need:
Build a new slave library, and only copy and filter one of the database workflows in the source database to the new instance.
One operation step
1.1 Create a new database instance on the target side
slightly
1.2 Make a backup at the source
/home/urman-agent/bin/xtrabackup --defaults-file=/data/mysql/etc/13314/my.cnf --target-dir=workflow_bak_0514 --user=root --password=密码 --socket=/data/mysql/data/13314/mysqld.sock --databases=workflow --backup
1.3 Copy the backup file to the target
scp -r workflow_bak_0514 target ip :/data/mysql/data/13320_temp/
1.4 Recovery
1.4.1 prepare
#Prepare on the target side and apply redo log
/home/urman-agent/bin/xtrabackup --prepare --export --target-dir=/data/mysql/data/13320_temp/workflow_bak_0514
1.4.2 Generate cfg file
/home/urman-agent/bin/xtrabackup --export --target-dir=/data/mysql/data/13320_temp/workflow_bak_0514
In this way, you can see the cfg file in the workflow directory.
1.4.3 Remote backup source database table structure (empty table)
mysqldump -h source database ip -P source ip -u root -p --single-transaction --databases workflow --set-gtid-purged=off - d > /opt/233_13314_kb.bak
1.4.4 Import an empty table on the target side
mysql -u root -p < /opt/233_13314_kb.bak
1.4.5 Drop tablespace
# generate sql
select concat('alter table ',table_name,' discard tablespace;') from information_schema.`TABLES` where table_schema='workflow'
#Execute the generated sql
1.4.6 Copy the ibd file and cfg file in the backup file to the target database directory
[root@mysql-235 workflow]# pwd
/data/mysql/data/13320_temp/workflow_bak_0514/workflow
cp *.cfg /data/mysql/data/13316/workflow/
cp *.ibd /data/mysql/data/13316/workflow/
1.4.7 Change file owner
cd /data/mysql/data/13316/workflow
ls -ltr Look at the owner of the existing files, and change the newly copied cfg, ibd and other files to the same owner. For example, here is:
chown -R actiontech-mysql:mysql *
1.4.8 Import tablespace
# generate sql
select concat('alter table ',table_name,' import tablespace;') from information_schema.`TABLES` where table_schema='workflow'
#Execute the generated sql
1.5 Configure master-slave replication
1.5.1 Add filter parameters
#Modify the configuration file from the library
vi my.cnf
Add to:
replicate_wild_do_table=workflow.%
#Restart the slave library to make the parameters take effect, example:
systemctl stop mysqld_13316
systemctl start mysqld_13316
1.5.2 Configuring master-slave replication
1.5.2.1 set gtid_purged
Get xtrabackup_binlog_info in the backup file
reset master;
set global gtid_purged=' The location obtained above ';
1.5.2.2 change master
change master to master_host=' master library ip ', master_port= master library port , master_user='universe_op', master_password=' password ', master_auto_position=1;
start slave;
show slave status ;
1.5.3 Manually synchronize functions, stored procedures, triggers, events, etc.
Under manual synchronization, it is best to manually synchronize on the day of cutover