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