本文主要是介绍centos7 xtrabackup mysql(8)压缩 全量备份 还原(4),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
centos7 xtrabackup mysql(8)压缩 全量备份 还原(4)
查看版本:
xtrabackup --version
qpress --help
主机端
mysql -u root -p
1234aA~1
use company_pro;
insert into employee(name) value (‘20240823_1401’);
sudo mkdir -p /data/20240823
sudo chmod -R 777 /data/20240823
sudo xtrabackup --backup --compress --compress-threads=2 --target-dir=/data/20240823/full_backup --user=root --password=1234aA~1 --parallel=2
log
[jack@localhost data]$ sudo xtrabackup --backup --compress --compress-threads=2 --target-dir=/data/20240823/full_backup --user=root --password=1234aA~1 --parallel=2
xtrabackup: recognized server arguments: --datadir=/opt/datadir/mysql/ --server-id=40 --log_bin=mysql-bin --parallel=2
xtrabackup: recognized client arguments: --socket=/opt/datadir/mysql/mysql.sock --backup=1 --compress --compress-threads=2 --target-dir=/data/20240823/full_backup --user=root --password=*
240823 14:08:48 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/opt/datadir/mysql/mysql.sock' as 'root' (using password: YES).
240823 14:08:48 version_check Connected to MySQL server
240823 14:08:48 version_check Executing a version check against the server...
240823 14:08:48 version_check Done.
240823 14:08:48 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /opt/datadir/mysql/mysql.sock
Using server version 5.7.44-log
xtrabackup version 2.4.26 based on MySQL server 5.7.35 Linux (x86_64) (revision id: 19de43b)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /opt/datadir/mysql/
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = .
xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 2
xtrabackup: innodb_log_file_size = 50331648
InnoDB: Number of pools: 1
240823 14:08:48 >> log scanned up to (2822750)
xtrabackup: Generating a list of tablespaces
InnoDB: Allocated tablespace ID 2 for mysql/plugin, old maximum was 0
xtrabackup: Starting 2 threads for parallel data files transfer
240823 14:08:48 [02] Compressing ./ibdata1 to /data/20240823/full_backup/ibdata1.qp
240823 14:08:48 [01] Compressing ./mysql/plugin.ibd to /data/20240823/full_backup/mysql/plugin.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [01] Compressing ./mysql/servers.ibd to /data/20240823/full_backup/mysql/servers.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [01] Compressing ./mysql/help_topic.ibd to /data/20240823/full_backup/mysql/help_topic.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/help_category.ibd to /data/20240823/full_backup/mysql/help_category.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/help_relation.ibd to /data/20240823/full_backup/mysql/help_relation.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/help_keyword.ibd to /data/20240823/full_backup/mysql/help_keyword.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/time_zone_name.ibd to /data/20240823/full_backup/mysql/time_zone_name.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/time_zone.ibd to /data/20240823/full_backup/mysql/time_zone.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/time_zone_transition.ibd to /data/20240823/full_backup/mysql/time_zone_transition.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/time_zone_transition_type.ibd to /data/20240823/full_backup/mysql/time_zone_transition_type.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [02] ...done
240823 14:08:48 [01] Compressing ./mysql/time_zone_leap_second.ibd to /data/20240823/full_backup/mysql/time_zone_leap_second.ibd.qp
240823 14:08:48 [02] Compressing ./mysql/innodb_table_stats.ibd to /data/20240823/full_backup/mysql/innodb_table_stats.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [02] ...done
240823 14:08:48 [01] Compressing ./mysql/innodb_index_stats.ibd to /data/20240823/full_backup/mysql/innodb_index_stats.ibd.qp
240823 14:08:48 [02] Compressing ./mysql/slave_relay_log_info.ibd to /data/20240823/full_backup/mysql/slave_relay_log_info.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/slave_master_info.ibd to /data/20240823/full_backup/mysql/slave_master_info.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [01] Compressing ./mysql/slave_worker_info.ibd to /data/20240823/full_backup/mysql/slave_worker_info.ibd.qp
240823 14:08:48 [02] Compressing ./mysql/gtid_executed.ibd to /data/20240823/full_backup/mysql/gtid_executed.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./mysql/server_cost.ibd to /data/20240823/full_backup/mysql/server_cost.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [01] Compressing ./mysql/engine_cost.ibd to /data/20240823/full_backup/mysql/engine_cost.ibd.qp
240823 14:08:48 [02] Compressing ./sys/sys_config.ibd to /data/20240823/full_backup/sys/sys_config.ibd.qp
240823 14:08:48 [01] ...done
240823 14:08:48 [02] ...done
240823 14:08:48 [02] Compressing ./company_pro/employee.ibd to /data/20240823/full_backup/company_pro/employee.ibd.qp
240823 14:08:48 [01] Compressing ./company_service/customer.ibd to /data/20240823/full_backup/company_service/customer.ibd.qp
240823 14:08:48 [02] ...done
240823 14:08:48 [01] ...done
240823 14:08:49 >> log scanned up to (2822750)
240823 14:08:49 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
240823 14:08:49 Executing FLUSH TABLES WITH READ LOCK...
240823 14:08:49 Starting to backup non-InnoDB tables and files
240823 14:08:49 [01] Compressing ./mysql/db.opt to /data/20240823/full_backup/mysql/db.opt.qp
240823 14:08:49 [01] ...done240823 14:08:50 [01] Compressing ./performance_schema/status_by_host.frm to /data/20240823/full_backup/performance_schema/status_by_host.frm.qp
240823 14:08:50 [01] ...done
240823 14:08:50 [01] Compressing ./performance_schema/status_by_account.frm to /data/20240823/full_backup/performance_schema/status_by_account.frm.qp
240823 14:08:50 [01] ...done
240823 14:08:50 [01] Compressing ./performance_schema/global_status.frm to /data/20240823/full_backup/performance_schema/global_status.frm.qp
240823 14:08:50 [01] ...done
240823 14:08:50 [01] Compressing ./performance_schema/session_status.frm to /data/20240823/full_backup/performance_schema/session_status.frm.qp
240823 14:08:50 [01] ...done
240823 14:08:50 Finished backing up non-InnoDB tables and files
240823 14:08:50 [00] Compressing /data/20240823/full_backup/xtrabackup_binlog_info.qp
240823 14:08:50 [00] ...done
240823 14:08:50 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '2822741'
xtrabackup: Stopping log copying thread.
.240823 14:08:50 >> log scanned up to (2822750)240823 14:08:50 Executing UNLOCK TABLES
240823 14:08:50 All tables unlocked
240823 14:08:50 [00] Compressing ib_buffer_pool to /data/20240823/full_backup/ib_buffer_pool.qp
240823 14:08:50 [00] ...done
240823 14:08:50 Backup created in directory '/data/20240823/full_backup/'
MySQL binlog position: filename 'mysql-bin.000006', position '529'
240823 14:08:50 [00] Compressing /data/20240823/full_backup/backup-my.cnf.qp
240823 14:08:50 [00] ...done
240823 14:08:50 [00] Compressing /data/20240823/full_backup/xtrabackup_info.qp
240823 14:08:50 [00] ...done
xtrabackup: Transaction log of lsn (2822741) to (2822750) was copied.
240823 14:08:50 completed OK!
sudo chmod -R 777 /data/20240823/full_backup
主机端
mysql -u root -p
1234aA~1
use company_pro;
insert into employee(name) value (‘20240823_1413’);
slave 机器上面:
cd ~
mkdir tmp
cd /home/jack/tmp
scp -r 192.168.99.40:/data/20240823 .
cd /home/jack/tmp/20240823/full_backup
解压
xtrabackup --decompress --parallel=2 --target-dir=/home/jack/tmp/20240823/full_backup
sudo systemctl stop mysqld
sudo cp -r /opt/datadir/mysql /opt/datadir/bak_mysql
sudo rm -rf /opt/datadir/mysql/*
sudo xtrabackup --prepare --apply-log-only --target-dir=/home/jack/tmp/20240823/full_backup
sudo xtrabackup --copy-back --target-dir=/home/jack/tmp/20240823/full_backup
sudo chown -R mysql.mysql /opt/datadir/mysql/*
sudo systemctl restart mysqld
mysql -u root -p
mysql -V
在主机端:
show binlog events in ‘mysql-bin.000006’;
sudo mysqlbinlog --start-position=529 /opt/datadir/mysql/mysql-bin.000006 -vv > load.sql
scp load.sql jack@192.168.99.49://home/jack/tmp/
mysql -u root -p < load.sql
mysql -u root -p
1234aA~1
show databases ;
use company_pro;
show tables ;
select * from employee ;
mydump 太大的文件,需要 分块,不然内存会溢出
show binlog events in ‘bin-log.000004’;
mysql-bin.000006
这篇关于centos7 xtrabackup mysql(8)压缩 全量备份 还原(4)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!