1.下载nacos-server-2.1.0.tar.gz:
https://github.com/alibaba/nacos/releases/tag/2.1.0
2.将nacos-mysql.sql导入到MySQL:
(1)在window系统中打开nacos-server-2.1.0.tar.gz,将nacos\conf\nacos-mysql.sql文件解压出来:
(2)使用Navicat连接MySQL,执行nacos-mysql.sql脚本文件,导入nacos数据库(表结构与表数据):
说明:nacos数据库用于存储配置等信息
3.安装Nacos:
(1)使用XFtp将nacos-server-2.1.0.tar.gz上传到CentOS7的root目录并解压:
[root@localhost ~]# tar -zxvf nacos-server-2.1.0.tar.gz
(2)将已解压的nacos文件夹移动到/usr/local目录:
[root@localhost ~]# mv nacos /usr/local/
(3)在application.properties中配置MySQL连接(cd /usr/local/nacos/conf):
[root@localhost conf]# vi application.properties
内容如下:
### 连接MySQL数据库:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=root123456
4.设nacos为开机启动:
(1)创建nacos服务:
[root@localhost ~]# vi /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.targe
(2)重载:
[root@localhost ~]# systemctl daemon-reload
(3)添加开机启动:
[root@localhost ~]# systemctl enable nacos
(4)启动/查看状态/停止服务:
[root@localhost ~]# systemctl start nacos
[root@localhost ~]# systemctl status nacos
[root@localhost ~]# systemctl stop nacos
5.访问nacos页面(用户与密码都是nacos):
http://192.168.83.129:8848/nacos/#/login