V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
jinzhongyuan
V2EX  ›  程序员

求一个熟悉 nacos 和 docker 的大哥,帮忙解答一下 docker-compose 启动 naocos 集群的问题

  •  
  •   jinzhongyuan · 2022-01-22 12:18:42 +08:00 · 1931 次点击
    这是一个创建于 1071 天前的主题,其中的信息可能已经有所发展或是发生改变。

    彦祖们,我使用这个仓库: https://github.com/nacos-group/nacos-docker/blob/master/README_ZH.md

    提供的 docker-compose.yml 去启动 nacos 集群

    日志显示 nacos 启动正常了

     
    nacos1    | 
    nacos1    |          ,--.
    nacos1    |        ,--.'|
    nacos1    |    ,--,:  : |                                           Nacos 2.0.3
    nacos1    | ,`--.'`|  ' :                       ,---.               Running in cluster mode, All function modules
    nacos1    | |   :  :  | |                      '   ,'\   .--.--.    Port: 8848
    nacos1    | :   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 1
    nacos1    | |   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://nacos1:8848/nacos/index.html
    nacos1    | '   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
    nacos1    | |   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
    nacos1    | '   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
    nacos1    | |   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
    nacos1    | '   : |     ;  :   .'   \   :    : `----'  '--'.     /
    nacos1    | ;   |.'     |  ,     .-./\   \  /            `--'---'
    nacos1    | '---'        `--`---'     `----'
    nacos1    | 
    nacos3    | 2022-01-22 11:37:37,117 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:38,133 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:39,151 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:40,175 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:41,223 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:42,272 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:43,374 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:44,659 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:45,904 INFO Nacos is starting...
    nacos3    | 
    nacos3    | 2022-01-22 11:37:48,495 INFO Nacos is starting...
    nacos3    | 
    
    

    但是我怎么访问 nacos 的控制台呢?

    http://127.0.0.1:8848/nacos/index.html 访问不了

    http://nacos1:8848/nacos/index.html 更访问不了(因为我压根没有 nacos1 这个 host )

    我本地 ifconfig 显示有多个网卡

    ➜  ~ ifconfig 
    lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
    	inet 127.0.0.1 netmask 0xff000000 
    	inet6 ::1 prefixlen 128 
    	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    	nd6 options=201<PERFORMNUD,DAD>
    gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
    stf0: flags=0<> mtu 1280
    en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    	ether ac:de:48:00:11:22 
    	inet6 fe80::aede:48ff:fe00:1122%en5 prefixlen 64 scopeid 0x4 
    	nd6 options=201<PERFORMNUD,DAD>
    	media: autoselect (100baseTX <full-duplex>)
    	status: active
    ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
    	options=400<CHANNEL_IO>
    	ether b2:9c:4a:cc:e4:9c 
    	media: autoselect
    	status: inactive
    en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    	options=400<CHANNEL_IO>
    	ether 90:9c:4a:cc:e4:9c 
    	inet6 fe80::6d:3c00:f311:eed%en0 prefixlen 64 secured scopeid 0x7 
    	inet 10.30.60.53 netmask 0xffffff00 broadcast 10.30.60.255
    	nd6 options=201<PERFORMNUD,DAD>
    	media: autoselect
    	status: active
    en8: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    	options=460<TSO4,TSO6,CHANNEL_IO>
    	ether ba:b2:eb:c7:a3:44 
    	media: autoselect <full-duplex>
    	status: inactive
    en9: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    	options=460<TSO4,TSO6,CHANNEL_IO>
    	ether ba:b2:eb:c7:a3:45 
    	media: autoselect <full-duplex>
    	status: inactive
    en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    	options=460<TSO4,TSO6,CHANNEL_IO>
    	ether ba:b2:eb:c7:a3:41 
    	media: autoselect <full-duplex>
    	status: inactive
    en4: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    	options=460<TSO4,TSO6,CHANNEL_IO>
    	ether ba:b2:eb:c7:a3:40 
    	media: autoselect <full-duplex>
    	status: inactive
    bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    	ether ba:b2:eb:c7:a3:41 
    	Configuration:
    		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
    		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
    		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
    		ipfilter disabled flags 0x0
    	member: en3 flags=3<LEARNING,DISCOVER>
    	        ifmaxaddr 0 port 10 priority 0 path cost 0
    	member: en4 flags=3<LEARNING,DISCOVER>
    	        ifmaxaddr 0 port 11 priority 0 path cost 0
    	member: en8 flags=3<LEARNING,DISCOVER>
    	        ifmaxaddr 0 port 8 priority 0 path cost 0
    	member: en9 flags=3<LEARNING,DISCOVER>
    	        ifmaxaddr 0 port 9 priority 0 path cost 0
    	nd6 options=201<PERFORMNUD,DAD>
    	media: <unknown type>
    	status: inactive
    p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    	options=400<CHANNEL_IO>
    	ether 02:9c:4a:cc:e4:9c 
    	media: autoselect
    	status: inactive
    awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
    	options=400<CHANNEL_IO>
    	ether 52:bf:d6:37:e4:e1 
    	inet6 fe80::50bf:d6ff:fe37:e4e1%awdl0 prefixlen 64 scopeid 0xe 
    	nd6 options=201<PERFORMNUD,DAD>
    	media: autoselect
    	status: active
    llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    	options=400<CHANNEL_IO>
    	ether 52:bf:d6:37:e4:e1 
    	inet6 fe80::50bf:d6ff:fe37:e4e1%llw0 prefixlen 64 scopeid 0xf 
    	nd6 options=201<PERFORMNUD,DAD>
    	media: autoselect
    	status: active
    utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
    	inet6 fe80::9e4e:800a:5b29:1e0d%utun0 prefixlen 64 scopeid 0x10 
    	nd6 options=201<PERFORMNUD,DAD>
    utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    	inet6 fe80::c370:7e36:ee82:4eca%utun1 prefixlen 64 scopeid 0x11 
    	nd6 options=201<PERFORMNUD,DAD>
    en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    	options=404<VLAN_MTU,CHANNEL_IO>
    	ether 00:0e:c6:6f:94:ac 
    	nd6 options=201<PERFORMNUD,DAD>
    	media: autoselect
    	status: inactive
    
    

    本质上还是对 docker 不熟悉。求彦祖解答,比心♥️

    7 条回复    2022-01-25 11:43:45 +08:00
    rainboat
        1
    rainboat  
       2022-01-22 13:29:02 +08:00 via iPhone
    docker ps 看看,看启动的容器有没有配置端口映射
    skiy
        2
    skiy  
       2022-01-22 13:46:04 +08:00
    netstat -tunlp | grep 8848 查看一下端口
    defunct9
        3
    defunct9  
       2022-01-22 13:57:58 +08:00 via iPhone
    开 ssh ,让我上去看看
    liuxu
        4
    liuxu  
       2022-01-22 14:02:05 +08:00 via Android
    docker 用的自己的 bridge ,和宿主机网络是隔开的,你映射端口没,docker exec 到容器里面看看 127.0.0.1 可以访问不
    jinzhongyuan
        5
    jinzhongyuan  
    OP
       2022-01-22 15:29:11 +08:00
    @rainboat
    ```txt
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    45c7f2bc405d nacos/nacos-server:latest "bin/docker-startup.…" 16 hours ago Up 13 minutes 0.0.0.0:8848->8848/tcp, 0.0.0.0:9555->9555/tcp nacos1
    3b03da856c6a nacos/nacos-server:latest "bin/docker-startup.…" 16 hours ago Up 3 minutes 0.0.0.0:8849->8848/tcp nacos2
    bd244aefe7af nacos/nacos-server:latest "bin/docker-startup.…" 16 hours ago Up 3 minutes 0.0.0.0:8850->8848/tcp nacos3
    c6b013b6c44d nacos/nacos-mysql:5.7 "docker-entrypoint.s…" 16 hours ago Up 15 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
    ```

    有端口映射的
    Usaki
        6
    Usaki  
       2022-01-24 08:28:41 +08:00 via Android
    可能是 iptables 的问题,重启下 docker 看看
    jinzhongyuan
        7
    jinzhongyuan  
    OP
       2022-01-25 11:43:45 +08:00
    破案了,哥哥们,是 nacos jvm 内存设置太大导致的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2492 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 04:38 · PVG 12:38 · LAX 20:38 · JFK 23:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.