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
1 / Copy the web project files directly to the we...
When there is a lot of data to be displayed, the ...
1. Export the database using the mysqldump comman...
1. Upper and lower list tags: <dl>..</dl...
1. ip_hash: ip_hash uses a source address hash al...
MySQL database basic syntax DDL Operations Create...
Vue routing this.route.push jump page does not re...
Table of contents Preface 1. Local port forwardin...
Color is one of the most important elements for a...
Solution to MySql service disappearance for unkno...
1. Shut down MySQL [root@localhost /]# service my...
Preface According to the project needs, Vue-touch...
Starting from Elasticsearch 6.8, free users are a...
Table of contents Preface vue-cli 2.0 version vue...
MySQL is easy to install, fast and has rich funct...