nsq简单安装以及测试
来源:互联网 发布:wifi定位技术算法 编辑:程序博客网 时间:2024/06/09 23:49
介绍
NSQ 是实时的分布式消息处理平台,其设计的目的是用来大规模地处理每天数以十亿计级别的消息。
NSQ 具有分布式和去中心化拓扑结构,该结构具有无单点故障、故障容错、高可用性以及能够保证消息的可靠传递的特征。
二进制下载路径:
https://github.com/nsqio/nsq/releases
下载需要的二进制包:
解压之后:
执行一下命令:
cd /Users/xinzhiyun/nsq/nsq-1.0.0-compat.darwin-amd64.go1.8/bin
安装
在一个 shell 中,运行 nsqlookupd:
➜ bin ./nsqlookupd [nsqlookupd] 2017/11/27 22:48:11.186029 nsqlookupd v1.0.0-compat (built w/go1.8)[nsqlookupd] 2017/11/27 22:48:11.186266 TCP: listening on [::]:4160[nsqlookupd] 2017/11/27 22:48:11.186314 HTTP: listening on [::]:4161
再开启一个 shell,运行 nsqd:
➜ bin ./nsqd --lookupd-tcp-address=127.0.0.1:4160[nsqd] 2017/11/27 22:49:11.433686 nsqd v1.0.0-compat (built w/go1.8)[nsqd] 2017/11/27 22:49:11.433755 ID: 280[nsqd] 2017/11/27 22:49:11.433797 NSQ: persisting topic/channel metadata to nsqd.dat[nsqd] 2017/11/27 22:49:11.434504 TCP: listening on [::]:4150[nsqd] 2017/11/27 22:49:11.434596 HTTP: listening on [::]:4151[nsqd] 2017/11/27 22:49:11.434641 LOOKUP(127.0.0.1:4160): adding peer[nsqd] 2017/11/27 22:49:11.434653 LOOKUP connecting to 127.0.0.1:4160[nsqd] 2017/11/27 22:49:11.435319 LOOKUPD(127.0.0.1:4160): peer info {TCPPort:4160 HTTPPort:4161 Version:1.0.0-compat BroadcastAddress:xinzhiyundeMacBook-Pro.local}
再开启第三个 shell,运行 nsqadmin:
➜ bin ./nsqadmin --lookupd-http-address=127.0.0.1:4161[nsqadmin] 2017/11/27 22:50:18.517989 nsqadmin v1.0.0-compat (built w/go1.8)[nsqadmin] 2017/11/27 22:50:18.518233 HTTP: listening on [::]:4171
开启第四个 shell,推送一条初始化数据(并且在集群中创建一个 topic):
➜ bin curl -d 'hello world 1' 'http://127.0.0.1:4151/pub?topic=test' OK
最后,开启第五个 shell, 运行 nsq_to_file:
➜ bin ./nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=127.0.0.1:41612017/11/27 22:54:01 INF 1 [test/nsq_to_file] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=test2017/11/27 22:54:01 ERR 1 [test/nsq_to_file] error querying nsqlookupd (http://127.0.0.1:4161/lookup?topic=test) - got response 404 Not Found "{\"message\":\"TOPIC_NOT_FOUND\"}"2017/11/27 22:54:31 INFO: opening /tmp/test.xinzhiyundeMacBook-Pro.2017-11-27_22.log2017/11/27 22:55:10 INF 1 [test/nsq_to_file] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=test2017/11/27 22:55:10 ERR 1 [test/nsq_to_file] error querying nsqlookupd (http://127.0.0.1:4161/lookup?topic=test) - got response 404 Not Found "{\"message\":\"TOPIC_NOT_FOUND\"}"2017/11/27 22:56:10 INF 1 [test/nsq_to_file] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=test2017/11/27 22:56:10 ERR 1 [test/nsq_to_file] error querying nsqlookupd (http://127.0.0.1:4161/lookup?topic=test) - got response 404 Not Found "{\"message\":\"TOPIC_NOT_FOUND\"}"2017/11/27 22:57:10 INF 1 [test/nsq_to_file] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=test2017/11/27 22:57:10 INF 1 [test/nsq_to_file] (xinzhiyundeMacBook-Pro.local:4150) connecting to nsqd2017/11/27 22:57:10 ERR 1 [test/nsq_to_file] (xinzhiyundeMacBook-Pro.local:4150) error connecting to nsqd - dial tcp: lookup xinzhiyundeMacBook-Pro.local on 10.39.1.10:53: no such host2017/11/27 22:58:10 INF 1 [test/nsq_to_file] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=test2017/11/27 22:58:10 INF 1 [test/nsq_to_file] (xinzhiyundeMacBook-Pro.local:4150) connecting to nsqd2017/11/27 22:58:10 ERR 1 [test/nsq_to_file] (xinzhiyundeMacBook-Pro.local:4150) error connecting to nsqd - dial tcp: lookup xinzhiyundeMacBook-Pro.local on 10.39.1.10:53: no such host
这一步报错 只是报找不到losthost而已,这个不影响测试,解决办法只要在hosts文件添加相关host就可以了
推送更多地数据到 nsqd:
➜ bin curl -d 'hello world 2' 'http://127.0.0.1:4151/pub?topic=test'OK% ➜ bin curl -d 'hello world 3' 'http://127.0.0.1:4151/pub?topic=test'OK% ➜ bin curl -d curl -d 'hello world 1' 'http://127.0.0.1:4151/pub?topic=test01' OK%
按照预先设想的,在浏览器中打开 http://127.0.0.1:4171/ 就能查看 nsqadmin 的 UI 界面和队列统计数据。同时,还可以在 /tmp 目录下检查 (test.*.log) 文件.
这个教程中最重要的是:nsq_to_file (客户端)没有明确地指出 test 主题从哪里产生,它从 nsqlookupd 获取信息,即使在消息推送之后才开始连接 nsqd,消息也并没有消失。
–参考
http://nsq.io
阅读全文
0 0
- nsq简单安装以及测试
- NSQ的安装运行以及编程实践
- NSQ-简单启动说明
- NSQ 安装指南
- nsq安装及初探
- nsq
- nsq
- CentOS 7下安装nsq
- ubuntu下nsq的安装
- ubuntu nsq安装与配置
- ubuntu nsq安装与配置
- redis安装以及主从的简单配置测试
- mac appium自动化测试 安装以及简单使用 小白篇
- robotframework介绍安装以及简单测试用例
- linux下expect环境安装以及简单脚本测试
- linux下expect环境安装以及简单脚本测试
- NSQ的golang客户端简单使用
- NSQ如何在windows上安装
- NYACM_006
- scala学习笔记-高阶函数
- HDU-OJ2041解题心得
- 洛谷3987之我的解法
- linux下mysql主从同步
- nsq简单安装以及测试
- 最短路径—Dijkstra算法和Floyd算法
- 接口优于反射
- java 时间转换错误 月份始终转换成1月
- OpenCV+Python车牌字符分割和识别入门
- hibernate_day04_17_hibernate批量抓取
- python 判断list是否为空
- 第六章:访问权限控制
- 第十二题 任务调度的贪心