zoukankan      html  css  js  c++  java
  • Xtrabackup安装与使用

    安装

    [root@node3 ~]# tar xf percona-xtrabackup-2.4.7-Linux-x86_64.tar.gz
    [root@node3 ~]# cd percona-xtrabackup-2.4.7-Linux-x86_64
    [root@node3 percona-xtrabackup-2.4.7-Linux-x86_64]# mkdir /usr/local/xtrabackup
    [root@node3 percona-xtrabackup-2.4.7-Linux-x86_64]# mv * /usr/local/xtrabackup/
    [root@node3 percona-xtrabackup-2.4.7-Linux-x86_64]#  ln -s /usr/local/xtrabackup/bin/* /usr/bin/

    全量备份`

    [root@localhost backup]# innobackupex --defaults-file=/etc/my.cnf --socket=/var/lib/mysql/mysql.sock --user=root --password="123456" --backup /root/backup
    200115 21:22:08 innobackupex: Starting the backup operation
    
    IMPORTANT: Please check that the backup run completes successfully.
               At the end of a successful backup run innobackupex
               prints "completed OK!".
    
    Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at - line 688.
    报错

    解决办法

    [root@localhost backup]# yum install 'perl(Data::Dumper)'
    [root@localhost backup]# yum -y install perl-Digest-MD5
    [root@localhost backup]# cd 2020-01-15_21-29-53/
    [root@localhost 2020-01-15_21-29-53]# ls -l
    总用量 12336
    drwxr-x---. 2 root root       48 1月  15 21:29 a
    -rw-r-----. 1 root root      424 1月  15 21:29 backup-my.cnf
    -rw-r-----. 1 root root      354 1月  15 21:29 ib_buffer_pool
    -rw-r-----. 1 root root 12582912 1月  15 21:29 ibdata1
    drwxr-x---. 2 root root     4096 1月  15 21:29 mysql
    drwxr-x---. 2 root root     8192 1月  15 21:29 performance_schema
    drwxr-x---. 2 root root     8192 1月  15 21:29 sys
    -rw-r-----. 1 root root      113 1月  15 21:29 xtrabackup_checkpoints
    -rw-r-----. 1 root root      493 1月  15 21:29 xtrabackup_info
    -rw-r-----. 1 root root     2560 1月  15 21:29 xtrabackup_logfile
    [root@localhost 2020-01-15_21-29-53]# cat xtrabackup_info 
    uuid = 1fad2cc0-379b-11ea-afa7-000c29f66717
    name = 
    tool_name = innobackupex
    tool_command = --defaults-file=/etc/my.cnf --socket=/var/lib/mysql/mysql.sock --user=root --password=... --backup /root/backup
    tool_version = 2.4.7
    ibbackup_version = 2.4.7
    server_version = 5.7.29
    start_time = 2020-01-15 21:29:54
    end_time = 2020-01-15 21:29:57
    lock_time = 0
    binlog_pos = 
    innodb_from_lsn = 0
    innodb_to_lsn = 2635117
    partial = N
    incremental = N
    format = file
    compact = N
    compressed = N
    encrypted = N
    这里面就是相关的备份文件,同样也可以看到我们创建的库的名称
    [root@localhost 2020-01-15_21-29-53]# innobackupex --apply-log /root/backup/2020-01-15_21-29-53/
    使用此参数使用相关数据性文件保持一致性状态
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | a                  |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    5 rows in set (0.14 sec)
    
    mysql> use a;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> show tables;
    +-------------+
    | Tables_in_a |
    +-------------+
    | a1          |
    +-------------+
    1 row in set (0.00 sec)
    
    mysql> select * from a1;
    +-------+------+
    | name  | age  |
    +-------+------+
    | lishi |   19 |
    +-------+------+
    1 row in set (0.00 sec)
    mysql> drop table a1;
    Query OK, 0 rows affected (0.34 sec)
    mysql> select * from a1;
    ERROR 1146 (42S02): Table 'a.a1' doesn't exist
    [root@localhost ~]# systemctl stop mysqld
    [root@localhost ~]# cd /var/lib/mysql
    [root@localhost mysql]#  rm -rf *
    [root@localhost mysql]# innobackupex --defaults-file=/etc/my.cnf --copy-back /root/backup/2020-01-15_21-29-53/
    [root@localhost mysql]# chown -R mysql:mysql ./*
    [root@localhost mysql]# systemctl start mysqld
    [root@localhost mysql]# mysql -uroot -p123456
    mysql> use a;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> show tables;
    +-------------+
    | Tables_in_a |
    +-------------+
    | a1          |
    +-------------+
    1 row in set (0.00 sec)
    
    mysql> select * from a1;
    +-------+------+
    | name  | age  |
    +-------+------+
    | lishi |   19 |
    +-------+------+
    1 row in set (0.00 sec)
  • 相关阅读:
    AcWiing 翻硬币
    AcWing 飞行员兄弟 二进制枚举
    AcWing 费解的开关 二进制枚举
    vue发送短信逻辑
    使用celery异步发送短信
    celery配置与基本使用
    celery原理与组件
    短信验证接口
    图片验证码接口
    编写注册接口
  • 原文地址:https://www.cnblogs.com/liujunjun/p/12198918.html
Copyright © 2011-2022 走看看