Using Innobackupex to build MySQL master-slave architecture from libraries
The existing schema is a master-one from the version of Mysql5.6.37. Implementation requirements are: use from the library, build a second from the library, version 5.7.21
1. Backup from library 1
[Email protected] ~]./innobackupex--user=root--password= "xxxxxx"--slave-info--safe-slave-backup--parallel=3/ data/backup/
#复制my. cnf files to new slave libraries
[[Email protected] ~] $SCP/etc/my.cnf 192.168.1.23:/data/backup
2. Master Library grant copy account from library 2
[Email protected]> grant Replication Slave,replication Client on * * to [e-mail protected] ' 192.168.1.23 ' identified by ' Repl ';
3, from the Library 2: to restore
[Email protected] ~]$./innobackupex--user=root--password= "xxxxxx"--apply-log--use-memory=2g/data/backup/ 2018-08-10_17-29-01
[[Email protected] ~] $MV/data/backup/2018-08-10_17-29-01/data/mysql_3306
4, prepare from the Library 2 configuration file my.cnf, modify the corresponding parameters as necessary, here the changes are as follows,
Skip-slave-start
DataDir =/data/mysql_3306
Port = 3306
server_id = 330623
Socket =/data/mysql_3306/mysql.sock
Pid-file=/data/mysql_3306/mysql3307.pid
Log_error=/data/mysql_3306/mysql_error.log
5. Start from library 2
# Chown-r Mysql:mysql/data/backup
# Mysqld_safe--DEFAULTS-FILE=/ETC/MY.CNF &
6. When running MySQL, prompt table ' performance_schema.session_variables ' doesn ' t exist
./mysql_upgrade-hlocalhost-u root-p--force-p3306 Sock=/data/mysql_3306/mysql.sock
Restart database
7. Change Master
mysql> system More/log/recover/xtrabackup_slave_info
Change MASTER to master_log_file= ' mysql-bin.000658 ', master_log_pos=925384099
Mysql> Change MASTER to
Master_host= ' 192.168.1.21 ',
Master_user= ' Repl ',
Master_password= ' Repl ',
master_port=3306,
Master_log_file= ' mysql-bin.000658 ',
master_log_pos=925384099;
Query OK, 0 rows affected, 2 warnings (0.31 sec)
mysql> start slave;
In the 2,start from library slave times: Error:
ERROR 1794 (HY000): Slave is isn't configured or failed to initialize properly. You must at least set--server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
After analysis, you need:
Delete 5 tables and re-import the script
Use MySQL
drop table Slave_master_info;
drop table Slave_relay_log_info;
drop table Slave_worker_info;
drop table innodb_index_stats;
drop table innodb_table_stats;
Check table data, empty table, rebuild table
Source/backup/mysql_system_tables.sql
(2) Restart the database
mysql> start slave;
Mysql> show Slave status\g;
Using Innobackupex to build MySQL master-slave architecture from libraries