The MySQL version targeted this time is 5.7. First, install MySQL on server A and server B respectively. You can install it through yum or download it through wget and compile and install it directly. There are many ways to install it, but you must ensure that it is successful. 1. Modify the my.cnf file of server Avim /etc/my.cnf And add the following content: server-id=1 auto_increment_offset=1 auto_increment_increment=2 gtid_mode=on enforce_gtid_consistency=on log-bin=mysql-bin 2. Modify the my.cnf file of server Bvim /etc/my.cnf And add the following content: server-id=2 auto_increment_offset=1 auto_increment_increment=2 gtid_mode=on enforce_gtid_consistency=on log-bin=mysql-bin 3. Create a replication user on MySQL server A for access by server Bcreate user B@'IP' identified by 'password'; grant replication slave on *.* to B@'server IP'; 4. Create a replication user for access from server A in MySQL on server Bcreate user A@'IP' identified by 'password'; grant replication slave on *.* to A@'password'; 5. Execute the master-slave configuration on MySQL on server B, and make A the master and B the slavechange master to master_host='IP', master_user='B', master_password='?Tp&clsr38i', master_port=3306, master_auto_position=1; start slave; show slave status; 6. Execute the master-slave configuration on MySQL on server A, and make B the master and A the slavechange master to master_host='IP', master_user='A', master_password='?Tp&clsr38i', master_port=3306, master_auto_position=1; start slave; show slave status; Then test, create a new database and corresponding data table in MySQL on server A, and MySQL on server B will be synchronized to ensure that the database and data table are consistent. 7. Nginx Configuration Nginx configures the MySQL cluster access URL to ensure that microservice applications connect to the same URL. stream { upstream mysql_proxy{ hash $remote_addr consistent; server A server IP:3306 weight=1 max_fails=3 fail_timeout=10s; server B server IP:3306 weight=1 max_fails=3 fail_timeout=10s; } server { listen 3306; # Database server listening port proxy_connect_timeout 10s; proxy_timeout 300s; proxy_pass mysql_proxy; } } Special Note:It is not recommended to set the MySQL port to 3306 or 3389 in a production environment. The above are the details of the steps for configuring a MySQL 5.7 cluster. For more information about MySQL cluster configuration, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Application of Beautiful Style Sheets in XHTML+CSS Web Page Creation
>>: Implementation of vertical centering with unknown height in CSS
Table of contents 1. Comments on MySQL primary ke...
This article introduces an example of using HTML+...
View the dependent libraries of so or executable ...
This article shares the specific code for the WeC...
one. Overview of IE8 Compatibility View <br /&...
Table of contents need Core Idea Two ways to impl...
1. Grid layout (grid): It divides the web page in...
The machines in our LAN can access the external n...
Table of contents 【Common commands】 [Summary of c...
There are many tags in XHTML, but only a few are ...
1: Download MySql Official website download addre...
1. Install basic components First, execute the yu...
Question: In index.html, iframe introduces son.htm...
Install the required environment 1. gcc installat...
Add secure_file_priv = ' '; then run cmd ...