Build a Nacos cluster on linux (detailed steps)

Today is also a day of debugging. bug bug bug, error report error report error. Hereby record.

1) Nacos official website : https://github.com/alibaba/nacos/releases/tag/1.2.1

 

Download the nacos installation package to the local window (the suffix is ​​tar.zip)

 

2) Download the nginx package on linux, linux installation instructions: (first go to the nginx official website to check the version, Stable version is the stable version)

 

[root@localhost ~]#yum install lrzsz 
[root@localhost ~]#rz

4) Decompress the compressed package, I installed (nacos-server-1.2.1.tar.gz and nginx-1.18.0.tar.gz)

 

root@localhost ~]#tar -zxvf  nacos-server-1.2.1.tar.gz
[root@localhost ~]#tar -zxvf  nginx-1.18.0.tar.gz

4) Decompress the compressed package, I installed (nacos-server-1.2.1.tar.gz and nginx-1.18.0.tar.gz)

[root@localhost ~]#tar -zxvf  nacos-server-1.2.1.tar.gz
[root@localhost ~]#tar -zxvf  nginx-1.18.0.tar.gz

(5) After decompression, move the two packages to /usr/local

[root@localhost ~]#mv nacos /usr/local/nacos
[root@localhost ~]#mv nginx-1.18.0 /usr/local/nginx
[root@localhost ~]#cd /usr/local/
[root@localhost local]#ll

The installation is successful when you see the following interface: (I installed nacos under /mynacos . Install nacos under  /usr/local/ )

 

(6) Enter nacos and modify the following three files application.properties:

[root@localhost ~]#vim application.properties
(如果linux装的是Mysql5.+,在application.properties最后粘贴)
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&serverTimezon
e=UTC
db.user=root
db.password=ww000000

(如果linux装的是Mysql8.+,在application.properties最后写:)
spring.datasource.platform=mysql
jdbc.DriverClassName=com.mysql.cj.jdbc.Driver
# 指定数据库实例数量
db.num=1
# 第一个数据库实例地址
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?serverTimezone=GMT%2B8&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user= root
db.password= ww000000

保存退出

(Note: Except for nacos_config, user and password, follow your own database, login name, login password, and others don’t need to be changed)

 

7) Modify the cluster.conf file under conf:

[root@localhost conf]#hostname -I(一定要用大写I,因为小写i可能会是127.0.0.1,假设我查出来的是192.168.111.130)
[root@localhost conf]#vim cluster.conf

 

(The ip number in the front is found out with hostname -I, the port number in the back can be set by yourself without port conflict, save and exit)

 

(8) Modify the startup.sh file in the bin file under nacos:

[root@localhost bin]#cp startup.sh start.sh.init
[root@localhost bin]#vim startup.sh
 
 

 

(Note: This is -Dserver.port=${PORT}, don’t mistake it for ".")

Be sure to start the mysql service before starting, otherwise nacos will report an error:

[root@localhost ~]#service mysql start

Execution results in the bin directory of nacos:

 

At the same time visit through the window browser:

http://192.168.171.128:3333/nacos/#/login

http://192.168.171.128:4444/nacos/#/login

http://192.168.171.128:5555/nacos/#/login

 

If the following page appears, the configuration is successful:

 

9) Change the nginx file configuration:

[root@localhost conf]#vim nginx.conf

(Note: The upstre cluster originally did not have to be added by yourself. The latter two original configuration texts only need to be found and modified. Among them, listen represents the port number of nginx and can be defined by yourself, and also do not conflict)

 

(10) Carry out pre-start inspection:

 [root@localhost conf]#ps -ef|grep nacos|grep -v grep|wc -l

(Note: This must be displayed as 3, which means that ports 3333, 4444, and 5555 have been started. If it is not 3, it means that the running memory is insufficient. At this time, go to the bin directory under nacos and modify startup.sh again, and change the value in the red box The small, originally it seems to be 2g, 2g, 2g, I changed it to 256m, 256m, 256m, reduce the running memory)

11) To start:

Enter the sbin directory under nginx:

[root@localhost sbin]#./nginx -c /usr/local/nginx/conf/nginx.conf

Finally, enter the local browser and enter: 192.168.171.128:1111/nacos to enter the console.

 

 

 

Guess you like

Origin blog.csdn.net/m0_46405589/article/details/114990708