CentOS 7 安装配置NSQ

CentOS 7 安装配置NSQ

介绍

NSQ 是实时的分布式消息处理平台,其设计的目的是用来大规模地处理每天数以十亿计级别的消息。
参考文档:https://nsq.io/overview/quick_start.html

安装

二进制下载路径:https://github.com/nsqio/nsq/releases
版本:nsq-1.1.0.linux-amd64.go1.10.3.tar.gz
上传到CentOS服务器,解压即可。

启动

进入解压路径的/bin目录

1. 启动nsqlookupd(nohup 后台启动):
$ nohup ./nsqlookupd &
2. 启动nsqd(nohup 后台启动)
$ nohup ./nsqd --lookupd-tcp-address=192.168.110.131(IP地址):4160 &
3. 启动nsqadmin(nohup 后台启动)
$ nohup ./nsqadmin --lookupd-http-address=192.168.110.131(IP地址):4161 &
4. 启动日志查看:bin目录会自动生成nohup日志,查看命令如下:
$ tail -f nohup.out

消息测试

1. 启动nsq_to_file,将消息写入/tmp文件的日志文件,文件名默认由主题topic+主机+日期时间戳组成
$ nohup ./nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=192.168.110.131(IP地址):4161 &
2. 使用curl命令,发布一条消息,返回OK
$ curl -d 'hello world' 'http://192.168.110.131(IP地址):4151/pub?topic=test'
3. 浏览器方问web界面:http://192.168.110.131:4171/,界面如下:

在这里插入图片描述

4. 点击test topic 进入详情:

在这里插入图片描述

注意事项

点击test topic 或者日志报错:

error connecting to nsqd - dial tcp: lookup xxx on xxx.xxx.xxx.xxx:53: no such host

需要编辑/etc/hosts 文件 ,添加你的机器名和ip映射即可
在这里插入图片描述

原创文章 29 获赞 82 访问量 1万+

猜你喜欢

转载自blog.csdn.net/cuixhao110/article/details/89928455