MySQL master-slave replication technology Detailed

Source: Internet
Author: User

M-s
Primary server: Master1
The first step: Open the Bin-log log, set as follows:
Vim/etc/my.cnf
Log_bin
Server-id=1
Gtid_mode=on
Enforce_gtid_consistency=1
Step two: Access to the database authorized users
Mysql-uroot-p ' Password '
Grant Replication Slave,replication Client No .To ' rep ' @ ' domain name ' identified by ' password ';
Flush privileges;
To see if the slave status is normal:
show slave status\;
Step Three: Copy
Cd
Mysqldump-uroot-p ' password ' \
-A \
--single-transaction \
--master-data=2 \
--flush-logs \

./ date +%F -all.sql
SCP./-all.sql domain name:/root
From server: Master2
First step: Reply to previous data
Mysql-uroot-p ' Password '
Set sql_log_bin=0;
source/root/
All.sql;
Step two: Set up the master server
Change Master to
Master_host= ' Master1 ',
Master_user= ' rep ',
master_password= ' Password ',
Master_auto_position=1;
Note: If the error is set, this can be handled ———— >> stop slave; reset slave; OK after can be new in configuration again, good start slave;
Step three: Start slave;
Start slave;
View status
show slave status\g;

Note that this is followed by an upgrade of the previous experiment:
If you are making m-m, just set up the server configuration on the master server above
Mysql-uroot-p ' Password '
Change Master to
Master_host= ' Master2 ',
Master_user= ' rep ',
master_password= ' Password ',
Master_auto_position=1;
Start slave;
Start slave;
View status
show slave status\g;

Continue to the above experimental environment and then finish:
first go to one of the primary servers to back up a metadata, intact through the SCP is copied to the other two from the server, and then do the following from the server:
First step: Turn off SELinux shutdown FIREWALLD
Step Two: Set/etc/my.cnf add
server-id=3
Gtid_mode=on
Enforce_gtid_consistency=1
Master_info_ Repository=table
Relay_log_info_repository=table
Step three: Restart mysqld
s-s
Log in to MySQL
The first thing to do is Restore data sent from the primary server:
set sql_log_bin=0;
The path and name of the file to be restored after source,
OK, then configure its slave:
Change master to
master_host= ' master1 ' (this writes the domain name of the primary server)
Master_ User= ' rep ' (write the user name authorized on the primary server)
Master_password= ' 123 ' (here write the password authorized on the primary server)
Master_auto_position=1 for channel ' Master1 ' (the name here can be customized);
OK, if you have more than one primary server to do it once:
Change master to
master_host= ' Master2 ' (write the domain name of the primary server)
Master_user = ' Rep ' (write the user name authorized on the primary server)
Master_password= ' 123 ' (write the password authorized on the primary server)
Master_auto_position=1 for channel ' Master1 ' ( The name here can be customized);

The FAQ for this technique has the following three points:
/etc/selinux/config didn't turn selinux off.
Binary file not open in/ETC/MY.CNF
The FIREWALLD didn't turn off.
If the other machine is cloned, it is the same UUID problem, just to
Change its UUID to be different from other machines in the/VAR/LIB/MYSQL/AUTO.CNF.

MySQL master-slave replication technology Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.