xtrabackup: Creating suspend file '/data/2016-11-14_15-08-34/xtrabackup_log_copied' with pid '5883'
xtrabackup: Transaction log of lsn (130772830819) to (130775124431) was copied.
161114 15:10:05 innobackupex: All tables unlocked
innobackupex: Backup created in directory '/data/2016-11-14_15-08-34'
innobackupex: MySQL binlog position: filename 'mysql-bin.000003', position 2848177
161114 15:10:05 innobackupex: Connection to database server closed
161114 15:10:05 innobackupex: completed OK!
4.执行数据库事物一致性
innobackupex --apply-log /data/2016-11-14_15-08-34/
[notice (again)]
If you use binary log and don't use any hack of group commit,
the binary log position seems to be:
InnoDB: Last MySQL binlog file position 0 2848177, file name /data/binlog/mysql-bin.000003
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
161114 15:12:20 InnoDB: Starting shutdown...
161114 15:12:24 InnoDB: Shutdown completed; log sequence number 130775124492
161114 15:12:24 innobackupex: completed OK!
将数据拷贝到要恢复的服务器上:
scp -r /data/2016-11-11_16-03-44 x.x.x.x:/data
5.从服务器上的操作:
停用数据库服务
service mysql stop
删除原来的文件,并用备份的替换
# rm -f /var/lib/mysql/ibdata1
# rm -f /var/lib/mysql/ib_logfile0
# rm -f /var/lib/mysql/ib_logfile1
mv /data/2016-11-11_16-03-44/ibdata1 ib_logfile0 ib_logfile1 zabbix /var/lib/mysql/
chown -R mysql.mysql /var/lib/mysql/
5.从数据库能正常访问后,配置主从
在主服务器上建立同步帐号
mysql> GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repluser'@'10.19.110.36' IDENTIFIED BY 'replpass';
mysql> FLUSH PRIVILEGES;
MariaDB [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 10829376 | zabbix | mysql |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
从服务器
mysql> CHANGE MASTER TO MASTER_HOST='10.19.50.236',MASTER_USER='repluser',MASTER_PASSWORD='replpass',MASTER_LOG_FILE='mysql-bin.000003',MASTER_LOG_POS=10829376;
MariaDB [zabbix]> start slave;
出现如下信息,说明主从同步配置成功
MariaDB [zabbix]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.19.50.236
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 11515844
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 316264
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table: zabbix.%
Replicate_Wild_Ignore_Table: mysql.%
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 11515844
Relay_Log_Space: 316552
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
至此���主从同步已配置完成,别忘记了添加主从同步的监控。
更多XtraBackup相关教程见以下内容:
MySQL管理之使用XtraBackup进行热备