Nacos high availability deployment

Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

In a distributed architecture, no middleware or application is allowed to be deployed singleton, so open source components support highly available cluster solutions. Nacos provides a cluster architecture similar to Zookeeper, including a Leader node and multiple Follower nodes. The difference between the two is that THE data consistency algorithm of Nacos adopts Raft.

Installation environment:
  • Linux system

  • More than 64 – bit JDK1.8

  • Maven 3.2 X and above

  • Three or more Nacos nodes

  • The MySQL database

Installation package: nacos-server-1.1.4.zip

5 folders: bin(service start/stop script), conf(configuration file), logs (log), data(database storage), target (compiled and packaged file)

The cluster configuration

In the conf directory

  • Application. properties: configuration file

  • Cluster.conf. example: example cluster configuration file

  • Nacos-mysql. SQL: mysql database script. Nacos supports both Derby and mysql persistence mechanisms. By default, the Derby database is used

  • Nacos-logback. XML: nacOS log configuration file

To configure the Nacos cluster, use the cluster.conf file. Add the following configuration information:

10.0.100.1:8848
10.0.100.2:8848
10.0.100.3:8848
Copy the code

Conf configurations on the three machines are the same. Because the three machines need to communicate with each other, port 8848 needs to be opened on the firewall during deployment.

Configuring the MySQL Database

Derby database is a kind of file type data, which has some limitations when using. For example, it cannot support multi-user operation at the same time, and a large number of connection backlogs will be generated when the data volume is large and the continuous number is large. MySQL database can be used instead

  • Execute nacos-mysql.sql to initialize the database
  • Modify the application.properties file under ${nacOS_HOME}/conf on the three machines respectively to add MySQl configuration
spring.datasource.platform=mysql
db.num=1
db.url=JDBC: mysql: / / 10.0.100.1:3306 / nacos_config
db.user=root
db.password=root
Copy the code