A, description,
Nacos deployment in production environment must first use the cluster mode cluster to ensure high availability. This paper mainly introduces the best clustering solution how to build and how to integrate with spring Cloud program
Second, cluster scheme
The following figure is the official recommended cluster solution, which is implemented by domain name + VIP mode, which is readable and convenient to change IP addresses
Here the VIP can be implemented directly using Nginx
Iii. Implementation of the scheme
The minimum configuration of nacOS cluster is at least 3 instances. Since I only have one machine locally, I deploy these 3 instances by modifying the ports: 8848, 8849, and 8850 respectively
3.1. Modify cluster configurations
Conf configuration file cluster.conf exists in the conf directory of nacos. Set each line to IP address :port.
192.168.28.130:8848
192.168.28.130:8849
192.168.28.130:8850
Copy the code
192.168.28.130 is my local IP address, and all three NACOS instances are configured the same
3.2. Configure the MySQL database
The MySQL database must be used in cluster mode. You are advised to use at least active/standby mode in production mode, or use a high availability database
3.2.1. Initialize the MySQL database
The script has the configuration file nacos-mysql. SQL in the conf directory of nacOS. You can execute it directly
3.2.2. Add the database configuration
Add the following configuration to the application. Properties directory in the conf directory of nacOS
The db. The num = 1 db. Url. 0 = JDBC: mysql: / / 192.168.28.131:3306 / nacos_config? characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=root db.password=rootCopy the code
Db. num is the number of database instances. If multiple database instances pass db.url.0, db.url.1….. Specify different database links
3.3. Other examples modify the Nacos port
Change the server.port variable under application.properties in the conf directory of nacOS. The three instances are 8848, 8849, 8850 respectively
This step can be ignored if the cluster is deployed on different machines
3.4. Start the Nacos cluster
Run startup.sh in the bin directory of nacOS. The startup file is clustered by default
3.5. Modify the Nginx configuration
Modify the conf/nginx.conf configuration
Upstream {server 192.168.28.130:8848; Server 192.168.28.130:8849; Server 192.168.28.130:8850; } server { listen 80; server_name test.nacos.com; location / { proxy_pass http://nacos; }}Copy the code
The test.nacos.com domain name is bound to VIP
3.6. Program integration with Nacos cluster
Nacos address server-addr Configuration domain name test.nacos.com
4. Nacos Cluster management
Nacos. IO /zh-cn/docs/…
Recommended reading
- Log troubleshooting difficulty? Distributed log link tracing to help you
- Zuul integrates Sentinel’s latest gateway flow control components