Linux (Centos7) install Nacos

1. Install JDK

JDK installation - refer to the previous article for detailed steps. installed can be ignored

2. Install Nacos

1. Upload the nacos compressed package to /optthe directory

insert image description here
2. Unzip to/usr/local/

 tar -zxvf nacos-server-1.4.2.tar.gz -C /usr/local/

insert image description hereinsert image description here
3. Modify the nacos configuration file – ( nacos/conf/application.properties)
– Find the following configuration, uncomment it, and change it to your own database ip address, database user name and password

vim /usr/local/nacos/conf/application.properties

insert image description here

4. Create a Nacos database
- - 1. Create a new database nacos, here I use Navicat to create
insert image description here
insert image description here
- - 2. The nacos installation package comes with a database script. Script location:/usr/local/nacos/conf/nacos-mysql.sql

insert image description here
- - 3. Import the scriptnacos数据库 , refresh after the import is complete, and then open the table
insert image description here
and the corresponding table will appear
. It is recommended to use the second type

- - 1. Directly use the command stand-alone start - -

// 在/usr/local/nacos/bin/ 下执行
sh startup.sh -m standalone

insert image description here
- - Check the startup log, if there is no abnormal log, the startup is successful

cat /usr/local/nacos/logs/start.out

insert image description here
- - 2. Modify the startup configuration file to start- -MODE="cluster" Change toMODE="standalone"

//文件路径:/usr/local/nacos/bin/startup.sh
vim /usr/local/nacos/bin/startup.sh

insert image description here

//在 /usr/local/nacos/bin/下执行
sh startup.sh

6. Browser access login - close the firewall or open the firewall port (nacos default port 8848), choose one

//1. 关闭防火墙
1. systemctl stop firewalld 

//2. 防火墙开放8080端口
1. firewall-cmd --zone=public --add-port=8848/tcp --permanent
2. systemctl restart firewalld   //重启
//登录信息
url:      http://IP:8848/nacos/index.html
user:     nacos
password :nacos

insert image description here
insert image description here

Set Nacos to start automatically

1. Create a new system service file ( nacos.service), add the following content

vim /etc/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

2. Modify the configuration file, modify the first line to your own jdk path, and comment the following three lines

vim /usr/local/nacos/bin/startup.sh

insert image description here
3. Set the boot to start

systemctl daemon-reload //重新加载服务配置
systemctl enable nacos  //设置为开机启动

4. start

systemctl start nacos  //启动nacos服务
systemctl status nacos //查看nacos状态

Guess you like

Origin blog.csdn.net/dontYouWorry/article/details/128969474