1.将下载好的nacos放到linux的指定目录下,我的是放在/usr /local/nacos下
2.直接启动nacos
./bin/startup.sh
抛了以下异常
which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/bin)
readlink: missing operand
Try 'readlink --help' for more information.
dirname: missing operand
Try 'dirname --help' for more information.
ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! !!
修改配置文件,将JAVA_HOME重新指定一遍即可
cd /usr/local/nacos/nacos/bin/
vim startup.sh
3.配置nacos开机启动
vim /lib/systemd/system/nacos.service
添加如下:
[Unit]
Description=nacos
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nacos/nacos/bin/startup.sh -m standalone
ExecReload=/usr/local/nacos/nacos/bin/shutdown.sh
ExecStop=/usr/local/nacos/nacos/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
保存后执行以下命令:
systemctl daemon-reload
systemctl enable nacos.service
systemctl start nacos.service
访问路径:
http://192.168.86.100:8848/nacos
用户名默认:nacos,密码:nacos
4、配置自定义环境变量
新建sh文件
vim /etc/profile.d/nacos-server-address.sh
输入一下内容(nacos 的安装地址)
export nacos_server_address=http://172.17.31.25:8848
保存退出后刷新一下配置文件,要不然会不生效
source /etc/profile