1. 程式人生 > >NSQ如何在windows上安裝

NSQ如何在windows上安裝

1、NSQ下載連結

Current Stable Release: v0.3.8

nsq-0.3.8.windows-amd64.go1.6.2.tar.gz

該壓縮包下載解壓


2、環境變數path追加

E:\program\nsq-0.3.8.windows-amd64.go1.6.2\bin

3、新建CMD命令列,執行命令:

nsqlookupd

4、再新建一個CMD命令列,執行命令:

nsqd --lookupd-tcp-address=127.0.0.1:4160

5、再新建一個CMD命令列,執行命令:

nsqadmin --lookupd-http-address=127.0.0.1:4161

6、再新建一個CMD命令列(windows上用git bash)釋出一個帶有初始化資訊的topic,執行命令:

curl -d 'hello world 1' 'http://127.0.0.1:4151/put?topic=test'

此時,nsqd命令列中,顯示以下資訊:

[nsqd] 2016/09/05 10:42:45.369968 TOPIC(test): created

[nsqd] 2016/09/05 10:42:45.370968 NSQ: persisting topic/channel metadata to nsqd.864.dat

[nsqd] 2016/09/05 10:42:45.371968 LOOKUPD(127.0.0.1:4160): topic REGISTER test

nslookupd命令列中,顯示以下資訊:

[nsqlookupd] 2016/09/05 10:42:33.620296 CLIENT(127.0.0.1:41334): pinged (last ping 14.9998579s)

[nsqlookupd] 2016/09/05 10:42:45.371968 DB: client(127.0.0.1:41334) REGISTER category:topic key:test subkey:

[nsqlookupd] 2016/09/05 10:42:48.620154 CLIENT(127.0.0.1:41334): pinged (last ping 14.999858s)

7、此時topic暫無任何通道channel連線該topic,故釋出至topic中的訊息將會全部駐留在topic本身內部,我們可以嘗試多發幾條資訊至該topic:

curl -d 'hello world 2' 'http://127.0.0.1:4151/put?topic=test'

curl -d 'hello world 3' 'http://127.0.0.1:4151/put?topic=test'

curl -d 'hello world 4' 'http://127.0.0.1:4151/put?topic=test'

此時,執行完成之後,該名為test的topic,其內部有4條訊息待處理,即:

'hello world 1'、'hello world 2'、'hello world 3'、'hello world 4'

8、此時我們新建一個channel,來消費這些訊息:

nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=127.0.0.1:4161

執行命令完,顯示以下資訊

[email protected] MINGW32 ~

$ nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=127.0.0.1:4161

2016/09/05 12:14:55 INF 1 [test/nsq_to_file] querying nsqlookupd http://127.0.0.1:4161/lookup?topic=test

2016/09/05 12:14:55 INF 1 [test/nsq_to_file] (GY-PC:4150) connecting to nsqd

2016/09/05 12:14:55 INFO: opening C:/Users/GY/AppData/Local/Temp/test.GY-PC.2016-09-05_12.log

2016/09/05 12:14:55 syncing 1 records to disk

2016/09/05 12:15:25 syncing 3 records to disk

檢視log檔案


9、http://127.0.0.1:4171/是nsqadmin生成的控制檯檢視,根據這個url可以檢視Nsq的執行情況。


相關推薦

no