配置文件
#Client port of 4222 on all interfaces
port: 4222#HTTP monitoring port monitor_port: 8222
#This is for clustering multiple servers together. cluster {
#Route connections to be received on any interface on port 6222
port: 6222#Routes are protected, so need to use them with --routes flag #
e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222
authorization {
user: ruser
password: T0pS3cr3t
timeout: 2 }#Routes are actively solicited and connected to from this server.
#This Docker image has none by default, but you can pass a # flag to the gnatsd docker image to create one to an existing server.
routes = [] }#最大的有效负载 ,默认1mb
max_payload: 20MB
#数据发布等待时间,超过这个时间nats就会自动停掉这次发布
write_deadline: 60s
docker开启nats服务
//先copy出nats的配置文件,然后再挂载,因为无法进入到容器内部
[root@rookieWRL myNats3]# ls
nats1-server.conf
[root@rookieWRL myNats3]# docker run -d -it -p 4222:4222 -v $PWD/nats1-server.conf:/nats-server.conf nats:latest
一系列操作
查看日志
[root@rookieWRL myNats3]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
348e940fdacd nats:latest "/nats-server --conf…" 8 minutes ago Up 8 minutes 6222/tcp, 0.0.0.0:4222->4222/tcp, 8222/tcp optimistic_maxwell
docker logs -f 348

本文介绍NATS消息中间件的配置文件设置方法,包括端口配置、集群配置及最大有效负载等参数调整。通过具体实例展示了如何使用Docker运行NATS服务并挂载配置文件。

2767

被折叠的 条评论
为什么被折叠?



