nsq的搭建超详细

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/NiQinGe/article/details/89186857

对于什么是nsq,请参考https://blog.csdn.net/chinawangfei/article/details/80341688。

在本地搭建时,请先到nsq官网熟悉搭建流程,具体网址为:https://nsq.io/overview/quick_start.html。

搭建NSQ实时分布式消息平台,主要启动三个模块nsqlookupd 、nsqd、nsqadmin。

1.在第一个shell中,启动nsqlookupd

$ nsqlookupd
2.在第二个shell中,启动nsqd

$ nsqd --lookupd-tcp-address=127.0.0.1:4160
3.在第三个shell中,启动nsqadmin

$ nsqadmin --lookupd-http-address=127.0.0.1:4161
4.在第四个shell中,发布第一个消息(同时创建topic)

$ curl -d 'hello world 1' 'http://127.0.0.1:4151/pub?topic=test'
5.在第五个shell中,使用nsq_to_file启动一个client来接收消息

$ nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=127.0.0.1:4161
如果这一步报错找不到nsqd,那么转到第二个shell中,在命令行中添加-broadcast-address参数为本机IP地址,重新启动即可。

6.在第四个shell中,向nsqd发布更多的消息

$ curl -d 'hello world 2' 'http://127.0.0.1:4151/pub?topic=test'
$ curl -d 'hello world 3' 'http://127.0.0.1:4151/pub?topic=test'
怎么验证我们的搭建NSQ实时分布式消息平台已经正常工作了?有两种方式:

第一种方式:在浏览器中输入网址http://127.0.0.1:4171,打开nsqadmin的UI界面,查看统计数据。

第二种方式:转到/tmp目录(nsq_to_file命令的--output-dir参数值),查看“名称符合test.*.log模式”的文件内容。

猜你喜欢

转载自blog.csdn.net/NiQinGe/article/details/89186857
nsq
今日推荐