• 请不要在回答技术问题时复制粘贴 AI 生成的内容
avichen
V2EX  ›  程序员

有用过 NSQ 的吗,它做 cluster 不能在一台机器上跑多个实例吗?

  •  
  •   avichen · Oct 11, 2016 · 5405 views
    This topic created in 3523 days ago, the information mentioned may be changed or developed.
    不知道谁用过 NSQ ,想请教关于是否可以在单台机器上部署 cluster 的问题

    想通过以下方式起多个实例,但是启动失败,只能在默认端口起
    /usr/local/bin/nsq/nsqlookupd -config=/usr/local/bin/nsq/nsqlookupd.4160.cfg
    /usr/local/bin/nsq/nsqlookupd -config=/usr/local/bin/nsq/nsqlookupd.4260.cfg
    /usr/local/bin/nsq/nsqd -config= /usr/local/bin/nsq/nsqd.4150.cfg
    /usr/local/bin/nsq/nsqd -config= /usr/local/bin/nsq/nsqd.4250.cfg
    /usr/local/bin/nsq/nsqadmin --lookupd-http-address=0.0.0.0:4161
    11 replies    2016-10-12 11:43:15 +08:00
    janxin
        1
    janxin  
       Oct 12, 2016 via iPhone
    端口号和 workerid 改了么?

    单机部署是为了测试?
    avichen
        2
    avichen  
    OP
       Oct 12, 2016
    @janxin
    端口都改了, workerid 是在哪儿的?
    三个 cfg 里面都没看到这个配置项
    ghbai
        3
    ghbai  
       Oct 12, 2016
    你看下启动失败的错误提示然后找原因就可以了啊。
    ps:单台机器部署 cluster 是没有意义的。
    avichen
        4
    avichen  
    OP
       Oct 12, 2016
    @ghbai 端口被占用,但是两个实例启动配置文件是配的不同的端口, ip 都是 0.0.0.0,难道两个端口不能在一个 IP 上启动?
    启动另一个就提示端口被占用,感觉配置文件的参数没有生效

    目前只是测试用,不是为了生产

    nsqd 配置部分代码如下,两个实在分别配置的 4150 、 4151 和 4250 、 4251

    ## enable verbose logging
    verbose = false

    ## unique identifier (int) for this worker (will default to a hash of hostname)
    id = 4150

    ## <addr>:<port> to listen on for TCP clients
    tcp_address = "0.0.0.0:4150"

    ## <addr>:<port> to listen on for HTTP clients
    http_address = "0.0.0.0:4151"

    ## <addr>:<port> to listen on for HTTPS clients
    # https_address = "0.0.0.0:4152"

    ## address that will be registered with lookupd (defaults to the OS hostname)
    # broadcast_address = ""

    ## cluster of nsqlookupd TCP addresses
    nsqlookupd_tcp_addresses = [
    "127.0.0.1:4160"
    "127.0.0.1:4260"
    ]
    ...
    ghbai
        5
    ghbai  
       Oct 12, 2016
    我自己试了下是可以的哇
    nsqd 的两个配置文件分别为
    /*nsqd.4150.cfg*/
    id = 1
    tcp_address = "0.0.0.0:4150"
    http_address = "0.0.0.0:4151"
    data_path = "./data1"
    nsqlookupd_tcp_addresses = [
    "127.0.0.1:4160"
    ]

    /*nsqd.4250.cfg*/
    id = 2
    tcp_address = "0.0.0.0:4250"
    http_address = "0.0.0.0:4251"
    data_path = "./data2"
    nsqlookupd_tcp_addresses = [
    "127.0.0.1:4160"
    ]
    avichen
        6
    avichen  
    OP
       Oct 12, 2016
    你 nsqlookupd 只监听了一个?应该也有对应的两个 nsqlookupd 吧
    ghbai
        7
    ghbai  
       Oct 12, 2016
    再加上一个 nsqlookupd 也是可以的,没有关系。
    avichen
        8
    avichen  
    OP
       Oct 12, 2016
    @ghbai 我现在试试看
    ghbai
        9
    ghbai  
       Oct 12, 2016
    我 QQ 号 951644384,加 QQ 聊吧,我帮你看下。
    avichen
        10
    avichen  
    OP
       Oct 12, 2016
    第一个启动后,生成的文件名是 856 的,第二个也是 856 的,这个是在哪儿控制修改的?
    4150
    [root@localhost nsq]# /usr/local/bin/nsq/nsqd -config= /usr/local/bin/nsq/nsqd.4150.cfg
    [nsqd] 2016/10/12 11:38:06.890583 nsqd v0.3.8 (built w/go1.6.2)
    [nsqd] 2016/10/12 11:38:06.895451 ID: 856
    [nsqd] 2016/10/12 11:38:06.895498 NSQ: persisting topic/channel metadata to nsqd.856.dat
    [nsqd] 2016/10/12 11:38:06.914159 HTTP: listening on [::]:4151
    [nsqd] 2016/10/12 11:38:06.914438 TCP: listening on [::]:4150

    4250
    [root@localhost nsq]# /usr/local/bin/nsq/nsqd -config= /usr/local/bin/nsq/nsqd.4250.cfg
    [nsqd] 2016/10/12 11:38:45.406966 FATAL: --data-path=/usr/local/bin/nsq in use (possibly by another instance of nsqd)
    ghbai
        11
    ghbai  
       Oct 12, 2016   ❤️ 1
    错误提示是 FATAL: --data-path=/usr/local/bin/nsq in use (possibly by another instance of nsqd)
    你要为这两个实例指定不同的 data_path 参数,不是监听端口的问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2991 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 14:53 · PVG 22:53 · LAX 07:53 · JFK 10:53
    ♥ Do have faith in what you're doing.