文档课题:rhel 6.5下Percona Xtrabackup的安装与使用.
系统:rhel 6.5 64位
数据库:mysql 5.5.18
安装包:percona-xtrabackup-24-2.4.6-2.el6.x86_64.rpm
1、安装依赖包
sftp> put percona-xtrabackup-24-2.4.6-2.el6.x86_64.rpm
sftp> put libev-4.04-2.el6.x86_64.rpm
[root@MySQL5518-Master ~]# cat <<EOF>>/etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1
EOF
[root@MySQL5518-Master ~]# yum makecache
[root@MySQL5518-Master ~]# rpm -ivh libev-4.04-2.el6.x86_64.rpm
[root@MySQL5518-Master ~]# yum -y install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL

2、安装xtrabackup
[root@MySQL5518-Master ~]# rpm -ivh percona-xtrabackup-24-2.4.6-2.el6.x86_64.rpm
warning: percona-xtrabackup-24-2.4.6-2.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
Preparing...                ########################################### [100%]
   1:percona-xtrabackup-24  ########################################### [100%]
[root@MySQL5518-Master ~]# xtrabackup --version
xtrabackup version 2.4.6 based on MySQL server 5.7.13 Linux (x86_64) (revision id: 8ec05b7)

3、数据确认
[mysql@MySQL5518-Master ~]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.18 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

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> use booksDB;
Database changed
mysql> show tables;
+-------------------+
| Tables_in_booksDB |
+-------------------+
| authorbook        |
| authors           |
| books             |
+-------------------+
3 rows in set (0.00 sec)

[mysql@MySQL5518-Master ~]$ cd /var/mysql/data/booksDB
[mysql@MySQL5518-Master booksDB]$ ll
total 64
-rw-rw----. 1 mysql mysql 8598 Aug 19 22:58 authorbook.frm
-rw-rw----. 1 mysql mysql   72 Aug 19 22:58 authorbook.MYD
-rw-rw----. 1 mysql mysql 3072 Aug 19 22:58 authorbook.MYI
-rw-rw----. 1 mysql mysql 8650 Aug 19 22:57 authors.frm
-rw-rw----. 1 mysql mysql  180 Aug 19 22:58 authors.MYD
-rw-rw----. 1 mysql mysql 2048 Aug 19 22:58 authors.MYI
-rw-rw----. 1 mysql mysql 8640 Aug 19 22:57 books.frm
-rw-rw----. 1 mysql mysql  208 Aug 19 22:57 books.MYD
-rw-rw----. 1 mysql mysql 2048 Aug 19 22:57 books.MYI
-rw-rw----. 1 mysql mysql   61 Aug 19 22:57 db.opt

4、备份测试
[mysql@MySQL5518-Master mysql]$ /usr/bin/innobackupex --defaults-file=/etc/my.cnf --socket=/tmp/mysql.sock --user=root --password=mysql_4U --port=3306 --slave-info --stream=tar --tmpdir=/mysql/tmpfile /mysql/bak/ 2>/mysql/log_bak/backup.log |gzip ->/mysql/bak/192.168.133.122_20230819_3306.tar.gz

5、备份日志
[mysql@MySQL5518-Master log_bak]$ cat backup.log
230819 23:12:56 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!".

230819 23:12:56  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/tmp/mysql.sock' as 'root'  (using password: YES).
230819 23:12:56  version_check Connected to MySQL server
230819 23:12:56  version_check Executing a version check against the server...
230819 23:12:56  version_check Done.
230819 23:12:56 Connecting to MySQL server host: localhost, user: root, password: set, port: 3306, socket: /tmp/mysql.sock
Using server version 5.5.18
/usr/bin/innobackupex version 2.4.6 based on MySQL server 5.7.13 Linux (x86_64) (revision id: 8ec05b7)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/mysql/data
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:10M:autoextend
xtrabackup:   innodb_log_group_home_dir = ./
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 5242880
InnoDB: Number of pools: 1
230819 23:12:56 >> log scanned up to (1595675)
xtrabackup: Generating a list of tablespaces
230819 23:12:56 [01] Streaming ./ibdata1
230819 23:12:57 [01]        ...done
230819 23:12:57 >> log scanned up to (1595675)
230819 23:12:57 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
230819 23:12:57 Executing FLUSH TABLES WITH READ LOCK...
230819 23:12:57 Starting to backup non-InnoDB tables and files
230819 23:12:57 [00] Streaming test/db.opt
230819 23:12:57 [00]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/events_waits_history_long.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/events_waits_history.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/threads.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/cond_instances.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/file_summary_by_event_name.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/file_instances.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/performance_timers.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/mutex_instances.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/events_waits_summary_by_instance.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/setup_consumers.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/file_summary_by_instance.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/setup_timers.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/rwlock_instances.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/events_waits_current.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/db.opt to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/setup_instruments.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./performance_schema/events_waits_summary_global_by_event_name.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/books.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/authorbook.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/authors.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/authors.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/authors.MYI to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/authorbook.MYI to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/db.opt to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/authorbook.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/books.MYI to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./booksDB/books.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/help_topic.frm to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/help_topic.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/time_zone.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/time_zone_leap_second.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/servers.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/proxies_priv.MYD to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/user.MYI to <STDOUT>
230819 23:12:57 [01]        ...done
230819 23:12:57 [01] Streaming ./mysql/columns_priv.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/ndb_binlog_index.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_keyword.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/tables_priv.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/func.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_transition_type.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_name.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_keyword.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/ndb_binlog_index.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/procs_priv.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/proxies_priv.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_transition.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_name.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/proc.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/plugin.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/ndb_binlog_index.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/plugin.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_keyword.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_relation.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/event.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/servers.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/host.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_category.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_category.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/tables_priv.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/host.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/proxies_priv.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/columns_priv.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_relation.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/general_log.CSM to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/proc.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/db.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_transition_type.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_transition.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/host.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/servers.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_relation.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/general_log.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/event.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/user.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/slow_log.CSM to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/general_log.CSV to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_topic.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_name.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/columns_priv.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/user.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/plugin.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/procs_priv.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/func.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/func.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_leap_second.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_transition.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/slow_log.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/help_category.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/db.MYD to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/event.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/procs_priv.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/proc.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/db.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_leap_second.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/slow_log.CSV to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/tables_priv.frm to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 [01] Streaming ./mysql/time_zone_transition_type.MYI to <STDOUT>
230819 23:12:58 [01]        ...done
230819 23:12:58 Finished backing up non-InnoDB tables and files
Failed to get master binlog coordinates from SHOW SLAVE STATUS
This means that the server is not a replication slave. Ignoring the --slave-info option
230819 23:12:58 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '1595675'
xtrabackup: Stopping log copying thread.
.230819 23:12:58 >> log scanned up to (1595675)

230819 23:12:58 Executing UNLOCK TABLES
230819 23:12:58 All tables unlocked
230819 23:12:58 Backup created in directory '/mysql/bak/'
230819 23:12:58 [00] Streaming backup-my.cnf
230819 23:12:58 [00]        ...done
230819 23:12:58 [00] Streaming xtrabackup_info
230819 23:12:58 [00]        ...done
xtrabackup: Transaction log of lsn (1595675) to (1595675) was copied.
230819 23:12:58 completed OK!

参考网址:http://www.hzhcontrols.com/new-134733.html