当前位置:网站首页>Detailed explanation of the construction process of Nacos cluster
Detailed explanation of the construction process of Nacos cluster
2022-08-05 06:44:00 【User Nickname 23】
I. Nacos cluster deployment architecture
In the actual development process, if Nacos is used, in order to ensure high availability, we generally deploy it in a cluster.Nacos stipulates that the number of Nacos nodes in the cluster must be greater than or equal to 3; at the same time, the data of Nacos in stand-alone mode is stored in its embedded database by default, which is inconvenient to observe the basic situation of data storage.Moreover, if multiple Nacos nodes with default configuration are started in the cluster, there is a consistency problem in data storage.In order to solve this problem, Nacos adopts a centralized storage method to support clustered deployment, and currently only supports MySQL storage; in addition, we also need to use Nginx to achieve load balancing.The deployment architecture diagram of this process is shown below:
Second, switch the default database of Nacos
(1) Before starting to build the cluster, we need to switch the default database derby of Nacos to mysql.
First start the local mysql, create the nacos_config database, and execute the nacos-mysql.sql script under the nacos_config database, as shown in the following figure:
After successful execution, view the created data table:
(2) My Nacos is directly decompressed under the /opt path, find and modify the application.properties file under the /opt/nacos/conf path, and paste the following content directly to the end of application.properties (note thatdb.user and db.password should be modified to their own mysql username and password):
spring.datasource.platform=mysqldb.num=1db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=truedb.user=rootdb.password=123456
Third, modify the cluster configuration of Nacos
(1) Similarly, in the /opt/nacos/conf directory, find and modify the cluster.conf file, as shown below:
(2) In the /opt/nacos/bin directory, find and modify the startup.sh file. The places to be modified are shown in the following figure:
① Before modification:
After modification:
② Before modification:
After modification:
After the modification is completed, you can use the following command in the /opt/nacos/bin path to start the nacos node corresponding to the port number:
Fourth, configure Nginx to achieve load balancing
(1) Find and modify the nginx.conf file under the /usr/local/nginx/conf path. The places that need to be modified are shown in the following figure (for the convenience of demonstration, the nginx cluster will not be built here, only theAn nginx is used as an example to illustrate):
V. Test effect
(1) Start nginx first, and then start the nacos nodes of 3333, 4444, and 5555 in turn
(2) Close the linux local firewall or open the corresponding port number that needs to be accessed on linux
(3) For example, my linux ip is 192.168.1.103, so I can successfully access the nacos interface by accessing 192.168.1.103:1111/nacos on Windows (here is 1111 because it was just exposed in the nginx configuration fileThe port number is 1111).
(4) Create new configuration information in the nacos interface:
(5) You can view the newly created configuration information in mysql of linux:
(6) So far, the Nacos cluster + MySQL centralized storage + Nginx load balancing has been successfully built.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- numpy.random使用文档
- Wireshark packet capture and common filtering methods
- Mina's long and short connections
- BIO, NIO, AIO practical study notes (easy to understand theory)
- The hook of the operation of the selenium module
- NB-IOT智能云家具项目系列实站
- Browser Storage for H5
- 教您简单几步实现工业树莓派正确安装RS232转USB驱动
- 单片机期末复习大题
- el-progress实现进度条颜色不同
猜你喜欢
VRRP overview and experiment
Cocos Creator Mini Game Case "Stick Soldier"
From "dual card dual standby" to "dual communication", vivo took the lead in promoting the implementation of the DSDA architecture
The cocos interview answers you are looking for are all here!
GetEnumerator method and MoveNext and Reset methods in Unity
获取预训练模型的网络输入尺寸
numpy.random使用文档
深入分析若依数据权限@datascope (注解+AOP+动态sql拼接) 【循序渐进,附分析过程】
BIO, NIO, AIO practical study notes (easy to understand theory)
DevOps - Understanding Learning
随机推荐
The method of using ROS1 bag under ROS2
Nacos集群的搭建过程详解
Difference between link and @improt
BIO, NIO, AIO practical study notes (easy to understand theory)
DisabledDate date picker datePicker
【FAQ】CCAPI Compatible EOS Camera List (Updated in August 2022)
selenium学习
el-progress implements different colors of the progress bar
link 和@improt的区别
干货!教您使用工业树莓派结合CODESYS配置EtherCAT主站
Xiaodu Xiaodu is here!
错误记录集锦(遇到则记下)
By solving these three problems, the operation and maintenance efficiency will exceed 90% of the hospital
Wireshark packet capture and common filtering methods
浏览器存储WebStorage
scikit-image图像处理笔记
disabledDate 日期选择器 datePicker
Billions of IT operations in the market, the product by strength to speak
LeetCode刷题记录(2)
DevOps - Understanding Learning