当前位置:网站首页>Nacos cluster construction and MySQL persistence configuration
Nacos cluster construction and MySQL persistence configuration
2022-04-23 18:38:00 【Hua Weiyun】
@toc
This article is very important , Because the production environment is used for high availability nacos colony , For single node service registration, you can follow the official website configuration , But clustering is a must .
1、Nacos Cluster deployment architecture
Most production environments use cluster mode to ensure high availability .
nacos The cluster architecture is as follows :
nacos Three deployment modes are supported :
- Click mode : For testing and click trial .
- Cluster pattern : For the production environment , Ensure high availability .
- Multi cluster mode : For multi data center scenarios .
Therefore, when open source, it is recommended that users put all service lists into one vip below , Then hang it under a domain name
http://ip1:port/openAPI Direct connection ip Pattern , The hook of the machine needs to be modified ip Can be used .
http://SLB:port/openAPI mount SLB Pattern ( Intranet SLB, Do not expose to the public network , To avoid safety risks ), Direct connection SLB that will do , Hang down server real ip, Poor readability .
http://nacos.com:port/openAPI domain name + SLB Pattern ( Intranet SLB, Do not expose to the public network , To avoid safety risks ), Good readability , And change ip convenient , Recommended modeMake complaints about it here. , Alibaba's documents are not very complete , Maybe there are too many big guys in Ali , Think we can understand the picture above , If you see the above architecture diagram, you can immediately translate it into the following , That means you really understand .
The above architecture diagram does not specify SLB What is it? , In fact, the above architecture diagram is translated into the following one. Does it look familiar .
2、Nacos Persistent configuration explanation
because Nacos The default is embedded database derby, This is not convenient for us to use tools to detect in real time , So here we use mysql Persistence nacos Configuration of .
derby Switch to mysql Steps for :
-
Go first conf Find... Under the folder nacos-mysql.sql This script , Then execute the script in your own database , The effect after execution is as follows :
-
Go ahead and revise conf Under the folder application.properties file , Add database configuration file :
Examples are as follows :
3、Linux edition Nacos+MySQL Production environment configuration
3.1 Cluster planning
Prepare three nacos node
- nacos01 node :192.168.159.33:3333
- nacos02 node :192.168.159.33:4444
- nacos03 node :192.168.159.33:5555
Prepare one nginx
Prepare one mysql:192.168.159.33:3306
namely 1 individual nginx+3 individual nacos node +1 individual mysql Low configuration cluster .
And here for simplicity ,nginx and mysql No cluster is used , The effect is the same .
Yes, of course , If you think it is unreasonable for all three nodes to be built in the same virtual machine , Then you can also start three virtual machines , Then revise ip that will do .
3.2 nacos Of linux Version installed
Download address :https://github.com/alibaba/nacos/releases/tag/1.4.1
What I use here is 1.4.1 edition ,
After downloading, you can decompress it directly .
Directory as follows :
3.3 linux On the server mysql Database configuration
take conf Under the folder nacos-mysql.sql Script in mysql In the implementation of .
View the results after execution
3.4 Copy three copies nacos file
Here we use nacos01、nacos02、nacos03, Just for testing , Please configure on different nodes in the production environment .
3.5 modify application.properties
modify /conf Under the folder application.properties file , increase mysql Persistent configuration .
nacos01、nacos02、nacos03 The following modifications need to be made in :
spring.datasource.platform=mysqldb.num=1db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?useUnicode=true&characterEncoding=utf-8&useSSL=falsedb.user=rootdb.password=123456
3.6 modify cluster.conf
stay nacos01 Modify in the folder /conf Under the folder cluster.conf
There is no initial , Only one cluster.conf.example,
We carry out orders cp cluster.conf.example cluster.conf
that will do .
And then execute vim cluster.conf
Command to edit the file
Add the following configuration :
192.168.159.33:3333192.168.159.33:4444192.168.159.33:5555
Now only nacos01, We copy the file directly to nacos02 and nacos03 In the corresponding folder .
Execute the following command :
cp cluster.conf /usr/local/nacos02/conf/ cp cluster.conf /usr/local/nacos03/conf/
3.7 Modify the port number of three nodes
Modify the of three nodes respectively /conf Under the folder application.properties file .
take nacos01、nacos02、nacos03 The port numbers of are modified to 3333、4444、5555
nacos01:
vim /usr/local/nacos01/conf/application.properties
nacos02:
vim /usr/local/nacos02/conf/application.properties
nacos03:
vim /usr/local/nacos03/conf/application.properties
3.8 Start three nacos node
Enter the... Of the three nodes respectively /bin Execute the following command under the file
startup.sh
You can see from the picture above , All in cluster mode (cluster) Starting up .
Visit the console of three nodes to check whether it is successful :
http://192.168.159.33:3333/nacos
http://192.168.159.33:4444/nacos
http://192.168.159.33:5555/nacos
3.9 Use nginx Load balancing
modify nginx Configuration file for
vim nginx.conf
Add the following configuration :
Configuration here means to make nginx monitor 1111 port ( You let it monitor 80 Ports are also OK )
start-up nginx
cd sbin./nginx -c /usr/local/nginx/conf/nginx.conf
3.10 Cluster testing
End here ,1 individual nginx+3 individual nacos Registry Center +1 individual mysql The configuration of is completed .
test Nginx visit nacos:http://192.168.159.33:1111/nacos
Create a new configuration test :
Check whether all three nodes have this configuration ,
nacos01:
nacos02:
nacos03:
see linux In the server mysql Whether there is one more record
3.11 Microservice registration test
Microservices cloudalibaba-provider-payment9002 Start registration nacos colony
modify application.yml Of documents nacos Registered address: :192.168.159.33:1111, Be careful , This is a nginx Listen to the address , After load balancing, it is handed over to 192.1168.159.33:3333、192.1168.159.33:4444、192.1168.159.33:5555 One of the three nodes handles .
After starting the micro service , Go to nacos Console to see if the registration is successful .
Here we are , The cluster construction and persistence configuration are all introduced , Here you can put nginx and mysql It is also built with clusters , Realize the real high availability cluster .
== Be careful : Here, if you simulate with a single virtual machine , Memory should be in 3G That's all .==
版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231836021874.html
边栏推荐
- 14 py games source code share the second bullet
- Introduction to quantexa CDI syneo platform
- WIN1 remote "this may be due to credssp encryption Oracle correction" solution
- ctfshow-web361(SSTI)
- Tangle
- 【ACM】376. Swing sequence
- Machine learning theory (8): model integration ensemble learning
- Custom prompt box MessageBox in QT
- Setting up keil environment of GD single chip microcomputer
- Halo open source project learning (VII): caching mechanism
猜你喜欢
WIN1 remote "this may be due to credssp encryption Oracle correction" solution
ctfshow-web362(SSTI)
Halo open source project learning (VII): caching mechanism
On iptables
机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
Druid SQL和Security在美团点评的实践
【ACM】70. climb stairs
ctfshow-web362(SSTI)
Cygwin64 right click to add menu, and open cygwin64 here
随机推荐
ESP32 LVGL8. 1 - event (event 17)
Ionic instruction set order from creation to packaging
With the use of qchart, the final UI interface can be realized. The control of qweight can be added and promoted to a user-defined class. Only the class needs to be promoted to realize the coordinate
Chondroitin sulfate in vitreous
os_authent_prefix
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
【ACM】70. climb stairs
Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
STM32 learning record 0008 - GPIO things 1
Quantexa CDI(场景决策智能)Syneo平台介绍
In shell programming, the shell file with relative path is referenced
硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)
Can filter
Configure iptables
数据库上机实验四(数据完整性与存储过程)
QT tablewidget insert qcombobox drop-down box
Daily CISSP certification common mistakes (April 14, 2022)
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
Daily CISSP certification common mistakes (April 13, 2022)
Promote QT default control to custom control