This article was written after the completion of the construction. If there is any error, please correct me.
This time the environment is two centos7.4
1: Download the nacos package
wget https://github.com/alibaba/nacos/releases/download/1.1.3/nacos-server-1.1.3.tar.gz
2: Unzip the source code package and move it to a location you like
tar -zxf nacos-server-1.1.3.tar.gz
mv nacos /usr/src/
3: Find your own java address and install it if you don't have it
yum -y install java* #If java is not installed, do this step with * to install other dependencies together#
whereis java #Find your own java path#
Modify the path of java in the nacos configuration file. If it is not changed, it will not start if it is different from the default location.
4: The stand-alone version can be started here. After successful startup, enter http://ip address:8848/nacos/index.html in the browser to access
5: Nacos cluster construction
(1) Steps 1-3 must be operated on each server
(2) Build a mysql database. (Because the stand-alone nacos has a default library, you need to do mysql yourself to build a cluster)
yum -y install mariadb* (mysql renamed to mariadb above centos7. MySQLd below 7)
After the installation is successful, start the database, create a library, and set the root password. Grant access rights.
systemctl start mariadb #Start mysql database#
mysql -uroot #Log in with root user#
create database nacos; #Create nacos database#
use mysql; #Enter mysql library#
set password for root@localhost = password ('123456'); #Set the password for root user to 123456#
Grant ALL PRIVILEGES ON *.* TO'root'@'%' IDENTIFIED BY'root'; "Grant root user remote access permissions"
flush privileges; #Reload to make it take effect immediately. #
exit; #Exit the database#
cd /usr/src/nacos/conf #Enter the conf directory of nacos#
mysql -uroot -p123456 -B nacos <nacos-mysql.sql #import sql script into nacos library#
(3) Add the server list to the cluster file and configure the database connection
cd /usr/src/nacos/conf #Enter the conf directory under nacos#
mv cluster.conf.example cluster.conf #Rename the file#
vim cluster.conf #Add the server ip and port number. I only have two #
vim /usr/src/nacos/conf/application.properties #Add a database connection at the end of this file#
#Add boot from start#
写到/ect/rc.local
sh /usr/src/nacos/bin/startup.sh
#Start after adding#
The stop and start commands are in nacos/bin
If it started just now, stop it first: sh shutdown.sh Start: sh startup.sh
Check logs/start.out after input
If it appears: INFO Nacos started successfully in cluster mode, then it is successful