Centos 8.2 安装 Nacos
Nacos安装、启动
- 准备安装包:/usr/local/pkgs/nginx-1.21.6.tar.gz
- 解压安装包
tar -zxvf nacos-server-2.1.0.tar.gz -C /usr/local/
- 启动(不用立即启动)
[root@VM-12-13-centos bin]# pwd
/usr/local/nacos/bin
[root@VM-12-13-centos bin]# ./startup.sh -m standalone
- 设置开机启动
vim /lib/systemd/system/nacos.service
文件内容
[Unit]
Description=nacos
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nacos/bin/startup.sh -m standalone
ExecReload=/usr/local/nacos/bin/shutdown.sh
ExecStop=/usr/local/nacos/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
执行命令
systemctl daemon-reload
systemctl enable nacos.service
systemctl start nacos.service
修改启动文件 bin/startup.sh,增加JAVA_HOME变量
查看Nacos的运行状态
systemctl status nacos.service
访问Nacos
http://IP:8848/nacos
默认登录账号:nacos/nacos
nacos使用Mysql存储数据
配置前,请先结束Nacos服务进程
systemctl stop nacos.service
- 创建并初始化数据库
数据库名:nacos_config
执行脚本:/usr/local/nacos/conf/nacos-mysql.sql
- 修改配置文件:/usr/local/nacos/conf/application.properties
取消以下几个配置项的注释符号,并配置相应的值
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://IP:3306/nacos_config?characterEncoding=utf8&connectTimeout=6000&socketTimeout=6000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai
db.user.0=login_name
db.password.0=login_pass
- 重新加载配置、重新启动nacos服务
systemctl daemon-reload
systemctl start nacos.service