创作不易感谢支持。
一条主写Go和PHP的小菜鸟。平常有时间喜欢自己写点东西,如有不对的地方,欢迎大佬指点。 个人博客:太阳上的雨天 地址:http://blog.caixiaoxin.cn 善于分享,希望有助他人. 非常感谢各位大佬的关注和支持
version: "3"
services:
my-nsq-admin:
image: nsqio/nsq:v1.1.0
command: /nsqadmin -lookupd-http-address my-nsq-nsqlookupd1:4161 -lookupd-http-address my-nsq-nsqlookupd2:4261
ports:
- "4171:4171"
my-nsq-nsqd1:
image: nsqio/nsq:v1.1.0
hostname: my-nsq-nsqd1
command: /nsqd -tcp-address 0.0.0.0:4150 -data-path /usr/local/nsq/bin/data --http-address 0.0.0.0:4151 -lookupd-tcp-address my-nsq-nsqlookupd1:4160 -lookupd-tcp-address my-nsq-nsqlookupd2:4260 -broadcast-address my-nsq-nsqd1
volumes:
- "./data1:/usr/local/nsq/bin/data"
ports:
- "4150:4150"
- "4151:4151"
my-nsq-nsqd2:
image: nsqio/nsq:v1.1.0
hostname: my-nsq-nsqd2
command: /nsqd -tcp-address 0.0.0.0:4250 -data-path /usr/local/nsq/bin/data -http-address 0.0.0.0:4251 -lookupd-tcp-address my-nsq-nsqlookupd1:4160 -lookupd-tcp-address my-nsq-nsqlookupd2:4260 -broadcast-address=my-nsq-nsqd2
volumes:
- "./data2:/usr/local/nsq/bin/data"
ports:
- "4250:4250"
- "4251:4251"
my-nsq-nsqd3:
image: nsqio/nsq:v1.1.0
hostname: ysdp-nsq-nsqd3
command: /nsqd -tcp-address 0.0.0.0:4350 -data-path /usr/local/nsq/bin/data --http-address 0.0.0.0:4351 -lookupd-tcp-address my-nsq-nsqlookupd1:4160 -lookupd-tcp-address my-nsq-nsqlookupd2:4260 -broadcast-address=my-nsq-nsqd3
volumes:
- "./data3:/usr/local/nsq/bin/data"
ports:
- "4354:4350"
- "4355:4351"
my-nsq-nsqlookupd1:
image: nsqio/nsq:v1.1.0
command: /nsqlookupd -http-address 0.0.0.0:4161 -tcp-address 0.0.0.0:4160 -broadcast-address my-nsq-nsqlookupd1
ports:
- "4160:4160"
- "4161:4161"
my-nsq-nsqlookupd2:
image: nsqio/nsq:v1.1.0
command: /nsqlookupd -http-address 0.0.0.0:4261 -tcp-address 0.0.0.0:4260 -broadcast-address my-nsq-nsqlookupd2
ports:
- "4260:4260"
- "4261:4261"
docker-compose up -d
浏览器访问:127.0.0.1:4171/nodes
因为基于nsqlookupd 的数据发现需要访问broadcast-address 暴露的地址,所以需要配置,同时都需要加上
127.0.0.1 my-nsq-nsqd1
127.0.0.1 my-nsq-nsqd2
127.0.0.1 my-nsq-nsqd3