MySQL数据库使用Xtrabackup全备和全备还原

2023年 4月 29日 65.8k 0

一、使用innobackupex创建全备 语法 innobackupex --user=DBUSER --password=DBUSERPASS /path/to/backup/dir/ innobackupex --user=DBUSER --password=DBUSERPASS --backup --target-dir=/path/to/BACKUP-DIR/ Option Description --backup 默认选

一、使用innobackupex创建全备

语法innobackupex --user=DBUSER --password=DBUSERPASS /path/to/backup/dir/innobackupex --user=DBUSER --password=DBUSERPASS --backup --target-dir=/path/to/BACKUP-DIR/

OptionDescription --backup 默认选项 –port 端口 –socket socket –host 主机 --no-timestamp 指定了这个选项备份会直接备份在BACKUP-DIR,不再创建时间戳文件夹 --target-dir 指定了这个选项备份会直接备份在BACKUP-DIR,不再创建时间戳文件夹 --defaults-file 指定默认的配置文件,必须为第一个选项

[root@558idc backup]# innobackupex --defaults-file=/etc/my.cnf  --user=root --password=wangshengzhuang /backup/160904 18:01:55 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!".

160904 18:01:56  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'root'  (using password: YES).160904 18:01:56  version_check Connected to MySQL server160904 18:01:56  version_check Executing a version check against the server...160904 18:01:56  version_check Done.160904 18:01:56 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: /var/lib/mysql/mysql.sockUsing server version 5.6.30-loginnobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)xtrabackup: uses posix_fadvise().xtrabackup: cd to /var/lib/mysqlxtrabackup: open files limit requested 0, set to 1024xtrabackup: using the following InnoDB configuration:xtrabackup:  innodb_data_home_dir = .xtrabackup:  innodb_data_file_path = ibdata1:12M:autoextendxtrabackup:  innodb_log_group_home_dir = ./xtrabackup:  innodb_log_files_in_group = 2xtrabackup:  innodb_log_file_size = 50331648InnoDB: Number of pools: 1160904 18:01:56 >> log scanned up to (1626027)xtrabackup: Generating a list of tablespacesInnoDB: Allocated tablespace ID 3 for mysql/slave_relay_log_info, old maximum was 0160904 18:01:56 [01] Copying ./ibdata1 to /backup/2019-09-04_18-01-55/ibdata1160904 18:01:56 [01]        ...done160904 18:01:56 [01] Copying ./mysql/slave_relay_log_info.ibd to /backup/2019-09-04_18-01-55/mysql/slave_relay_log_info.ibd160904 18:01:56 [01]        ...done160904 18:01:56 [01] Copying ./mysql/slave_worker_info.ibd to /backup/2019-09-04_18-01-55/mysql/slave_worker_info.ibd160904 18:01:56 [01]        ...done160904 18:01:56 [01] Copying ./mysql/slave_master_info.ibd to /backup/2019-09-04_18-01-55/mysql/slave_master_info.ibd160904 18:01:56 [01]        ...done160904 18:01:56 [01] Copying ./mysql/innodb_index_stats.ibd to /backup/2019-09-04_18-01-55/mysql/innodb_index_stats.ibd160904 18:01:56 [01]        ...done160904 18:01:56 [01] Copying ./mysql/innodb_table_stats.ibd to /backup/2019-09-04_18-01-55/mysql/innodb_table_stats.ibd160904 18:01:56 [01]        ...done160904 18:01:57 >> log scanned up to (1626027)160904 18:01:57 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...160904 18:01:57 Executing FLUSH TABLES WITH READ LOCK...160904 18:01:57 Starting to backup non-InnoDB tables and files160904 18:01:57 [00] Writing test/db.opt160904 18:01:57 [00]        ...done160904 18:01:57 [01] Copying ./mysql/servers.frm to /backup/2019-09-04_18-01-55/mysql/servers.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/tables_priv.MYD to /backup/2019-09-04_18-01-55/mysql/tables_priv.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_keyword.frm to /backup/2019-09-04_18-01-55/mysql/help_keyword.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/ndb_binlog_index.MYD to /backup/2019-09-04_18-01-55/mysql/ndb_binlog_index.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/columns_priv.MYD to /backup/2019-09-04_18-01-55/mysql/columns_priv.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/servers.MYD to /backup/2019-09-04_18-01-55/mysql/servers.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/user.MYD to /backup/2019-09-04_18-01-55/mysql/user.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/event.frm to /backup/2019-09-04_18-01-55/mysql/event.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_transition.MYD to /backup/2019-09-04_18-01-55/mysql/time_zone_transition.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/proc.MYI to /backup/2019-09-04_18-01-55/mysql/proc.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_leap_second.MYI to /backup/2019-09-04_18-01-55/mysql/time_zone_leap_second.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_topic.MYI to /backup/2019-09-04_18-01-55/mysql/help_topic.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_transition.MYI to /backup/2019-09-04_18-01-55/mysql/time_zone_transition.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/general_log.CSV to /backup/2019-09-04_18-01-55/mysql/general_log.CSV160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_transition.frm to /backup/2019-09-04_18-01-55/mysql/time_zone_transition.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/func.MYD to /backup/2019-09-04_18-01-55/mysql/func.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/user.MYI to /backup/2019-09-04_18-01-55/mysql/user.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_relation.MYI to /backup/2019-09-04_18-01-55/mysql/help_relation.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/plugin.frm to /backup/2019-09-04_18-01-55/mysql/plugin.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_name.frm to /backup/2019-09-04_18-01-55/mysql/time_zone_name.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/ndb_binlog_index.MYI to /backup/2019-09-04_18-01-55/mysql/ndb_binlog_index.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_relation.MYD to /backup/2019-09-04_18-01-55/mysql/help_relation.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/plugin.MYD to /backup/2019-09-04_18-01-55/mysql/plugin.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_category.MYD to /backup/2019-09-04_18-01-55/mysql/help_category.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/event.MYI to /backup/2019-09-04_18-01-55/mysql/event.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/event.MYD to /backup/2019-09-04_18-01-55/mysql/event.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/procs_priv.MYI to /backup/2019-09-04_18-01-55/mysql/procs_priv.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/slow_log.frm to /backup/2019-09-04_18-01-55/mysql/slow_log.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_keyword.MYI to /backup/2019-09-04_18-01-55/mysql/help_keyword.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/user.frm to /backup/2019-09-04_18-01-55/mysql/user.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/slow_log.CSV to /backup/2019-09-04_18-01-55/mysql/slow_log.CSV160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_keyword.MYD to /backup/2019-09-04_18-01-55/mysql/help_keyword.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/plugin.MYI to /backup/2019-09-04_18-01-55/mysql/plugin.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/func.frm to /backup/2019-09-04_18-01-55/mysql/func.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/proxies_priv.MYD to /backup/2019-09-04_18-01-55/mysql/proxies_priv.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_leap_second.frm to /backup/2019-09-04_18-01-55/mysql/time_zone_leap_second.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/slave_master_info.frm to /backup/2019-09-04_18-01-55/mysql/slave_master_info.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_relation.frm to /backup/2019-09-04_18-01-55/mysql/help_relation.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/func.MYI to /backup/2019-09-04_18-01-55/mysql/func.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/procs_priv.frm to /backup/2019-09-04_18-01-55/mysql/procs_priv.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/proc.frm to /backup/2019-09-04_18-01-55/mysql/proc.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/innodb_index_stats.frm to /backup/2019-09-04_18-01-55/mysql/innodb_index_stats.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/db.MYD to /backup/2019-09-04_18-01-55/mysql/db.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/db.frm to /backup/2019-09-04_18-01-55/mysql/db.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/columns_priv.MYI to /backup/2019-09-04_18-01-55/mysql/columns_priv.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone.frm to /backup/2019-09-04_18-01-55/mysql/time_zone.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/columns_priv.frm to /backup/2019-09-04_18-01-55/mysql/columns_priv.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/slave_worker_info.frm to /backup/2019-09-04_18-01-55/mysql/slave_worker_info.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_transition_type.frm to /backup/2019-09-04_18-01-55/mysql/time_zone_transition_type.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_topic.frm to /backup/2019-09-04_18-01-55/mysql/help_topic.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/servers.MYI to /backup/2019-09-04_18-01-55/mysql/servers.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_category.frm to /backup/2019-09-04_18-01-55/mysql/help_category.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_category.MYI to /backup/2019-09-04_18-01-55/mysql/help_category.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/general_log.frm to /backup/2019-09-04_18-01-55/mysql/general_log.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_leap_second.MYD to /backup/2019-09-04_18-01-55/mysql/time_zone_leap_second.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/tables_priv.MYI to /backup/2019-09-04_18-01-55/mysql/tables_priv.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_name.MYI to /backup/2019-09-04_18-01-55/mysql/time_zone_name.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/tables_priv.frm to /backup/2019-09-04_18-01-55/mysql/tables_priv.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_transition_type.MYI to /backup/2019-09-04_18-01-55/mysql/time_zone_transition_type.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_name.MYD to /backup/2019-09-04_18-01-55/mysql/time_zone_name.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/slave_relay_log_info.frm to /backup/2019-09-04_18-01-55/mysql/slave_relay_log_info.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/ndb_binlog_index.frm to /backup/2019-09-04_18-01-55/mysql/ndb_binlog_index.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone.MYD to /backup/2019-09-04_18-01-55/mysql/time_zone.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/innodb_table_stats.frm to /backup/2019-09-04_18-01-55/mysql/innodb_table_stats.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/proc.MYD to /backup/2019-09-04_18-01-55/mysql/proc.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone_transition_type.MYD to /backup/2019-09-04_18-01-55/mysql/time_zone_transition_type.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/general_log.CSM to /backup/2019-09-04_18-01-55/mysql/general_log.CSM160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/proxies_priv.frm to /backup/2019-09-04_18-01-55/mysql/proxies_priv.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/db.MYI to /backup/2019-09-04_18-01-55/mysql/db.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/proxies_priv.MYI to /backup/2019-09-04_18-01-55/mysql/proxies_priv.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/procs_priv.MYD to /backup/2019-09-04_18-01-55/mysql/procs_priv.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/help_topic.MYD to /backup/2019-09-04_18-01-55/mysql/help_topic.MYD160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/time_zone.MYI to /backup/2019-09-04_18-01-55/mysql/time_zone.MYI160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./mysql/slow_log.CSM to /backup/2019-09-04_18-01-55/mysql/slow_log.CSM160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./performance_schema/hosts.frm to /backup/2019-09-04_18-01-55/performance_schema/hosts.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./performance_schema/setup_objects.frm to /backup/2019-09-04_18-01-55/performance_schema/setup_objects.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./performance_schema/file_instances.frm to /backup/2019-09-04_18-01-55/performance_schema/file_instances.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./performance_schema/performance_timers.frm to /backup/2019-09-04_18-01-55/performance_schema/performance_timers.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./performance_schema/table_io_waits_summary_by_index_usage.frm to /backup/2019-09-04_18-01-55/performance_schema/table_io_waits_summary_by_index_usage.frm160904 18:01:57 [01]        ...done160904 18:01:57 [01] Copying ./performance_schema/events_statements_summary_by_user_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_summary_by_user_by_event_name.frm160904 18:01:57 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/objects_summary_global_by_type.frm to /backup/2019-09-04_18-01-55/performance_schema/objects_summary_global_by_type.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_current.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_current.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/accounts.frm to /backup/2019-09-04_18-01-55/performance_schema/accounts.frm160904 18:01:58 [01]        ...done160904 18:01:58 >> log scanned up to (1626027)160904 18:01:58 [01] Copying ./performance_schema/socket_summary_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/socket_summary_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/mutex_instances.frm to /backup/2019-09-04_18-01-55/performance_schema/mutex_instances.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/table_lock_waits_summary_by_table.frm to /backup/2019-09-04_18-01-55/performance_schema/table_lock_waits_summary_by_table.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/users.frm to /backup/2019-09-04_18-01-55/performance_schema/users.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/file_summary_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_history_long.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_history_long.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/host_cache.frm to /backup/2019-09-04_18-01-55/performance_schema/host_cache.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_summary_by_account_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_summary_by_account_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_summary_by_user_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_summary_by_user_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_summary_by_digest.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_summary_by_digest.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/session_account_connect_attrs.frm to /backup/2019-09-04_18-01-55/performance_schema/session_account_connect_attrs.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/setup_actors.frm to /backup/2019-09-04_18-01-55/performance_schema/setup_actors.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_summary_by_instance.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/setup_instruments.frm to /backup/2019-09-04_18-01-55/performance_schema/setup_instruments.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_history_long.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_history_long.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_history_long.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_history_long.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_history.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_history.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_summary_by_host_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_summary_by_host_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_summary_by_thread_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_current.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_current.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/cond_instances.frm to /backup/2019-09-04_18-01-55/performance_schema/cond_instances.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/table_io_waits_summary_by_table.frm to /backup/2019-09-04_18-01-55/performance_schema/table_io_waits_summary_by_table.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_summary_by_account_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_summary_by_account_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_summary_global_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/threads.frm to /backup/2019-09-04_18-01-55/performance_schema/threads.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_summary_by_thread_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_summary_by_thread_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/session_connect_attrs.frm to /backup/2019-09-04_18-01-55/performance_schema/session_connect_attrs.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_summary_global_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_summary_global_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/db.opt to /backup/2019-09-04_18-01-55/performance_schema/db.opt160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_summary_by_host_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_summary_by_host_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/file_summary_by_instance.frm to /backup/2019-09-04_18-01-55/performance_schema/file_summary_by_instance.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_summary_by_account_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_summary_by_account_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_summary_global_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_summary_global_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_current.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_current.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_waits_history.frm to /backup/2019-09-04_18-01-55/performance_schema/events_waits_history.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/socket_instances.frm to /backup/2019-09-04_18-01-55/performance_schema/socket_instances.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_summary_by_host_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_summary_by_host_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/setup_consumers.frm to /backup/2019-09-04_18-01-55/performance_schema/setup_consumers.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/socket_summary_by_instance.frm to /backup/2019-09-04_18-01-55/performance_schema/socket_summary_by_instance.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_statements_summary_by_thread_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_statements_summary_by_thread_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/rwlock_instances.frm to /backup/2019-09-04_18-01-55/performance_schema/rwlock_instances.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_summary_by_user_by_event_name.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_summary_by_user_by_event_name.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/events_stages_history.frm to /backup/2019-09-04_18-01-55/performance_schema/events_stages_history.frm160904 18:01:58 [01]        ...done160904 18:01:58 [01] Copying ./performance_schema/setup_timers.frm to /backup/2019-09-04_18-01-55/performance_schema/setup_timers.frm160904 18:01:58 [01]        ...done160904 18:01:58 Finished backing up non-InnoDB tables and files160904 18:01:58 [00] Writing xtrabackup_binlog_info160904 18:01:58 [00]        ...done160904 18:01:58 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...xtrabackup: The latest check point (for incremental): '1626027'xtrabackup: Stopping log copying thread..160904 18:01:58 >> log scanned up to (1626027)

160904 18:01:58 Executing UNLOCK TABLES160904 18:01:58 All tables unlocked160904 18:01:58 Backup created in directory '/backup/2019-09-04_18-01-55'MySQL binlog position: filename 'mysql-bin.000012', position '262'160904 18:01:58 [00] Writing backup-my.cnf160904 18:01:58 [00]        ...done160904 18:01:58 [00] Writing xtrabackup_info160904 18:01:58 [00]        ...donextrabackup: Transaction log of lsn (1626027) to (1626027) was copied.160904 18:01:59 completed OK!

最后的completed OK!表示成功

二、使用innobackupex预备全备

一般情况下,在备份完成后,数据尚且不能用于恢复操作,因为备份的数据中可能会包含尚未提交的事务或已经提交但尚未同步至数据文件中的事务。因此,此时数据文件仍处理不一致状态。“准备”的主要作用正是通过回滚未提交的事务及同步已经提交的事务至数据文件也使得数据文件处于一致性状态。读取备份文件夹中的配置文件,然后innobackupex重做已提交事务,回滚未提交事务,之后数据就被写到了备份的数据文件(innodb文件)中,并重建日志文件。这一步隐式调用了2次xtrabackup –prepare。

语法:innobackupex --apply-log --use-memory=4G /path/to/BACKUP-DIR/日期文件夹

例子:[root@558idc backup]# innobackupex --apply-log /backup/2019-09-04_18-01-55/160904 18:04:24 innobackupex: Starting the apply-log operation

IMPORTANT: Please check that the apply-log run completes successfully.          At the end of a successful apply-log run innobackupex          prints "completed OK!".

innobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)xtrabackup: cd to /backup/2019-09-04_18-01-55xtrabackup: This target seems to be not prepared yet.InnoDB: Number of pools: 1xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(1626027)xtrabackup: using the following InnoDB configuration for recovery:xtrabackup:  innodb_data_home_dir = .xtrabackup:  innodb_data_file_path = ibdata1:12M:autoextendxtrabackup:  innodb_log_group_home_dir = .xtrabackup:  innodb_log_files_in_group = 1xtrabackup:  innodb_log_file_size = 8388608xtrabackup: using the following InnoDB configuration for recovery:xtrabackup:  innodb_data_home_dir = .xtrabackup:  innodb_data_file_path = ibdata1:12M:autoextendxtrabackup:  innodb_log_group_home_dir = .xtrabackup:  innodb_log_files_in_group = 1xtrabackup:  innodb_log_file_size = 8388608xtrabackup: Starting InnoDB instance for recovery.xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)InnoDB: PUNCH HOLE support availableInnoDB: Mutexes and rw_locks use GCC atomic builtinsInnoDB: Uses event mutexesInnoDB: GCC builtin __sync_synchronize() is used for memory barrierInnoDB: Compressed tables use zlib 1.2.3InnoDB: Number of pools: 1InnoDB: Using CPU crc32 instructionsInnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100MInnoDB: Completed initialization of buffer poolInnoDB: page_cleaner coordinator priority: -20InnoDB: Highest supported file format is Barracuda.InnoDB: The log sequence number 1626007 in the system tablespace does not match the log sequence number 1626027 in the ib_logfiles!InnoDB: Database was not shutdown normally!InnoDB: Starting crash recovery.InnoDB: Doing recovery: scanned up to log sequence number 1626027 (0%)InnoDB: Creating shared tablespace for temporary tablesInnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...InnoDB: File './ibtmp1' size is now 12 MB.InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.InnoDB: 32 non-redo rollback segment(s) are active.InnoDB: 5.7.13 started; log sequence number 1626027

xtrabackup: starting shutdown with innodb_fast_shutdown = 1InnoDB: FTS optimize thread exiting.InnoDB: Starting shutdown...InnoDB: Shutdown completed; log sequence number 1626046InnoDB: Number of pools: 1xtrabackup: using the following InnoDB configuration for recovery:xtrabackup:  innodb_data_home_dir = .xtrabackup:  innodb_data_file_path = ibdata1:12M:autoextendxtrabackup:  innodb_log_group_home_dir = .xtrabackup:  innodb_log_files_in_group = 2xtrabackup:  innodb_log_file_size = 50331648InnoDB: PUNCH HOLE support availableInnoDB: Mutexes and rw_locks use GCC atomic builtinsInnoDB: Uses event mutexesInnoDB: GCC builtin __sync_synchronize() is used for memory barrierInnoDB: Compressed tables use zlib 1.2.3InnoDB: Number of pools: 1InnoDB: Using CPU crc32 instructionsInnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100MInnoDB: Completed initialization of buffer poolInnoDB: page_cleaner coordinator priority: -20InnoDB: Setting log file ./ib_logfile101 size to 48 MBInnoDB: Setting log file ./ib_logfile1 size to 48 MBInnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0InnoDB: New log files created, LSN=1626046InnoDB: Highest supported file format is Barracuda.InnoDB: Log scan progressed past the checkpoint lsn 1626124InnoDB: Doing recovery: scanned up to log sequence number 1626133 (0%)InnoDB: Doing recovery: scanned up to log sequence number 1626133 (0%)InnoDB: Database was not shutdown normally!InnoDB: Starting crash recovery.InnoDB: Removed temporary tablespace data file: "ibtmp1"InnoDB: Creating shared tablespace for temporary tablesInnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...InnoDB: File './ibtmp1' size is now 12 MB.InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.InnoDB: 32 non-redo rollback segment(s) are active.InnoDB: 5.7.13 started; log sequence number 1626133xtrabackup: starting shutdown with innodb_fast_shutdown = 1InnoDB: FTS optimize thread exiting.InnoDB: Starting shutdown...InnoDB: Shutdown completed; log sequence number 1626152160904 18:04:27 completed OK!

如果执行正确,其最后输出的几行信息通常如下:completed OK!

在实现“准备”的过程中,innobackupex 通常还可以使用 --use-memory 选项来指定其可以使用的内存的大小,默认通常为 100M。如果有足够的内存可用,可以多划分一些内存给 prepare 的过程,以提高其完成速度。

三、使用innobackupex还原备份

innobackupex命令的--copy-back选项用于执行恢复操作,其通过复制所有数据相关的文件至mysql服务器DATADIR目录中来执行恢复过程。innobackupex通过backup-my.cnf来获取DATADIR目录的相关信息。

语法:innobackupex --copy-back /path/to/BACKUP-DIRinnobackupex --copy-back --datadir=恢复的数据目录 /path/to/BACKUP-DIR

注:1.datadir必须是为空的,innobackupex –copy-back不会覆盖已存在的文件2.还原时需要先关闭服务,如果服务是启动的,那么就不能还原到datadir。

例子[root@558idc mysql]# innobackupex --copy-back /backup/2019-09-04_18-01-55/160904 18:06:31 innobackupex: Starting the copy-back operation

IMPORTANT: Please check that the copy-back run completes successfully.          At the end of a successful copy-back run innobackupex          prints "completed OK!".

innobackupex version 2.4.4 based on MySQL server 5.7.13 Linux (x86_64) (revision id: df58cf2)160904 18:06:31 [01] Copying ib_logfile0 to /var/lib/mysql/ib_logfile0160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ib_logfile1 to /var/lib/mysql/ib_logfile1160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ibdata1 to /var/lib/mysql/ibdata1160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./test/db.opt to /var/lib/mysql/test/db.opt160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./ibtmp1 to /var/lib/mysql/ibtmp1160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/servers.frm to /var/lib/mysql/mysql/servers.frm160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/slave_relay_log_info.ibd to /var/lib/mysql/mysql/slave_relay_log_info.ibd160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/tables_priv.MYD to /var/lib/mysql/mysql/tables_priv.MYD160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/help_keyword.frm to /var/lib/mysql/mysql/help_keyword.frm160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/ndb_binlog_index.MYD to /var/lib/mysql/mysql/ndb_binlog_index.MYD160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/columns_priv.MYD to /var/lib/mysql/mysql/columns_priv.MYD160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/servers.MYD to /var/lib/mysql/mysql/servers.MYD160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/user.MYD to /var/lib/mysql/mysql/user.MYD160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/event.frm to /var/lib/mysql/mysql/event.frm160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/time_zone_transition.MYD to /var/lib/mysql/mysql/time_zone_transition.MYD160904 18:06:31 [01]        ...done160904 18:06:31 [01] Copying ./mysql/proc.MYI to /var/lib/mysql/mysql/proc.MYI160904 18:06:31 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slave_worker_info.ibd to /var/lib/mysql/mysql/slave_worker_info.ibd160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_leap_second.MYI to /var/lib/mysql/mysql/time_zone_leap_second.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_topic.MYI to /var/lib/mysql/mysql/help_topic.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_transition.MYI to /var/lib/mysql/mysql/time_zone_transition.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/general_log.CSV to /var/lib/mysql/mysql/general_log.CSV160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slave_master_info.ibd to /var/lib/mysql/mysql/slave_master_info.ibd160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_transition.frm to /var/lib/mysql/mysql/time_zone_transition.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/func.MYD to /var/lib/mysql/mysql/func.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/user.MYI to /var/lib/mysql/mysql/user.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_relation.MYI to /var/lib/mysql/mysql/help_relation.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/plugin.frm to /var/lib/mysql/mysql/plugin.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_name.frm to /var/lib/mysql/mysql/time_zone_name.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/ndb_binlog_index.MYI to /var/lib/mysql/mysql/ndb_binlog_index.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_relation.MYD to /var/lib/mysql/mysql/help_relation.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/plugin.MYD to /var/lib/mysql/mysql/plugin.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_category.MYD to /var/lib/mysql/mysql/help_category.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/event.MYI to /var/lib/mysql/mysql/event.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/event.MYD to /var/lib/mysql/mysql/event.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/procs_priv.MYI to /var/lib/mysql/mysql/procs_priv.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slow_log.frm to /var/lib/mysql/mysql/slow_log.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_keyword.MYI to /var/lib/mysql/mysql/help_keyword.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/user.frm to /var/lib/mysql/mysql/user.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slow_log.CSV to /var/lib/mysql/mysql/slow_log.CSV160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_keyword.MYD to /var/lib/mysql/mysql/help_keyword.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/plugin.MYI to /var/lib/mysql/mysql/plugin.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/func.frm to /var/lib/mysql/mysql/func.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/innodb_index_stats.ibd to /var/lib/mysql/mysql/innodb_index_stats.ibd160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/proxies_priv.MYD to /var/lib/mysql/mysql/proxies_priv.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_leap_second.frm to /var/lib/mysql/mysql/time_zone_leap_second.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slave_master_info.frm to /var/lib/mysql/mysql/slave_master_info.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_relation.frm to /var/lib/mysql/mysql/help_relation.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/func.MYI to /var/lib/mysql/mysql/func.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/procs_priv.frm to /var/lib/mysql/mysql/procs_priv.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/proc.frm to /var/lib/mysql/mysql/proc.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/innodb_index_stats.frm to /var/lib/mysql/mysql/innodb_index_stats.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/db.MYD to /var/lib/mysql/mysql/db.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/db.frm to /var/lib/mysql/mysql/db.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/columns_priv.MYI to /var/lib/mysql/mysql/columns_priv.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone.frm to /var/lib/mysql/mysql/time_zone.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/columns_priv.frm to /var/lib/mysql/mysql/columns_priv.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slave_worker_info.frm to /var/lib/mysql/mysql/slave_worker_info.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_transition_type.frm to /var/lib/mysql/mysql/time_zone_transition_type.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_topic.frm to /var/lib/mysql/mysql/help_topic.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/servers.MYI to /var/lib/mysql/mysql/servers.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/innodb_table_stats.ibd to /var/lib/mysql/mysql/innodb_table_stats.ibd160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_category.frm to /var/lib/mysql/mysql/help_category.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_category.MYI to /var/lib/mysql/mysql/help_category.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/general_log.frm to /var/lib/mysql/mysql/general_log.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_leap_second.MYD to /var/lib/mysql/mysql/time_zone_leap_second.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/tables_priv.MYI to /var/lib/mysql/mysql/tables_priv.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_name.MYI to /var/lib/mysql/mysql/time_zone_name.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/tables_priv.frm to /var/lib/mysql/mysql/tables_priv.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_transition_type.MYI to /var/lib/mysql/mysql/time_zone_transition_type.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_name.MYD to /var/lib/mysql/mysql/time_zone_name.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slave_relay_log_info.frm to /var/lib/mysql/mysql/slave_relay_log_info.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/ndb_binlog_index.frm to /var/lib/mysql/mysql/ndb_binlog_index.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone.MYD to /var/lib/mysql/mysql/time_zone.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/innodb_table_stats.frm to /var/lib/mysql/mysql/innodb_table_stats.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/proc.MYD to /var/lib/mysql/mysql/proc.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone_transition_type.MYD to /var/lib/mysql/mysql/time_zone_transition_type.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/general_log.CSM to /var/lib/mysql/mysql/general_log.CSM160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/proxies_priv.frm to /var/lib/mysql/mysql/proxies_priv.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/db.MYI to /var/lib/mysql/mysql/db.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/proxies_priv.MYI to /var/lib/mysql/mysql/proxies_priv.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/procs_priv.MYD to /var/lib/mysql/mysql/procs_priv.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/help_topic.MYD to /var/lib/mysql/mysql/help_topic.MYD160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/time_zone.MYI to /var/lib/mysql/mysql/time_zone.MYI160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./mysql/slow_log.CSM to /var/lib/mysql/mysql/slow_log.CSM160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/hosts.frm to /var/lib/mysql/performance_schema/hosts.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/setup_objects.frm to /var/lib/mysql/performance_schema/setup_objects.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/file_instances.frm to /var/lib/mysql/performance_schema/file_instances.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/performance_timers.frm to /var/lib/mysql/performance_schema/performance_timers.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/table_io_waits_summary_by_index_usage.frm to /var/lib/mysql/performance_schema/table_io_waits_summary_by_index_usage.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/events_statements_summary_by_user_by_event_name.frm to /var/lib/mysql/performance_schema/events_statements_summary_by_user_by_event_name.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/objects_summary_global_by_type.frm to /var/lib/mysql/performance_schema/objects_summary_global_by_type.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/events_statements_current.frm to /var/lib/mysql/performance_schema/events_statements_current.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/accounts.frm to /var/lib/mysql/performance_schema/accounts.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/socket_summary_by_event_name.frm to /var/lib/mysql/performance_schema/socket_summary_by_event_name.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/mutex_instances.frm to /var/lib/mysql/performance_schema/mutex_instances.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/table_lock_waits_summary_by_table.frm to /var/lib/mysql/performance_schema/table_lock_waits_summary_by_table.frm160904 18:06:32 [01]        ...done160904 18:06:32 [01] Copying ./performance_schema/users.frm to /var/lib/mysql/performance_schema/users.frm160904 18:06:32 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /var/lib/mysql/performance_schema/file_summary_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_history_long.frm to /var/lib/mysql/performance_schema/events_statements_history_long.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/host_cache.frm to /var/lib/mysql/performance_schema/host_cache.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_summary_by_account_by_event_name.frm to /var/lib/mysql/performance_schema/events_statements_summary_by_account_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_summary_by_user_by_event_name.frm to /var/lib/mysql/performance_schema/events_waits_summary_by_user_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_summary_by_digest.frm to /var/lib/mysql/performance_schema/events_statements_summary_by_digest.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/session_account_connect_attrs.frm to /var/lib/mysql/performance_schema/session_account_connect_attrs.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/setup_actors.frm to /var/lib/mysql/performance_schema/setup_actors.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /var/lib/mysql/performance_schema/events_waits_summary_by_instance.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/setup_instruments.frm to /var/lib/mysql/performance_schema/setup_instruments.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_history_long.frm to /var/lib/mysql/performance_schema/events_stages_history_long.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_history_long.frm to /var/lib/mysql/performance_schema/events_waits_history_long.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_history.frm to /var/lib/mysql/performance_schema/events_statements_history.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_summary_by_host_by_event_name.frm to /var/lib/mysql/performance_schema/events_stages_summary_by_host_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /var/lib/mysql/performance_schema/events_waits_summary_by_thread_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_current.frm to /var/lib/mysql/performance_schema/events_waits_current.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/cond_instances.frm to /var/lib/mysql/performance_schema/cond_instances.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/table_io_waits_summary_by_table.frm to /var/lib/mysql/performance_schema/table_io_waits_summary_by_table.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_summary_by_account_by_event_name.frm to /var/lib/mysql/performance_schema/events_stages_summary_by_account_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /var/lib/mysql/performance_schema/events_waits_summary_global_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/threads.frm to /var/lib/mysql/performance_schema/threads.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_summary_by_thread_by_event_name.frm to /var/lib/mysql/performance_schema/events_stages_summary_by_thread_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/session_connect_attrs.frm to /var/lib/mysql/performance_schema/session_connect_attrs.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_summary_global_by_event_name.frm to /var/lib/mysql/performance_schema/events_statements_summary_global_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/db.opt to /var/lib/mysql/performance_schema/db.opt160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_summary_by_host_by_event_name.frm to /var/lib/mysql/performance_schema/events_waits_summary_by_host_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/file_summary_by_instance.frm to /var/lib/mysql/performance_schema/file_summary_by_instance.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_summary_by_account_by_event_name.frm to /var/lib/mysql/performance_schema/events_waits_summary_by_account_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_summary_global_by_event_name.frm to /var/lib/mysql/performance_schema/events_stages_summary_global_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_current.frm to /var/lib/mysql/performance_schema/events_stages_current.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_waits_history.frm to /var/lib/mysql/performance_schema/events_waits_history.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/socket_instances.frm to /var/lib/mysql/performance_schema/socket_instances.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_summary_by_host_by_event_name.frm to /var/lib/mysql/performance_schema/events_statements_summary_by_host_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/setup_consumers.frm to /var/lib/mysql/performance_schema/setup_consumers.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/socket_summary_by_instance.frm to /var/lib/mysql/performance_schema/socket_summary_by_instance.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_statements_summary_by_thread_by_event_name.frm to /var/lib/mysql/performance_schema/events_statements_summary_by_thread_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/rwlock_instances.frm to /var/lib/mysql/performance_schema/rwlock_instances.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_summary_by_user_by_event_name.frm to /var/lib/mysql/performance_schema/events_stages_summary_by_user_by_event_name.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/events_stages_history.frm to /var/lib/mysql/performance_schema/events_stages_history.frm160904 18:06:33 [01]        ...done160904 18:06:33 [01] Copying ./performance_schema/setup_timers.frm to /var/lib/mysql/performance_schema/setup_timers.frm160904 18:06:33 [01]        ...done160904 18:06:33 completed OK!

如果执行正确,其输出信息的最后几行通常如下:completed OK! 请确保如上信息的最行一行出现“innobackupex: completed OK!”。

如果服务器剩余空间不足,你可以使用 --move-back替换掉 --copy-back。

启动数据库

当数据恢复至DATADIR目录以后,还需要确保所有数据文件的属主和属组均为正确的用户,如mysql,否则,在启动mysqld之前还需要事先修改数据文件的属主和属组。如:chown -R mysql.mysql 新的数据目录

现在可以启动mysql了

四、Xtrabackup备份文件的说明

查看备份的输出,使用innobakupex备份时,其会调用xtrabackup备份所有的InnoDB表,复制所有关于表结构定义的相关文件(.frm)、以及MyISAM、MERGE、CSV和ARCHIVE表的相关文件,同时还会备份触发器和数据库配置信息相关的文件。这些文件会被保存至一个以时间命令的目录中。[root@558idc backup]# tree -L 2 /backup//backup/└── 2019-09-04_18-01-55    ├── backup-my.cnf    ├── ibdata1    ├── ib_logfile0    ├── ib_logfile1    ├── ibtmp1    ├── mysql    ├── performance_schema    ├── test    ├── xtrabackup_binlog_info    ├── xtrabackup_checkpoints    ├── xtrabackup_info    └── xtrabackup_logfile

4 directories, 9 files

在备份的同时,innobackupex还会在备份目录中创建如下文件:

(1)xtrabackup_checkpoints

包含备份类型(如完全或增量)、备份状态(如是否已经为prepared状态)和LSN(日志序列号)范围信息;每个InnoDB页(通常为16k大小)都会包含一个日志序列号,即LSN。LSN是整个数据库系统的系统版本号,每个页面相关的LSN能够表明此页面最近是如何发生改变的。[root@558idc 2019-09-04_18-01-55]# cat xtrabackup_checkpoints backup_type = full-preparedfrom_lsn = 0to_lsn = 1626027last_lsn = 1626027compact = 0recover_binlog_info = 0

(2)xtrabackup_info

mysql服务器当前正在使用的二进制日志文件及至备份这一刻为止二进制日志事件的位置。[root@558idc 2019-09-04_18-01-55]# cat xtrabackup_info uuid = 9e4c2078-7286-11e6-92a6-0800279b6e4dname = tool_name = innobackupextool_command = --defaults-file=/etc/my.cnf --user=root --password=... /backup/tool_version = 2.4.4ibbackup_version = 2.4.4server_version = 5.6.30-logstart_time = 2019-09-04 18:01:56end_time = 2019-09-04 18:01:58lock_time = 0binlog_pos = filename 'mysql-bin.000012', position '262'innodb_from_lsn = 0innodb_to_lsn = 1626027partial = Nincremental = Nformat = filecompact = Ncompressed = Nencrypted = N

(3)xtrabackup_binlog_info

二进制日志文件及用于InnoDB或XtraDB表的二进制日志文件的当前position。[root@558idc 2019-09-04_18-01-55]# cat xtrabackup_binlog_info mysql-bin.000012    262

(4)xtrabackup_logfile

开始以来的二进制日志,用于prepare的时候实现一致性

(5)backup-my.cnf

备份命令用到的配置选项信息;[root@558idc 2019-09-04_18-01-55]# cat backup-my.cnf # This MySQL options file was generated by innobackupex.

# The MySQL server[mysqld]innodb_checksum_algorithm=innodbinnodb_log_checksum_algorithm=innodbinnodb_data_file_path=ibdata1:12M:autoextendinnodb_log_files_in_group=2innodb_log_file_size=50331648innodb_fast_checksum=falseinnodb_page_size=16384innodb_log_block_size=512innodb_undo_directory=.innodb_undo_tablespaces=0server_id=1

redo_log_version=0

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论