返回顶部
首页 > 资讯 > 数据库 >使用xtrabackup工具实现mysql的多实例备份和还原
  • 477
分享到

使用xtrabackup工具实现mysql的多实例备份和还原

2024-04-02 19:04:59 477人浏览 独家记忆
摘要

下面讲讲关于使用xtrabackup工具实现Mysql的多实例备份和还原,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完使用xtrabackup工具实现mysql的多实例备份和还

下面讲讲关于使用xtrabackup工具实现Mysql的多实例备份和还原,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完使用xtrabackup工具实现mysql的多实例备份和还原这篇文章你一定会有所受益。

1、安装percona-xtrabackup

# 下载安装包:

# cd /usr/local/src
# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.3.2/binary/redhat/6/x86_64/percona-xtrabackup-2.3.2-1.el6.x86_64.rpm

# 安装依赖库:

# yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-Mysql
# wget ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/libev-4.15-1.el6.rf.x86_64.rpm 
# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
# rpm -ivh percona-xtrabackup-2.3.2-1.el6.x86_64.rpm

# 创建备份的目录:

# mkdir -p /databackup/fullbackup
# mkdir -p /databackup/increasebackup

# 创建备份用户和授权:

mysql>grant SELECT,RELOAD,SHOW DATABASES,SUPER,LOCK TABLES,REPLICATION CLIENT,SHOW VIEW,EVENT,FILE on *.* to backup@'localhost' identified by 'MANAGER';

2、 备份3306实例:

# innobackupex --defaults-file=/data/3306/my.cnf --Socket=/data/3306/mysql.sock --user=backup --passWord='MANAGER' /mysqlbackup/fullbackup/3306

说明:
--defaults-file,指定mysql实例的配置文件
--socket,指定socket的位置
--user,指定备份的用户
--password,指定用户名称
/mysqlbackup/fullbackup/3306,这里我们将实例备份到/mysqlbackup/fullbackup/3306目录下

# du -sh /mysqlbackup/fullbackup/3306
130M /mysqlbackup/fullbackup/3306
# ls -lrt /mysqlbackup/fullbackup/3306/*
总用量 131136
-rw-r----- 1 root root 134217728 10月 12 04:32 ibdata1
drwx------ 2 root root      4096 10月 12 04:32 james
drwx------ 2 root root      4096 10月 12 04:32 ems
drwx------ 2 root root      4096 10月 12 04:32 mysql
drwx------ 2 root root      4096 10月 12 04:32 perfORMance_schema
drwx------ 2 root root      4096 10月 12 04:32 wh510
drwx------ 2 root root      4096 10月 12 04:32 www
drwx------ 2 root root      4096 10月 12 04:32 blog
drwx------ 2 root root      4096 10月 12 04:32 opark
drwx------ 2 root root      4096 10月 12 04:32 dawnpro
drwx------ 2 root root      4096 10月 12 04:32 eip
drwx------ 2 root root      4096 10月 12 04:32 hangzhou_dawnpro
-rw-r----- 1 root root        21 10月 12 04:32 xtrabackup_binlog_info
-rw-r----- 1 root root      2560 10月 12 04:32 xtrabackup_logfile
-rw-r----- 1 root root       113 10月 12 04:32 xtrabackup_checkpoints
-rw-r----- 1 root root       386 10月 12 04:32 backup-my.cnf
-rw-r----- 1 root root       551 10月 12 04:32 xtrabackup_info

3、模拟3306数据文件丢失

# rm -rf /data/3306/data
# lsof -i :3306

说明:此时数据库已经没法正常运行,检查错误日志,发现没有了data目录
161012 04:40:35 mysqld_safe mysqld from pid file /data/3306/mysqld.pid ended
161012 04:42:10 mysqld_safe Starting mysqld daemon with databases from /data/3306/data
161012  4:42:10 [Warning] Can't create test file /data/3306/data/mysql-master.lower-test
161012  4:42:10 [Warning] Can't create test file /data/3306/data/mysql-master.lower-test
/application/mysql-5.5.32/bin/mysqld: Can't change dir to '/data/3306/data/' (Errcode: 2)
161012  4:42:10 [ERROR] Aborting

161012  4:42:10 [Note] /application/mysql-5.5.32/bin/mysqld: Shutdown complete

161012 04:42:10 mysqld_safe mysqld from pid file /data/3306/mysqld.pid ended

4、mysql全备数据恢复:
# mkdir -p /data/3306/data
# 对于一般恢复,都是直接用备份文件还原,如果我们这里也是直接运用该备份文件,则可能会导致一些意想不到的问题,比如:备份的数据中可能会包含尚未提交的事务或已经提交但尚未同步至数据文件中的事务。因此,此时数据文件处于不一致的状态,我们现在就是要通过回滚未提交的事务及同步已经提交的事务至数据文件也使得数据文件处于一致性状态。所以我们要用如下命令进行检查:

# innobackupex  --apply-log --redo-only /mysqlbackup/fullbackup/3306/2016-10-12_04-32-49/

161012 04:53:07 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.3.2 based on MySQL Server 5.6.24 Linux (x86_64) (revision id: 306a2e0)
xtrabackup: cd to /mysqlbackup/fullbackup/3306/2016-10-12_04-32-49/
xtrabackup: This target seems to be already prepared with --apply-log-only.
xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
xtrabackup: using the following InnoDB configuration for recovery:
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 = 50331648
xtrabackup: using the following InnoDB configuration for recovery:
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 = 50331648
xtrabackup: Starting InnoDB instance for recovery.
xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
InnoDB: Using atomics to ref count buffer pool pages
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Memory barrier is not used
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Using CPU crc32 instructions
InnoDB: Initializing buffer pool, size = 100.0M
InnoDB: Completed initialization of buffer pool
InnoDB: Highest supported file format is Barracuda.
xtrabackup: Last MySQL binlog file position 2442, file name /data/3306/mysql-bin.000008

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: Starting shutdown...
InnoDB: Shutdown completed; log sequence number 1606678
161012 04:53:08 completed OK!

# innobackupex --defaults-file=/data/3306/my.cnf --copy-back /mysqlbackup/fullbackup/3306/2016-10-12_04-32-49/
161012 04:56:32 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.3.2 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 306a2e0)
161012 04:56:32 [01] Copying ib_logfile0 to /data/3306/data/ib_logfile0
161012 04:56:33 [01]        ...done
161012 04:56:33 [01] Copying ib_logfile1 to /data/3306/data/ib_logfile1
161012 04:56:34 [01]        ...done
161012 04:56:34 [01] Copying ibdata1 to /data/3306/data/ibdata1
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./james/db.opt to /data/3306/data/james/db.opt
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./ems/db.opt to /data/3306/data/ems/db.opt
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/func.MYD to /data/3306/data/mysql/func.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/time_zone.MYD to /data/3306/data/mysql/time_zone.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/help_topic.MYD to /data/3306/data/mysql/help_topic.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/tables_priv.MYI to /data/3306/data/mysql/tables_priv.MYI
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/db.MYD to /data/3306/data/mysql/db.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/proc.frm to /data/3306/data/mysql/proc.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/help_relation.MYI to /data/3306/data/mysql/help_relation.MYI
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/proxies_priv.MYI to /data/3306/data/mysql/proxies_priv.MYI
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/func.frm to /data/3306/data/mysql/func.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/plugin.MYD to /data/3306/data/mysql/plugin.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/user.frm to /data/3306/data/mysql/user.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/time_zone_transition.MYD to /data/3306/data/mysql/time_zone_transition.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/time_zone_transition_type.MYD to /data/3306/data/mysql/time_zone_transition_type.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/general_log.CSV to /data/3306/data/mysql/general_log.CSV
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/event.MYI to /data/3306/data/mysql/event.MYI
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/time_zone_leap_second.frm to /data/3306/data/mysql/time_zone_leap_second.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/help_relation.frm to /data/3306/data/mysql/help_relation.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/ndb_binlog_index.MYD to /data/3306/data/mysql/ndb_binlog_index.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/procs_priv.frm to /data/3306/data/mysql/procs_priv.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/db.frm to /data/3306/data/mysql/db.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/event.frm to /data/3306/data/mysql/event.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/plugin.MYI to /data/3306/data/mysql/plugin.MYI
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/help_cateGory.frm to /data/3306/data/mysql/help_category.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/time_zone_name.MYD to /data/3306/data/mysql/time_zone_name.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/event.MYD to /data/3306/data/mysql/event.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/proc.MYI to /data/3306/data/mysql/proc.MYI
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/tables_priv.MYD to /data/3306/data/mysql/tables_priv.MYD
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/servers.frm to /data/3306/data/mysql/servers.frm
161012 04:56:36 [01]        ...done
161012 04:56:36 [01] Copying ./mysql/time_zone_leap_second.MYI to /data/3306/data/mysql/time_zone_leap_second.MYI
161012 04:56:36 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/proxies_priv.MYD to /data/3306/data/mysql/proxies_priv.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/procs_priv.MYI to /data/3306/data/mysql/procs_priv.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone.MYI to /data/3306/data/mysql/time_zone.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/slow_log.CSV to /data/3306/data/mysql/slow_log.CSV
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_transition.frm to /data/3306/data/mysql/time_zone_transition.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/procs_priv.MYD to /data/3306/data/mysql/procs_priv.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_topic.MYI to /data/3306/data/mysql/help_topic.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/user.MYI to /data/3306/data/mysql/user.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_keyword.MYD to /data/3306/data/mysql/help_keyword.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/db.MYI to /data/3306/data/mysql/db.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/func.MYI to /data/3306/data/mysql/func.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/servers.MYI to /data/3306/data/mysql/servers.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_category.MYD to /data/3306/data/mysql/help_category.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/host.MYI to /data/3306/data/mysql/host.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone.frm to /data/3306/data/mysql/time_zone.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_category.MYI to /data/3306/data/mysql/help_category.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/proxies_priv.frm to /data/3306/data/mysql/proxies_priv.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/general_log.frm to /data/3306/data/mysql/general_log.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_keyword.frm to /data/3306/data/mysql/help_keyword.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/proc.MYD to /data/3306/data/mysql/proc.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/columns_priv.MYI to /data/3306/data/mysql/columns_priv.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/slow_log.frm to /data/3306/data/mysql/slow_log.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_topic.frm to /data/3306/data/mysql/help_topic.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_keyword.MYI to /data/3306/data/mysql/help_keyword.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_name.MYI to /data/3306/data/mysql/time_zone_name.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/host.MYD to /data/3306/data/mysql/host.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/columns_priv.MYD to /data/3306/data/mysql/columns_priv.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/user.MYD to /data/3306/data/mysql/user.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/ndb_binlog_index.frm to /data/3306/data/mysql/ndb_binlog_index.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/tables_priv.frm to /data/3306/data/mysql/tables_priv.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/general_log.CSM to /data/3306/data/mysql/general_log.CSM
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_leap_second.MYD to /data/3306/data/mysql/time_zone_leap_second.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/servers.MYD to /data/3306/data/mysql/servers.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/host.frm to /data/3306/data/mysql/host.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_name.frm to /data/3306/data/mysql/time_zone_name.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/help_relation.MYD to /data/3306/data/mysql/help_relation.MYD
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_transition.MYI to /data/3306/data/mysql/time_zone_transition.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/slow_log.CSM to /data/3306/data/mysql/slow_log.CSM
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/ndb_binlog_index.MYI to /data/3306/data/mysql/ndb_binlog_index.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/columns_priv.frm to /data/3306/data/mysql/columns_priv.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_transition_type.MYI to /data/3306/data/mysql/time_zone_transition_type.MYI
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/time_zone_transition_type.frm to /data/3306/data/mysql/time_zone_transition_type.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./mysql/plugin.frm to /data/3306/data/mysql/plugin.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/events_waits_summary_by_instance.frm to /data/3306/data/performance_schema/events_waits_summary_by_instance.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/file_instances.frm to /data/3306/data/performance_schema/file_instances.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/performance_timers.frm to /data/3306/data/performance_schema/performance_timers.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/file_summary_by_event_name.frm to /data/3306/data/performance_schema/file_summary_by_event_name.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/events_waits_summary_by_thread_by_event_name.frm to /data/3306/data/performance_schema/events_waits_summary_by_thread_by_event_name.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/events_waits_current.frm to /data/3306/data/performance_schema/events_waits_current.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/setup_instruments.frm to /data/3306/data/performance_schema/setup_instruments.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/threads.frm to /data/3306/data/performance_schema/threads.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/file_summary_by_instance.frm to /data/3306/data/performance_schema/file_summary_by_instance.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/events_waits_history.frm to /data/3306/data/performance_schema/events_waits_history.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/rwlock_instances.frm to /data/3306/data/performance_schema/rwlock_instances.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/setup_consumers.frm to /data/3306/data/performance_schema/setup_consumers.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/setup_timers.frm to /data/3306/data/performance_schema/setup_timers.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/events_waits_summary_global_by_event_name.frm to /data/3306/data/performance_schema/events_waits_summary_global_by_event_name.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/mutex_instances.frm to /data/3306/data/performance_schema/mutex_instances.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/events_waits_history_long.frm to /data/3306/data/performance_schema/events_waits_history_long.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/cond_instances.frm to /data/3306/data/performance_schema/cond_instances.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./performance_schema/db.opt to /data/3306/data/performance_schema/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./wh510/db.opt to /data/3306/data/wh510/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./www/db.opt to /data/3306/data/www/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./xtrabackup_info to /data/3306/data/xtrabackup_info
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./blog/db.opt to /data/3306/data/blog/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./xtrabackup_binlog_pos_innodb to /data/3306/data/xtrabackup_binlog_pos_innodb
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./opark/person.frm to /data/3306/data/opark/person.frm
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./opark/db.opt to /data/3306/data/opark/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./dawnpro/db.opt to /data/3306/data/dawnpro/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./eip/db.opt to /data/3306/data/eip/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 [01] Copying ./hangzhou_dawnpro/db.opt to /data/3306/data/hangzhou_dawnpro/db.opt
161012 04:56:37 [01]        ...done
161012 04:56:37 completed OK!
说明:innobackup的copy-back用于执行恢复操作时,它是通过复制所有数据相关文件至MySQL数据目录,因此,需要清空数据目录。

[root@mysql-master data]# ll /data/3306/data
总用量 229432
drwx------ 2 root root      4096 10月 12 04:56 blog
drwx------ 2 root root      4096 10月 12 04:56 dawnpro
drwx------ 2 root root      4096 10月 12 04:56 eip
drwx------ 2 root root      4096 10月 12 04:56 ems
drwx------ 2 root root      4096 10月 12 04:56 hangzhou_dawnpro
-rw-r----- 1 root root 134217728 10月 12 04:56 ibdata1
-rw-r----- 1 root root  50331648 10月 12 04:56 ib_logfile0
-rw-r----- 1 root root  50331648 10月 12 04:56 ib_logfile1
drwx------ 2 root root      4096 10月 12 04:56 james
drwx------ 2 root root      4096 10月 12 04:56 mysql
drwx------ 2 root root      4096 10月 12 04:56 opark
drwx------ 2 root root      4096 10月 12 04:56 performance_schema
drwx------ 2 root root      4096 10月 12 04:56 wh510
drwx------ 2 root root      4096 10月 12 04:56 www
-rw-r----- 1 root root        33 10月 12 04:56 xtrabackup_bin

5、更改数据库目录权限

# chown -R mysql.mysql /data/3306/data

6、开启mysql服务

启动mysql发现没法起来,检查日志信息如下(InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes):
# tail -15 mysql_oldboy3306.err
161012  5:00:15 InnoDB: Mutexes and rw_locks use GCC atomic builtins
161012  5:00:15 InnoDB: Compressed tables use zlib 1.2.3
161012  5:00:15 InnoDB: Using Linux native AIO
161012  5:00:15 InnoDB: Initializing buffer pool, size = 32.0M
161012  5:00:15 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 4194304 bytes!
161012  5:00:15 [ERROR] Plugin 'InnoDB' init function returned error.
161012  5:00:15 [ERROR] Plugin 'InnoDB' reGIStration as a STORAGE ENGINE failed.
161012  5:00:15 [ERROR] Unknown/unsupported storage engine: InnoDB
161012  5:00:15 [ERROR] Aborting

161012  5:00:15 [Note] /application/mysql-5.5.32/bin/mysqld: Shutdown complete

161012 05:00:15 mysqld_safe mysqld from pid file /data/3306/mysqld.pid ended

# rm ib_logfile* -rf
# /data/3306/mysql start
# netstat -tuNLP| grep 3306
tcp        0      0 0.0.0.0:3306      0.0.0.0:*               LISTEN      29697/mysqld

7、进入数据库进行验证

# mysql -uroot -predhat12345 -S /data/3306/mysql.sock
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| blog               |
| dawnpro            |
| eip                |
| ems                |
| hangzhou_dawnpro   |
| james              |
| mysql              |
| opark              |
| performance_schema |
| wh510              |
| www                |
+--------------------+

12 rows in set (0.01 sec)

对于以上使用xtrabackup工具实现mysql的多实例备份和还原相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的数据库板块。

您可能感兴趣的文档:

--结束END--

本文标题: 使用xtrabackup工具实现mysql的多实例备份和还原

本文链接: https://lsjlt.com/news/35504.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • 使用xtrabackup工具实现mysql的多实例备份和还原
    下面讲讲关于使用xtrabackup工具实现mysql的多实例备份和还原,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完使用xtrabackup工具实现mysql的多实例备份和还...
    99+
    2024-04-02
  • 基于xtrabackup实现数据备份还原——高效的数据备份还原工具
    准备一个干净的备份目录;[root@mysql ~]$ll /backups/ total 0 MariaDB [(none)]> show&nbs...
    99+
    2024-04-02
  • 【MySQL】Xtrabackup备份工具使用
    简介: Xtrabackup是由percona提供的mysql数据库备份工具,支持在线热备份(备份时不影响数据读写).Xtrabackup有两个主要的工具:xtrabackup、innobackupex1...
    99+
    2024-04-02
  • 如何使用xtrabackup备份和还原mysql
    这篇文章给大家介绍如何使用xtrabackup备份和还原mysql,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。1、安装percona-xtrabackup# 下载安装包:# ...
    99+
    2024-04-02
  • 使用xtrabackup工具实现对MySQL数据库备份
    下文给大家带来有关使用xtrabackup工具实现对MySQL数据库备份内容,相信大家一定看过类似的文章。我们给大家带来的有何不同呢?一起来看看正文部分吧,相信看完使用xtrabackup工具实现对MySQ...
    99+
    2024-04-02
  • MySQL Xtrabackup备份原理和实现细节
    备份原理: XtraBackup基于InnoDB的crash-recovery功能。它会复制innodb的data file,由于不锁表,复制出来的数据是不一致的,在恢复的时候使用crash-recover...
    99+
    2024-04-02
  • MySQL之xtrabackup备份恢复的实现
    目录1、安装xtrabackup2、备份2.1、做一次全备2.2、进入mysql添加数据2.3、做一次增备2.4、删除数据库(千万不要在生产库执行!!!)3、恢复3.1、准备阶段3.2、模仿数据库丢失,停掉服务3.3、恢...
    99+
    2023-02-03
    MySQLxtrabackup备份恢复 MySQL备份恢复
  • 使用xtrabackup工具如何热备和恢复mysql
    下文主要给大家带来使用xtrabackup工具如何热备和恢复mysql,希望这些内容能够带给大家实际用处,这也是我编辑使用xtrabackup工具如何热备和恢复mysql这篇文章的主要目的。好了,废话不多说...
    99+
    2024-04-02
  • 批处理如何实现oracle数据库备份还原工具
    这篇文章主要介绍了批处理如何实现oracle数据库备份还原工具,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。这是针对oracle编写的,可以用在不同的电脑上,因为它会自动读取...
    99+
    2023-06-08
  • 使用mysqldump工具实现备份mysql命令方法
    下面一起来了解下使用mysqldump工具实现备份mysql命令方法,相信大家看完肯定会受益匪浅,文字在精不在多,希望使用mysqldump工具实现备份mysql命令方法这篇短内容是你想要的。mysqldu...
    99+
    2024-04-02
  • IIS中实现备份和还原的方法
    小编给大家分享一下IIS中实现备份和还原的方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!备份 IIS 配置若要备份 IIS&nb...
    99+
    2023-06-14
  • Mysql数据库中怎么实现备份和还原
    这期内容当中小编将会给大家带来有关Mysql数据库中怎么实现备份和还原,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。  1、备份MySQL数据库的命令 双击代码全选...
    99+
    2024-04-02
  • Win10怎么使用自带DISM部署工具备份和还原驱动
    小编给大家分享一下Win10怎么使用自带DISM部署工具备份和还原驱动,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!如果你当前的Win10系统都已经安装了合适的驱...
    99+
    2023-06-14
  • MySQL学习——使用mysqldump命令备份和还原
    MySQL学习——使用mysqldump命令备份和还原 摘要:本文主要学习了如何使用mysqldump命令备份和还原数据库。 导出数据 导出全部数据 参数: 1 --all-databases, -A 举例: 1 mysqldump ...
    99+
    2021-02-14
    MySQL学习——使用mysqldump命令备份和还原
  • 如何在 PHP 中使用 MySQL 备份和还原?
    在 php 中备份和还原 mysql 数据库可通过以下步骤实现:备份数据库:使用 mysqldump 命令转储数据库为 sql 文件。还原数据库:使用 mysql 命令从 sql 文件还...
    99+
    2024-05-12
    mysql 备份 还原
  • mysql使用mysqld_multi工具启动多实例
    先给出实验环境/etc/my.cnf文件内容 修改内容为: 添加了[mysqld_multi]标签和多出来两个数据库的标签[mysqld3307]和[mysqld3308] 配置完成后启动方法,举一例: m...
    99+
    2024-04-02
  • Mysql数据库中怎么实现备份与还原
    这篇文章给大家介绍Mysql数据库中怎么实现备份与还原,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。import java.io.IOException;import java.tex...
    99+
    2024-04-02
  • 怎么在MySQL中实现数据备份与还原
    本篇文章为大家展示了怎么在MySQL中实现数据备份与还原,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。一、数据备份1、使用mysqldump命令备份mysqldum...
    99+
    2024-04-02
  • 如何实现alwayson的备份还原脚本
    这篇文章主要介绍如何实现alwayson的备份还原脚本,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完! 1、 备份数据库 在主副本上,将需要做AlwaysOn的数据库做一次全备和日...
    99+
    2024-04-02
  • 用Mysqldump实现全库备份+binlog的数据还原
      随着业务量的增长,数据库也是成倍增长,原来一直使用的全库备份不再适合现在的数据库了,动辄就备份10G-20G,太占用磁盘空间,所以就考虑用更简洁更快速更节省磁盘空间的备份方法,这就想到了使用b...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作