当前位置:   article > 正文

xtrabackup 全量备份、恢复数据

xtrabackup: starting shutdown with innodb_fast_shutdown = 1

1、全量备份

  1. [root@localhost lib]##innobackupex --defaults-file=$defaults_file --user=$mysql_username --password=$mysql_password --stream=tar $mysql_backup_dir | gzip - > $timeStart.bz.tar.gz 2> "$logfile"
  2. 备份目录/var/lib/mysqlsource,
  3. 如果下面要恢复,解压bz文件至该目录下面。

 2、恢复准备

[root@localhost lib]#mkdir mysql
  1. [root@localhost lib]# innobackupex --apply-log /var/lib/mysqlsource/
  2. 180712 15:22:51 innobackupex: Starting the apply-log operation
  3. IMPORTANT: Please check that the apply-log run completes successfully.
  4. At the end of a successful apply-log run innobackupex
  5. prints "completed OK!".
  6. innobackupex version 2.4.5 based on MySQL server 5.7.13 Linux (x86_64) (revision id: e41c0be)
  7. xtrabackup: cd to /var/lib/mysqlsource/
  8. xtrabackup: This target seems to be not prepared yet.
  9. InnoDB: Number of pools: 1
  10. xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(117069890525)
  11. xtrabackup: using the following InnoDB configuration for recovery:
  12. xtrabackup: innodb_data_home_dir = .
  13. xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
  14. xtrabackup: innodb_log_group_home_dir = .
  15. xtrabackup: innodb_log_files_in_group = 1
  16. xtrabackup: innodb_log_file_size = 8388608
  17. xtrabackup: using the following InnoDB configuration for recovery:
  18. xtrabackup: innodb_data_home_dir = .
  19. xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
  20. xtrabackup: innodb_log_group_home_dir = .
  21. xtrabackup: innodb_log_files_in_group = 1
  22. xtrabackup: innodb_log_file_size = 8388608
  23. xtrabackup: Starting InnoDB instance for recovery.
  24. xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
  25. InnoDB: PUNCH HOLE support available
  26. InnoDB: Mutexes and rw_locks use GCC atomic builtins
  27. InnoDB: Uses event mutexes
  28. InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  29. InnoDB: Compressed tables use zlib 1.2.7
  30. InnoDB: Number of pools: 1
  31. InnoDB: Using CPU crc32 instructions
  32. InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
  33. InnoDB: Completed initialization of buffer pool
  34. InnoDB: page_cleaner coordinator priority: -20
  35. InnoDB: Highest supported file format is Barracuda.
  36. InnoDB: Log scan progressed past the checkpoint lsn 117069890525
  37. InnoDB: Doing recovery: scanned up to log sequence number 117070116070 (3%)
  38. InnoDB: Database was not shutdown normally!
  39. InnoDB: Starting crash recovery.
  40. InnoDB: Starting an apply batch of log records to the database...
  41. InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
  42. InnoDB: Apply batch completed
  43. InnoDB: xtrabackup: Last MySQL binlog file position 466896958, file name mysql-bin.000360
  44. InnoDB: Creating shared tablespace for temporary tables
  45. InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  46. InnoDB: File './ibtmp1' size is now 12 MB.
  47. InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
  48. InnoDB: 32 non-redo rollback segment(s) are active.
  49. InnoDB: page_cleaner: 1000ms intended loop took 9422ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
  50. InnoDB: 5.7.13 started; log sequence number 117070116070
  51. InnoDB: xtrabackup: Last MySQL binlog file position 466896958, file name mysql-bin.000360
  52. xtrabackup: starting shutdown with innodb_fast_shutdown = 1
  53. InnoDB: FTS optimize thread exiting.
  54. InnoDB: Starting shutdown...
  55. InnoDB: Shutdown completed; log sequence number 117070116783
  56. InnoDB: Number of pools: 1
  57. xtrabackup: using the following InnoDB configuration for recovery:
  58. xtrabackup: innodb_data_home_dir = .
  59. xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend
  60. xtrabackup: innodb_log_group_home_dir = .
  61. xtrabackup: innodb_log_files_in_group = 2
  62. xtrabackup: innodb_log_file_size = 268435456
  63. InnoDB: PUNCH HOLE support available
  64. InnoDB: Mutexes and rw_locks use GCC atomic builtins
  65. InnoDB: Uses event mutexes
  66. InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  67. InnoDB: Compressed tables use zlib 1.2.7
  68. InnoDB: Number of pools: 1
  69. InnoDB: Using CPU crc32 instructions
  70. InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
  71. InnoDB: Completed initialization of buffer pool
  72. InnoDB: page_cleaner coordinator priority: -20
  73. InnoDB: Setting log file ./ib_logfile101 size to 256 MB
  74. InnoDB: Progress in MB:
  75. 100 200
  76. InnoDB: Setting log file ./ib_logfile1 size to 256 MB
  77. InnoDB: Progress in MB:
  78. 100 200
  79. InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
  80. InnoDB: New log files created, LSN=117070116783
  81. InnoDB: Highest supported file format is Barracuda.
  82. InnoDB: Log scan progressed past the checkpoint lsn 117070116876
  83. InnoDB: Doing recovery: scanned up to log sequence number 117070116885 (0%)
  84. InnoDB: Doing recovery: scanned up to log sequence number 117070116885 (0%)
  85. InnoDB: Database was not shutdown normally!
  86. InnoDB: Starting crash recovery.
  87. InnoDB: xtrabackup: Last MySQL binlog file position 466896958, file name mysql-bin.000360
  88. InnoDB: Removed temporary tablespace data file: "ibtmp1"
  89. InnoDB: Creating shared tablespace for temporary tables
  90. InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  91. InnoDB: File './ibtmp1' size is now 12 MB.
  92. InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active.
  93. InnoDB: 32 non-redo rollback segment(s) are active.
  94. InnoDB: page_cleaner: 1000ms intended loop took 6645ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
  95. InnoDB: 5.7.13 started; log sequence number 117070116885
  96. xtrabackup: starting shutdown with innodb_fast_shutdown = 1
  97. InnoDB: FTS optimize thread exiting.
  98. InnoDB: Starting shutdown...
  99. InnoDB: Shutdown completed; log sequence number 117070117601
  100. 180712 15:23:12 completed OK!

 3、开始恢复

  1. [root@localhost lib]# innobackupex --defaults-file=/etc/my.cnf --copy-back --rsync /var/lib/mysqlsource
  2. 180712 15:23:50 innobackupex: Starting the copy-back operation
  3. IMPORTANT: Please check that the copy-back run completes successfully.
  4. At the end of a successful copy-back run innobackupex
  5. prints "completed OK!".
  6. innobackupex version 2.4.5 based on MySQL server 5.7.13 Linux (x86_64) (revision id: e41c0be)
  7. 180712 15:23:50 [01] Copying ib_logfile0 to /var/lib/mysql/ib_logfile0
  8. 180712 15:23:52 [01] ...done
  9. 180712 15:23:53 [01] Copying ib_logfile1 to /var/lib/mysql/ib_logfile1
  10. 180712 15:23:55 [01] ...done
  11. 180712 15:23:55 [01] Copying ibdata1 to /var/lib/mysql/ibdata1
  12. 180712 15:23:59 [01] ...done
  13. 180712 15:23:59 [01] Copying ./2018712013001.bz.tar.gz to /var/lib/mysql/2018712013001.bz.tar.gz
  14. 180712 15:25:02 [01] ...done
  15. 180712 15:25:03 [01] Copying ./vehicle_gps/tb_bas_gps_vendor.ibd to /var/lib/mysql/vehicle_gps/tb_bas_gps_vendor.ibd
  16. 180712 15:25:03 [01] ...done
  17. 180712 15:25:03 [01] Copying ./vehicle_gps/tb_gps_info.ibd to /var/lib/mysql/vehicle_gps/tb_gps_info.ibd
  18. 180712 15:25:03 [01] ...done
  19. 180712 15:25:03 [01] Copying ./vehicle_gps/tb_gps_alarm_info.ibd to /var/lib/mysql/vehicle_gps/tb_gps_alarm_info.ibd
  20. 180712 15:25:03 [01] ...done
  21. 180712 15:40:55 [01] ...done
  22. 180712 15:40:55 [01] Copying ./ib_buffer_pool to /var/lib/mysql/ib_buffer_pool
  23. 180712 15:40:55 [01] ...done
  24. 180712 15:40:55 [01] Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info
  25. 180712 15:40:55 [01] ...done
  26. 180712 15:40:55 [01] Copying ./xtrabackup_binlog_pos_innodb to /var/lib/mysql/xtrabackup_binlog_pos_innodb
  27. 180712 15:40:55 [01] ...done
  28. 180712 15:40:55 [01] Copying ./ibtmp1 to /var/lib/mysql/ibtmp1
  29. 180712 15:40:55 [01] ...done
  30. 180712 15:40:55 completed OK!

 

4、更改mysql目录属性

[root@localhost lib]# chown -R mysql.mysql mysql

 5、启动mysql

  1. [root@localhost mysql]# service mysqld start
  2. Redirecting to /bin/systemctl start mysqld.service
  3. [root@localhost mysql]# service mysqld status
  4. Redirecting to /bin/systemctl status mysqld.service
  5. ● mysqld.service - MySQL Server
  6. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  7. Active: active (running) since Thu 2018-07-12 15:42:17 CST; 10s ago
  8. Docs: man:mysqld(8)
  9. http://dev.mysql.com/doc/refman/en/using-systemd.html
  10. Process: 127987 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  11. Process: 127908 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  12. Main PID: 127995 (mysqld)
  13. CGroup: /system.slice/mysqld.service
  14. └─127995 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  15. Jul 12 15:41:40 localhost.localdomain systemd[1]: Starting MySQL Server...
  16. Jul 12 15:42:17 localhost.localdomain systemd[1]: Started MySQL Server.

 扩展阅读:

转载于:https://www.cnblogs.com/growithus/p/11012170.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/522292
推荐阅读
相关标签
  

闽ICP备14008679号