Bootstrap

centOS7安装nacos

安装nacos

从github中下载好 nacos 的包后上传到 centos7中
将其解压到一个位置 tar zxvf nacos-server-x.x.x.tar.gz -C /usr/local/nacos
单机启动命令: sh /usr/local/nacos/bin/startup.sh -m standalone
单机关闭命令: sh /usr/local/nacos/bin/shutdown.sh -m standalone
访问地址: http://ip:8848/nacos/#/login [ ip是centos7 的ip地址, 不知道的话可以使用 ip addr 命令查看 ]

配置开机启动

cd /usr/local/nacos/bin
chmod +x *.sh
vim /usr/lib/systemd/system/nacos.service
[Unit]
Description=nacos
After=network.target

[Service]
Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_261"
Type=forking
#standalone 是单机,默认是集群cluster 
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

修改startup.sh脚本

#查看javac位置
which javac
#修改nacos启动脚本
vi /usr/local/nacos/bin/startup.sh
error_exit ()
{
    echo "ERROR: $1 !!"
    exit 1
}
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/local/java/jdk1.8.0_261
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/opt/taobao/java
[ ! -e "$JAVA_HOME/bin/java" ] && unset JAVA_HOME

if [ -z "$JAVA_HOME" ]; then

配置数据库

vim /usr/local/nacos/conf/application.properties
### If use MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=123456

下面是启动时命令

systemctl daemon-reload
#启用开启自启服务
systemctl enable nacos.service
#启动服务
systemctl start nacos.service
#删除服务
systemctl disable nacos.service

> > >
;