centos7 xtrabackup mysql(8)压缩 全量备份 还原(4)

2024-08-24 05:04

本文主要是介绍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)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1101521

相关文章

SQL中的外键约束

外键约束用于表示两张表中的指标连接关系。外键约束的作用主要有以下三点: 1.确保子表中的某个字段(外键)只能引用父表中的有效记录2.主表中的列被删除时,子表中的关联列也会被删除3.主表中的列更新时,子表中的关联元素也会被更新 子表中的元素指向主表 以下是一个外键约束的实例展示

基于MySQL Binlog的Elasticsearch数据同步实践

一、为什么要做 随着马蜂窝的逐渐发展,我们的业务数据越来越多,单纯使用 MySQL 已经不能满足我们的数据查询需求,例如对于商品、订单等数据的多维度检索。 使用 Elasticsearch 存储业务数据可以很好的解决我们业务中的搜索需求。而数据进行异构存储后,随之而来的就是数据同步的问题。 二、现有方法及问题 对于数据同步,我们目前的解决方案是建立数据中间表。把需要检索的业务数据,统一放到一张M

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

Centos7安装Mongodb4

1、下载源码包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz 2、解压 放到 /usr/local/ 目录下 tar -zxvf mongodb-linux-x86_64-rhel70-4.2.1.tgzmv mongodb-linux-x86_64-rhel70-4.2.1/

如何去写一手好SQL

MySQL性能 最大数据量 抛开数据量和并发数,谈性能都是耍流氓。MySQL没有限制单表最大记录数,它取决于操作系统对文件大小的限制。 《阿里巴巴Java开发手册》提出单表行数超过500万行或者单表容量超过2GB,才推荐分库分表。性能由综合因素决定,抛开业务复杂度,影响程度依次是硬件配置、MySQL配置、数据表设计、索引优化。500万这个值仅供参考,并非铁律。 博主曾经操作过超过4亿行数据

hdu1043(八数码问题,广搜 + hash(实现状态压缩) )

利用康拓展开将一个排列映射成一个自然数,然后就变成了普通的广搜题。 #include<iostream>#include<algorithm>#include<string>#include<stack>#include<queue>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#inclu

性能分析之MySQL索引实战案例

文章目录 一、前言二、准备三、MySQL索引优化四、MySQL 索引知识回顾五、总结 一、前言 在上一讲性能工具之 JProfiler 简单登录案例分析实战中已经发现SQL没有建立索引问题,本文将一起从代码层去分析为什么没有建立索引? 开源ERP项目地址:https://gitee.com/jishenghua/JSH_ERP 二、准备 打开IDEA找到登录请求资源路径位置

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间

hdu1565(状态压缩)

本人第一道ac的状态压缩dp,这题的数据非常水,很容易过 题意:在n*n的矩阵中选数字使得不存在任意两个数字相邻,求最大值 解题思路: 一、因为在1<<20中有很多状态是无效的,所以第一步是选择有效状态,存到cnt[]数组中 二、dp[i][j]表示到第i行的状态cnt[j]所能得到的最大值,状态转移方程dp[i][j] = max(dp[i][j],dp[i-1][k]) ,其中k满足c

Centos7安装JDK1.8保姆版

工欲善其事,必先利其器。这句话同样适用于学习Java编程。在开始Java的学习旅程之前,我们必须首先配置好适合的开发环境。 通过事先准备好这些工具和配置,我们可以避免在学习过程中遇到因环境问题导致的代码异常或错误。一个稳定、高效的开发环境能够让我们更加专注于代码的学习和编写,提升学习效率,减少不必要的困扰和挫折感。因此,在学习Java之初,投入一些时间和精力来配置好开发环境是非常值得的。这将为我