Xtrabackup how to build MySQL master-slave environment

Source: Internet
Author: User

Environment: HE3 Main Library, HE1 from library
he1:192.168.1.248
he3:192.168.1.250
Add the following parameters from the library my.cnf and restart the database:
Read_only=1
Log_slave_updates=1 (recommended to open, from the library record Binlog)
Primary Library Authorized Backup account
Mysql>grant select,reload,show databases,super,locktables,replication client,show VIEW,EVENT,FILE on * * to ' backup ' @ ' localhost ' identified by ' MANAGER ';
mysql> flush Privileges;
Master Repository Full Library backup
Innobackupex--no-timestamp--defaults-file=/etc/my.cnf--user=backup--password=manager--host=192.168.1.250--port =3306/databackup/xtrabackup/all-20160328-bak
Copy the main library backup file to the library and unzip to view POS number
[Email protected]_18-25-12]# cat Xtrabackup_binlog_info
Mysql-bin.000007 317
The Binlog log in the backup set has reached the mysql-bin.000007 offset position to 317.
Restore from the library to the same as the main library's full-Library backup data
[Email protected]]# innobackupex--user=backup--host=127.0.0.1--password=manager--defaults-file=/etc/my.cnf-- Apply-log/data/2016-04-03_18-25-12
[[Email protected]]# MV 2016-04-03_18-25-12/mysql
[[Email protected]]# chown-r mysql:mysql MySQL
[[email protected] bin]#/etc/init.d/mysqld start
Main Library:
Establish a master-slave copy of the user name and password, specify which IP address users can access the main library with this user
mysql> Grant Replication client,replication slave on * * to ' mysync ' @ ' 192.168.1.248 ' identifiedby ' MANAGER ';
Mysql>flush privileges;
From library:
The IP address of the master library is read from the library configuration, the copied user name and password, which Binlog file from the main library starts reading, what is the offset?
mysql> change MASTER to master_host= ' 192.168.1.250 ', master_user= ' Mysync ', master_password= ' MANAGER ', master_port= 3306,master_log_file= ' mysql-bin.000007 ', master_log_pos=317;
Turn on the copy switch from the library
mysql> start slave;
Query OK, 0 rowsaffected (0.30 sec)
Mysql>show slave status\g;
At this point, the asynchronous master-slave replication is built successfully.

Xtrabackup how to build MySQL master-slave environment

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.