The following steps will run a small NSQ cluster on your local machine and walk through publishing,


consuming, and archiving messages to disk.


  1. follow the instructions in the INSTALLING doc.

    文档 链接 :
  1. in one shell, start nsqlookupd:

    $ nsqlookupd
  2. in another shell, start nsqd:

    在另一个shell中,启动' nsqd ':
    $ nsqd --lookupd-tcp-address=
  1. in another shell, start nsqadmin:

    #在另一个shell中,启动' nsqadmin '
    $ nsqadmin --lookupd-http-address=
  1. publish an initial message (creates the topic in the cluster, too):

    $ curl -d 'hello world 1' ''
  1. finally, in another shell, start nsq_to_file:

    最后,在另一个shell中,启动' nsq_to_file '
    $ nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=
  1. publish more messages to nsqd:

    $ curl -d 'hello world 2' ''
    $ curl -d 'hello world 3' ''
  1. to verify things worked as expected, in a web browser open to view the nsqadmin UI and see statistics. Also, check the contents of the log files (test.*.log) written to /tmp.

    #要验证事情是否如预期的那样工作,可以在web浏览器中打开“”来查看“nsqadmin”UI并查看统计数据。另外,检查写入' /tmp '的日志文件(' test.*.log ')的内容。

The important lesson here is that nsq_to_file (the client) is not explicitly told where the test topic is produced, it retrieves this information from nsqlookupd and, despite the timing of the connection, no messages are lost.

最后修改:2021 年 02 月 19 日 10 : 22 PM