原文链接 https://nsq.io/components/nsqlookupd.html

nsqlookupd is the daemon that manages topology information. Clients query nsqlookupd to discover nsqdproducers for a specific topic and nsqd nodes broadcasts topic and channel information.

​ 'nsqlookupd '是管理拓扑信息的守护进程。客户端查询' nsqlookupd '来发现' nsqd '生产者的特定主题和' nsqd '节点广播主题和频道信息。

There are two interfaces: A TCP interface which is used by nsqd for broadcasts and an HTTP interface for clients to perform discovery and administrative actions.


Command Line Options

-broadcast-address string
    address of this lookupd node, (default to the OS hostname) (default "PROSNAKES.local")
#    此lookupd节点的地址(默认为系统主机名)(默认为“prosnake .local”)
-config string
    path to config file
#    配置文件路径
-http-address string
    <addr>:<port> to listen on for HTTP clients (default "")
#    <addr>:<port> 要监听HTTP客户机(默认为“”)
-inactive-producer-timeout duration
    duration of time a producer will remain in the active list since its last ping (default 5m0s)
#    自上次ping以来,生产者将保持在活动列表中的持续时间(默认为5m0s)
-log-prefix string
    log message prefix (default "[nsqlookupd] ")
#    日志消息前缀(默认为“[nsqlookupd]”)
-tcp-address string
    <addr>:<port> to listen on for TCP clients (default "")
#    <addr>:<port>监听TCP客户机(默认值“”)
-tombstone-lifetime duration
    duration of time a producer will remain tombstoned if registration remains (default 45s)
#    如果注册仍然存在,那么生产者将保持tombstoned状态的时间(默认为45秒)
    enable verbose logging
#    启用详细日志
    print version string
#    打印版本字符串

HTTP Interface

GET /lookup

Returns a list of producers for a topic




topic - the topic to list producers for

GET /topics

Returns a list of all known topics


GET /channels

Returns a list of all known channels of a topic



​ 参数

topic - the topic to list channels for
#    要列出通道的主题

GET /nodes

Returns a list of all known nsqd


POST /topic/create

Add a topic to nsqlookupd’s registry



topic - name of topic
#    主题名称    

POST /topic/delete

Deletes an existing topic

​ 删除现有主题



topic - the existing topic to delete
#    删除现有主题的名称

POST /channel/create

Add a channel to nsqlookupd’s registry


topic - name of topic
channel - name of channel

POST /channel/delete

Deletes an existing channel of an existing topic


topic - the existing topic
channel - the existing channel to delete

POST /topic/tombstone

Tombstones a specific producer of an existing topic. See deletion and tombstones.




topic - the existing topic
#    现有的主题
node - the producer (nsqd) to tombstone (identified by <broadcast_address>:<http_port>)
#    到tombstone的生产者(nsqd)(由<broadcast_address>:<http_port>标识)

GET /ping

Monitoring endpoint, should return OK

监视结点,应该返回' OK '

GET /info

Returns version information


Deletion and Tombstones

​ 删除与墓碑

When a topic is no longer globally produced it is a relatively simple operation to purge that information from the cluster. Assuming all the applications that were producing messages are downed, using the /delete_topicendpoint of your nsqlookupd instances is all that is necessary to complete the operation (internally, it will identify the relevant nsqd producers and perform the appropriate actions on those nodes).

当不再全局生成主题时,从集群中清除该信息是一个相对简单的操作。假设生成消息的所有应用程序都被关闭,使用' nsqlookupd '实例的' /delete_topic '端点即可完成操作(在内部,它将标识相关的' nsqd '生成器并在这些节点上执行适当的操作)。

For a global channel deletion the process is similar, the only difference being you would use the /delete_channelendpoint on your nsqlookupd instances and you would need to ensure that all consumers that were subscribed the the channel were already downed.

对于全局通道删除,过程是类似的,唯一的区别是您将在' nsqlookupd '实例上使用' /delete_channel '端点,并且您需要确保订阅了通道的所有消费者都已被关闭。

However, it gets a bit more complicated when a topic is no longer produced on a subset of nodes. Because of the way consumers query nsqlookupd and connect to all producers you enter into race conditions with attempting to remove the information from the cluster and consumers discovering that node and reconnecting (thus pushing updates that the topic is still produced on that node). The solution in these cases is to use “tombstones”. A tombstone in nsqlookupd context is producer specific and lasts for a configurable --tombstone-lifetime time. During that window the producer will not be listed in /lookup queries, allowing the node to delete the topic, propagate that information to nsqlookupd (which then removes the tombstoned producer), and prevent any consumer from re-discovering that node.

但是,当主题不再在节点的*子集上生成时,就会变得更加复杂。由于消费者查询' nsqlookupd '并连接到所有生产者的方式,您进入竞争条件,试图从集群中删除信息,消费者发现该节点并重新连接(从而推动更新,主题仍然在该节点上生成)。在这些情况下,解决方案是使用“tombstones”。' nsqlookupd '上下文中的tombstone是特定于生产者的,并且可以持续一个可配置的' -tombstone-lifetime '时间.在该窗口期间,生产者不会出现在“/lookup”查询中,允许节点删除主题,将该信息传播到“nsqlookupd”(然后“删除”已删除的生产者),并防止任何消费者重新发现该节点。

最后修改:2021 年 02 月 23 日 10 : 40 PM