NATS服务器配置的详细介绍
前言:
尽管NATS可以无配置的运行,但也可以使用配置文件配置NATS服务器。
1)配置项包括
2)配置文件的语法
NATS服务器配置文件的格式比较灵活,结合了传统的JSON格式和新的YAML格式的风格。
NATS配置文件格式支持以下语法:
Mixed Arrays: […]
Nested Maps: {…}
Multiple comment types: # and //
Key value assigments using:
Equals sign (foo = 2)
Colon (foo: 2)
Whitespace (foo 2)
Maps can be assigned with no key separator
Semicolons as value terminators in key/value assignments are optional
注:YAML不是标记语言,而是一种语言中立的、对阅读友好的数据序列化标准。YAML语言发展了三个版本,1.0、1.1、1.2,
3)NATS服务器配置文件示例
下面是一个完整的NATS服务器配置文件样例:
port: 4242 # 供客户端连接的监听端口
net: apcera.me # 监听的网络地址
http_port: 8222 # HTTP监控端口
# 客户端连接的认证信息
authorization {
user: derek
password: T0pS3cr3t
timeout: 1
}
# 集群定义
cluster {
host: '127.0.0.1' # 主机地址
port: 4244 # 路由连接的入站(inbound)端口
# 路由连接的认证信息
authorization {
user: route_user
password: T0pS3cr3tT00!
timeout: 0.5
}
# Routes are actively solicited and connected to from this server.
# Other servers can connect to us if they supply the correct credentials
# in their routes definitions from above.
routes = [
nats-route://user1:pass1@127.0.0.1:4245
nats-route://user2:pass2@127.0.0.1:4246
]
}
# 日志选项
debug: false
trace: true
logtime: false
log_file: "/tmp/gnatsd.log"
# PID进程文件
pid_file: "/tmp/gnatsd.pid"
# 一些系统属性
# 客户端最大连接数
max_connections: 100
# 最大协议控制行
max_control_line: 512
# 最大的有效负载
max_payload: 65536
# 慢消费者阀值
max_pending_size: 10000000
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。