-
Notifications
You must be signed in to change notification settings - Fork 0
/
xtrabackup.log
90 lines (67 loc) · 3.93 KB
/
xtrabackup.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
http://blog.csdn.net/yangzhawen/article/details/50457922
yum -y install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr bison libtool zlib-devel libgcrypt-devel libcurl-devel crypt* libgcrypt* python-sphinx openssl imake libxml2-devel expat-devel ncurses5-devel ncurses-devle vim-common libgpg-error-devel libidn-devel perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL
安装boost
tar -zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 /usr/local/boost_1_59_0
mkdir -p /usr/local/xtrabackup
tar xvzf percona-xtrabackup-2.4.4.tar.gz -C /usr/local/xtrabackup/ && cd /usr/local/xtrabackup/percona-xtrabackup-2.4.4
chown -R mysql:mysql /usr/local/xtrabackup
cd /usr/local/xtrabackup/percona-xtrabackup-2.4.4/
cmake -DBUILD_CONFIG=xtrabackup_release -DWITH_MAN_PAGES=OFF -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost_1_59_0/
安装libev
gunzip libev-4.22.tar.gz
tar xf libev-4.22.tar
sh autogen.sh
./configure && make && make install
make -j8
make install
ln -sf /usr/local/xtrabackup/bin/innobackupex /usr/bin/
ln -sf /usr/local/xtrabackup/bin/xtrabackup /usr/bin/
#备份
innobackupex --defaults-file=/usr/local/percona-server-5.6.32-78.1/etc/my4306.cnf --user=root --password=rootpass --parallel=4 /tmp/backup
#保持事务一致性
#--apply-log选项的命令是准备在一个备份上启动mysql服务
innobackupex --/usr/local/percona-server-5.6.32-78.1/etc/my4306.cnf --user=root --password=rootpass --apply-log /tmp/backup/2016-10-25_15-31-40
#传输
scp -r /tmp/backup/2016-10-25_13-54-51 10.10.16.24:/tmp/backup/
#恢复
#--copy-back 选项的命令从备份目录拷贝数据,索引,日志到my.cnf文件里规定的初始位置
innobackupex --defaults-file=/usr/local/percona-server-5.6.32-78.1/etc/my5306.cnf --user=root --password=rootpass --copy-back /tmp/backup/2016-10-25_15-31-40
#还原权限
chown -R mysql:mysql /usr/local/percona-server-5.6.32-78.1/data5306
/usr/local/percona-server-5.6.32-78.1/bin/mysqld_safe --defaults-file=/usr/local/percona-server-5.6.32-78.1/etc/my5306.cnf --user=mysql &
##scripts/mysql_install_db --basedir=/usr/local/percona-server-5.6.32-78.1 --datadir=/usr/local/percona-server-5.6.32-78.1/data5306 --no-defaults --skip-name-resolve --user=mysql
#主库授权同步帐号
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
GRANT REPLICATION SLAVE ON *.* TO 'slave_passport'@'10.10.16.24' IDENTIFIED BY 'slave_passport';
FLUSH PRIVILEGES;
#从库开启同步
cat /tmp/backup/2015-08-05_16-08-14/xtrabackup_binlog_info
mysql-bin.002599 804497686
CHANGE MASTER TO
MASTER_HOST='10.0.56.87',
MASTER_USER='replicater',
MASTER_PASSWORD='rootpass',
MASTER_PORT=4306,
MASTER_LOG_FILE='mysql-bin.000011',
MASTER_LOG_POS=971038;
#开启主从同步
start slave;
#查看从库状态
show slave status\ G
#从库的检查参数
Slave_IO_Running=Yes
Slave_SQL_Running=Yes
#主库的检查参数
show master status \G
+------------------+-----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.002600 | 454769337 | | |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)
show processlist;
Master has sent all binlog to slave; waiting for binlog to be updated
远程备份
innobackupex --defaults-file=/usr/local/percona-server-5.6.32-78.1/etc/my4306.cnf --slave-info --user=root --password=rootpass --stream=tar /usr/local/percona-server-5.6.32-78.1/data 2> /var/log/xtra.log | pigz | ssh [email protected] "cat - > /tmp/mysql_backup.tar.gz"
nohup /home/mysql/scripts/percona-xtrabackup-2.1/bin/innobackupex --ibbackup="+ibback_path+" --defaults-file="+defaults_file_m+" --slave-info --user=backup --password="+conf_info['backup']+" --stream=tar "+datadir_s+" 2> /var/log/"+c_date+".log | gzip -9 | ssh root@"+slave_ip+" cat \">\" "+backup_dir+"/xtr.tar.gz 2>&1 >/dev/null &