MySQL master-slave configuration Innobackupex

Source: Internet
Author: User

1, Main library: Back up Database to from library 1), Backup script
mycnf=/etc/My.cnfuser=Rootpasswd=Xxxxxxxxxxxxxxxxxsocket=/data/mysql/3306/var/run/mysql.sockdest_ip=192.168.30.27Dest_user=Rootdest_dir=/data/Mysql_19backupname=mysql_ 'Date+%f_%h-%m-%s '.Tar. Gzinnobackupex--user= $user--password=$passwd--defaults-file= $mycnf--no-lock--socket= $socket--stream=Tar$dest _dir |SSH[Email protected] $dest _IP"gzip > $dest _dir/$backupname"

2), configure the Sync account on the main library

Select on mysql.* to [email protected]'localhost'123456' 
2, from the library:

1) Stop MySQL from the library and delete the data

/etc/init.d/mysqld Stoprm -rf/opt/mysql/3306/data/*

2), extract the data directory from the library:, parameter i is ignore zero

tar xvfi backup. tar -c/opt/mysql/3306/data

3) revert to the data directory from the library--apply-log

# Innobackupex--user=root--socket=/opt/data/mysql/3306/var/run/mysql.sock--defaults-file=/opt /data/mysql/3306/var/my.cnf  --apply-log/opt/data/mysql/3306/--user=root-- apply-log/opt/data/mysql/3306/datachown -R mysql:mysql/opt/data/mysql      permissions configuration

4) View the position of the backup

Cat xtrabackup_binlog_infomysql-bin. 003786        275137157

5) Start MySQL from library

Nohup/usr/local/mysql/bin/mysqld_safe--defaults-file=/opt/data/mysql/33062>& 1 &

6) Configure from library

/usr/local/mysql/bin/mysql--socket=/opt/data/mysql/3306/var/run/mysql.sock-uroot-Pchange Master Tomaster_host='192.168.30.19', Master_user='Slaves', Master_password='Jqfvs4epazp', Master_port=3306, Master_log_file='mysql-bin.003786', Master_log_pos=275137157;
Start slave;show slave status\g

7) Fix the error./mysql/proc ' is marked as crashed and should be repaired

Mysqlcheck--repair mysql proc--socket=/opt/data/mysql/3306/var/run/mysql.sock-uroot-pstop slave; Start slave;

MySQL master-slave configuration Innobackupex

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.