nacos 诡异的连接不上解决方案
搭建最新版spring cloud,今天做服务注册nacos时候遇到了这样一个错误:
NacosException: failed to req API:/nacos/v1/ns/instance after all servers([localhost:8848]
望文生义,改配置,清缓存,重新打包,翻来覆去依然报这个错,注我的配置:
cloud:
nacos:
config:
server-addr: 192.168.18.111:8848
file-extension: yaml
discovery:
server-addr: 192.168.18.111:8848
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
怀着忐忑的心情替换了我以前安装的nacos:
wget https://github.com/alibaba/nacos/releases/download/1.4.1/nacos-server-1.4.1.tar.gz
tar -zxvf nacos-server-1.4.1.tar.gz
systemctl restart nacos.service
果然启动成功!这该死的气质。
顺便记录当年文档有个没有给写清楚的启动脚本:
步骤:cd /usr/lib/systemd/system
vim nacos.service
脚本内容:
[Unit]
Description=nacos
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/obj/nacos/bin/startup.sh -m standalone
ExecReload=/usr/local/obj/nacos/bin/shutdown.sh
ExecStop=/usr/local/obj/nacos/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
这样就可以使用systemctl 管理nacos,配置开机启动啥的相当方便!