侧边栏壁纸
博主头像
张种恩的技术小栈博主等级

行动起来,活在当下

  • 累计撰写 748 篇文章
  • 累计创建 65 个标签
  • 累计收到 39 条评论

目 录CONTENT

文章目录

从云上mysql冷备xb文件恢复到本地

zze
zze
2021-04-20 / 0 评论 / 0 点赞 / 261 阅读 / 1650 字

不定期更新相关视频,抖音点击左上角加号后扫一扫右方侧边栏二维码关注我~正在更新《Shell其实很简单》系列

腾讯云和阿里云上的 MySQL 实例全备文件都是 xb 后缀,如下:

image.png

今天由于特殊原因需要恢复之前的备份到本地环境,要注意的是本地部署的实例版本需要和云上一致,主要恢复步骤如下:


1、参考【二进制包形式安装 MySQL 5.7】完成一个 MySQL 实例的部署。

2、安装处理 *.xb 文件相关的工具包:

$ yum install percona-xtrabackup-2.3.6-1.el7.x86_64 -y
$ wget http://www.quicklz.com/qpress-11-linux-x64.tar
$ tar xf qpress-11-linux-x64.tar
$ mv qpress /usr/local/bin/

3、对 *.xb 文件进行解包解压处理并设置 mysql 权限:

$ mkdir tencent-mysqldata
$ cat xxx.xb | xbstream -x -v -C  tencent-mysqldata/
$ innobackupex --decompress --remove-original  tencent-mysqldata/

4、将解压的数据目录直接设置为本地 MySQL 实例的数据目录:

$ mv tencent-mysqldata/ /data/3306
$ chown -R mysql.mysql /data/3306
$ vim /etc/my.cnf
[mysqld]
...
datadir=/data/3306/tencent-mysqldata/
...

5、重启 MySQL 实例,登入测试:

$ systemctl restart mysql
$ mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
0

评论区