MySQL 5.5使用Xtrabackup線上搭建複製環境
--Master IP 192.168.78.139 PORT 3306
--Slave IP 192.168.78.137 PORT 5505
--編輯Master的配置檔案
[root@localhost install]# vim /etc/my.cnf
# Log
server-id = 100
log-bin = /log/binlog/mysql-bin
--在Slave安裝好MySQL軟體,安裝流程可以參考原始碼安裝文章
http://blog.itpub.net/26506993/viewspace-2072859/
--在Master節點,使用Xtrabackup建立完整備份
關於Xtrabackup,可參考
http://blog.itpub.net/26506993/viewspace-2087734/
http://blog.itpub.net/26506993/viewspace-2088737/
[root@localhost backup]# /install/percona/percona-xtrabackup-2.4.2-Linux-x86_64/bin/innobackupex --defaults-file=/etc/my.cnf --stream=tar /tmp --user system --password 'Mysql#2015' | gzip ->
/backup/xtra/xtra_fullbackup_20160501.tar.gz
--複製備份到Slave節點
[root@localhost backup]# scp /backup/xtra/xtra_fullbackup_20160501.tar.gz root@192.168.78.137:/backup/20160501
解壓備份到資料檔案目錄
[root@localhost 5505]# tar xivfz xtra_fullbackup_20160501.tar.gz -C /mysql_data/5505
在Slave節點上面需要安裝Xtraback
--使用Xtrabackup準備資料、應用日誌,使資料檔案達到一致性的狀態
[root@localhost bin]# ./innobackupex --defaults-file=/mysql_data/cnf/my.cnf --apply-log /mysql_data/5505
.....
InnoDB: Doing recovery: scanned up to log sequence number 68405269 (0%)
InnoDB: Doing recovery: scanned up to log sequence number 68405269 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: xtrabackup: Last MySQL binlog file position 414, file name /log/binlog/mysql-bin.000012
InnoDB: Removed temporary tablespace data file: "ibtmp1"
InnoDB: Creating shared tablespace for temporary tables
InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
InnoDB: File './ibtmp1' size is now 12 MB.
InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
InnoDB: 32 non-redo rollback segment(s) are active.
InnoDB: 5.7.11 started; log sequence number 68405269
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 68405621
160430 23:51:25 completed OK!
--在Master資料庫上面建立複製專用賬戶
mysql> grant replication slave on *.* to 'repl'@'192.168.78.%' identified by 'Mysql#2015';
Query OK, 0 rows affected (0.04 sec)
--配置Slave的配置檔案
[root@localhost 5505]# vim /mysql_data/cnf/my.cnf
# Log
server-id = 200
log-bin = /mysql_log/binlog/mysql-bin
relay-log = /mysql_log/binlog/product-relay-bin
relay-log-index = /mysql_log/binlog/product-relay-index
binlog_cache_size = 32M
max_binlog_cache_size = 512M
max_binlog_size = 512M
binlog_format = MIXED
relay_log_recovery = 1
--啟動Slave節點的Mysql服務
[root@localhost bin]# /data/bin/mysqld_safe --defaults-file=/mysql_data/cnf/my.cnf &
--配置Slave節點複製環境
查詢Slave節點連線Master節點的二進位制檔案和位置
使用Xtrabackup備份時,在xtrabackup_binlog_info檔案中會儲存這部分資訊
[root@localhost 5505]# more xtrabackup_binlog_info
mysql-bin.000012 414
--在Slave節點執行CHANGE MASTER語句
mysql> change master to
-> master_host='192.168.78.139',
-> master_port=3306,
-> master_user='repl',
-> master_password='Mysql#2015',
-> master_log_file='mysql-bin.000012',
-> master_log_pos=414;
Query OK, 0 rows affected (0.13 sec)
--啟動應用執行緒
mysql> start slave;
--檢視同步狀態
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.78.141
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000013
Read_Master_Log_Pos: 341
Relay_Log_File: product-relay-bin.000003
Relay_Log_Pos: 487
Relay_Master_Log_File: mysql-bin.000013
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
--Slave IP 192.168.78.137 PORT 5505
--編輯Master的配置檔案
[root@localhost install]# vim /etc/my.cnf
# Log
server-id = 100
log-bin = /log/binlog/mysql-bin
--在Slave安裝好MySQL軟體,安裝流程可以參考原始碼安裝文章
http://blog.itpub.net/26506993/viewspace-2072859/
--在Master節點,使用Xtrabackup建立完整備份
關於Xtrabackup,可參考
http://blog.itpub.net/26506993/viewspace-2087734/
http://blog.itpub.net/26506993/viewspace-2088737/
[root@localhost backup]# /install/percona/percona-xtrabackup-2.4.2-Linux-x86_64/bin/innobackupex --defaults-file=/etc/my.cnf --stream=tar /tmp --user system --password 'Mysql#2015' | gzip ->
/backup/xtra/xtra_fullbackup_20160501.tar.gz
--複製備份到Slave節點
[root@localhost backup]# scp /backup/xtra/xtra_fullbackup_20160501.tar.gz root@192.168.78.137:/backup/20160501
解壓備份到資料檔案目錄
[root@localhost 5505]# tar xivfz xtra_fullbackup_20160501.tar.gz -C /mysql_data/5505
在Slave節點上面需要安裝Xtraback
--使用Xtrabackup準備資料、應用日誌,使資料檔案達到一致性的狀態
[root@localhost bin]# ./innobackupex --defaults-file=/mysql_data/cnf/my.cnf --apply-log /mysql_data/5505
.....
InnoDB: Doing recovery: scanned up to log sequence number 68405269 (0%)
InnoDB: Doing recovery: scanned up to log sequence number 68405269 (0%)
InnoDB: Database was not shutdown normally!
InnoDB: Starting crash recovery.
InnoDB: xtrabackup: Last MySQL binlog file position 414, file name /log/binlog/mysql-bin.000012
InnoDB: Removed temporary tablespace data file: "ibtmp1"
InnoDB: Creating shared tablespace for temporary tables
InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
InnoDB: File './ibtmp1' size is now 12 MB.
InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
InnoDB: 32 non-redo rollback segment(s) are active.
InnoDB: 5.7.11 started; log sequence number 68405269
xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 68405621
160430 23:51:25 completed OK!
--在Master資料庫上面建立複製專用賬戶
mysql> grant replication slave on *.* to 'repl'@'192.168.78.%' identified by 'Mysql#2015';
Query OK, 0 rows affected (0.04 sec)
--配置Slave的配置檔案
[root@localhost 5505]# vim /mysql_data/cnf/my.cnf
# Log
server-id = 200
log-bin = /mysql_log/binlog/mysql-bin
relay-log = /mysql_log/binlog/product-relay-bin
relay-log-index = /mysql_log/binlog/product-relay-index
binlog_cache_size = 32M
max_binlog_cache_size = 512M
max_binlog_size = 512M
binlog_format = MIXED
relay_log_recovery = 1
--啟動Slave節點的Mysql服務
[root@localhost bin]# /data/bin/mysqld_safe --defaults-file=/mysql_data/cnf/my.cnf &
--配置Slave節點複製環境
查詢Slave節點連線Master節點的二進位制檔案和位置
使用Xtrabackup備份時,在xtrabackup_binlog_info檔案中會儲存這部分資訊
[root@localhost 5505]# more xtrabackup_binlog_info
mysql-bin.000012 414
--在Slave節點執行CHANGE MASTER語句
mysql> change master to
-> master_host='192.168.78.139',
-> master_port=3306,
-> master_user='repl',
-> master_password='Mysql#2015',
-> master_log_file='mysql-bin.000012',
-> master_log_pos=414;
Query OK, 0 rows affected (0.13 sec)
--啟動應用執行緒
mysql> start slave;
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.78.141
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000013
Read_Master_Log_Pos: 341
Relay_Log_File: product-relay-bin.000003
Relay_Log_Pos: 487
Relay_Master_Log_File: mysql-bin.000013
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2091601/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL Xtrabackup真實生產環境搭建主從複製全過程MySql
- MySQL 5.5 複製搭建流程MySql
- MySQL 5.7 使用GTID方式搭建複製環境MySql
- 使用XtraBackup搭建mysql主從複製的操作步驟MySql
- MySQL 5.5 主主複製搭建流程MySql
- MySQL搭建帶過濾的複製環境MySql
- 生產環境搭建MySQL複製的教程MySql
- MySQL 複製全解析 Part 11 使用xtrabackup建立MySQL複製MySql
- 生產環境中MySQL複製的搭建KPMySql
- 線上環境MySQL5.5升級至5.6MySql
- MySQL 5.5 常用的複製環境管理命令MySql
- 快速搭建streams表級複製環境
- 使用MySQL8.0 clone技術線上搭建主從複製MySql
- redhat 5.5 配置 mysql AB複製RedhatMySql
- GoldenGate簡單複製環境的搭建Go
- 利用percona-xtrabackup快速搭建MySQL資料庫主從複製MySql資料庫
- Redis多例項及主從複製環境搭建Redis
- MySQL 5.5級聯複製配置流程MySql
- mysql5.5半同步複製探究MySql
- Windows 環境下,MySQL 的主從複製和主主複製WindowsMySql
- windows環境下,Mysql的主從複製和主主複製WindowsMySql
- 配置mysql5.5主從複製、半同步複製、主主複製MySql
- mongodb複製集(replica sets)+分片(sharding)環境搭建MongoDB
- 搭建oracle 11.2.0.4環境下的goldengate複製OracleGo
- 用RMAN複製 搭建 物理 Data Gurad 環境
- mysql5.5中的半同步複製MySql
- MySQL 如何快速複製使用者許可權到其他環境MySql
- 手把手教你,如何在windows系統搭建mysql主從複製的環境WindowsMySql
- 詳解CentOS5.5 下搭建 PHP 環境(最佳的LAMP環境)CentOSPHPLAMP
- Innobackupex實現mysql線上搭建master-slave主從複製MySqlAST
- MAC使用brew搭建nginx、php、mysql環境MacNginxPHPMySql
- MySQL5.5半同步複製實現原理MySql
- mysql主從複製搭建MySql
- 企業環境下MySQL5.5調優MySql
- MySQL 複製全解析 Part 1 實驗環境介紹MySql
- 處理MySQL複製環境Slave故障的一個案例MySql
- CentOS7.8 環境搭建 Redis 主從複製和哨兵模式CentOSRedis模式
- MySQL 5.5 Semi-sync 半同步複製測試MySql