mysqldumper 與 Innobackupex的備份和恢復操作實驗過程
一、mysqldumper
1.1 mysqldumper 編譯安裝
wget https://launchpadlibrarian.net/185032423/mydumper-0.6.2.tar.gz
[[email protected] tang]# tar -zxvf mydumper-0.6.2.tar.gz
[[email protected] tang]# cd mydumper-0.6.2
[[email protected] mydumper-0.6.2]# yum install pcre-devel.x86_64
[
[[email protected] mydumper-0.6.2]# cd bin
[[email protected] bin]# cmake ../
報錯,提示沒有支援包:
-- checking for one of the modules 'glib-2.0'
-- checking for one of the modules 'gthread-2.0'
檢視官方介紹
https://answers.launchpad.net/mydumper/+faq/349
找到:
Ubuntu or Debian: apt-get install libglib2.0-dev libmysqlclient15-dev zlib1g-dev libpcre3-dev libssl-dev
安裝支援包:
yum install glib2-devel mysql-devel zlib-devel pcre-devel openssl-devel
[
-- Using mysql-config: /usr/local/mysql/bin/mysql_config
-- Found MySQL: /usr/local/mysql/include, /usr/local/mysql/lib/libmysqlclient.so;/usr/lib64/libpthread.so;/usr/lib64/libm.so;/usr/lib64/librt.so;/usr/lib64/libdl.so
CMake Warning at docs/CMakeLists.txt:9 (message):
Unable to find Sphinx documentation generator
-- ------------------------------------------------
-- MYSQL_CONFIG = /usr/local/mysql/bin/mysql_config
-- CMAKE_INSTALL_PREFIX = /usr/local
-- BUILD_DOCS = ON
-- WITH_BINLOG = OFF
-- RUN_CPPCHECK = OFF
-- Change a values with: cmake -D<Variable>=<Value>
-- ------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/mydumper0.6.2/bin
[
Scanning dependencies of target mydumper
[ 25%] Building C object CMakeFiles/mydumper.dir/mydumper.c.o
[ 50%] Building C object CMakeFiles/mydumper.dir/server_detect.c.o
[ 75%] Building C object CMakeFiles/mydumper.dir/g_unix_signal.c.o
Linking C executable mydumper
[ 75%] Built target mydumper
Scanning dependencies of target myloader
[100%] Building C object CMakeFiles/myloader.dir/myloader.c.o
Linking C executable myloader
[100%] Built target myloader
[[email protected] bin]#
[[email protected] bin]# make install
[ 75%] Built target mydumper
[100%] Built target myloader
Linking C executable CMakeFiles/CMakeRelink.dir/mydumper
Linking C executable CMakeFiles/CMakeRelink.dir/myloader
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/mydumper
-- Installing: /usr/local/bin/myloader
[[email protected] bin]#
[[email protected] bin]# ll -rth mydumper myloader
-rwxr-xr-x 1 root root 143K Feb 27 16:00 mydumper
-rwxr-xr-x 1 root root 48K Feb 27 16:00 myloader
[[email protected] bin]#
1.2 備份全庫
[[email protected] bin]# ./mydumper -u root -p sa123 -S /tmp/mysql3306.sock -o /opt/backup/all_database_0227.dmp備份出來的sql 檔案,是以資料開關.表名[-schema].sql 為名。有帶[-schema]的為表結構建立語句,沒有的
為表資料插入語句。
[[email protected] bin]# ll /opt/backup/all_database_0227.dmp/
total 768
-rw-r--r-- 1 root root 200 Feb 27 16:37 erp.order-schema.sql
-rw-r--r-- 1 root root 393 Feb 27 16:37 erp.refundorder-schema.sql
-rw-r--r-- 1 root root 191 Feb 27 16:37 erp.test1-schema.sql
-rw-r--r-- 1 root root 236 Feb 27 16:37 erp.test1.sql
-rw-r--r-- 1 root root 238 Feb 27 16:37 erp.test2-schema.sql
-rw-r--r-- 1 root root 188 Feb 27 16:37 jfedu.t1-schema.sql
-rw-r--r-- 1 root root 193 Feb 27 16:37 jfedu.t1.sql
-rw-r--r-- 1 root root 130 Feb 27 16:37 metadata
-rw-r--r-- 1 root root 722 Feb 27 16:37 mysql.columns_priv-schema.sql
-rw-r--r-- 1 root root 1783 Feb 27 16:37 mysql.db-schema.sql
-rw-r--r-- 1 root root 513 Feb 27 16:37 mysql.db.sql
-rw-r--r-- 1 root root 2210 Feb 27 16:37 mysql.event-schema.sql
-rw-r--r-- 1 root root 419 Feb 27 16:37 mysql.func-schema.sql
-rw-r--r-- 1 root root 388 Feb 27 16:37 mysql.help_category-schema.sql
-rw-r--r-- 1 root root 1373 Feb 27 16:37 mysql.help_category.sql
-rw-r--r-- 1 root root 298 Feb 27 16:37 mysql.help_keyword-schema.sql
-rw-r--r-- 1 root root 11410 Feb 27 16:37 mysql.help_keyword.sql
-rw-r--r-- 1 root root 311 Feb 27 16:37 mysql.help_relation-schema.sql
-rw-r--r-- 1 root root 13223 Feb 27 16:37 mysql.help_relation.sql
-rw-r--r-- 1 root root 423 Feb 27 16:37 mysql.help_topic-schema.sql
-rw-r--r-- 1 root root 591208 Feb 27 16:37 mysql.help_topic.sql
-rw-r--r-- 1 root root 712 Feb 27 16:37 mysql.innodb_index_stats-schema.sql
-rw-r--r-- 1 root root 1682 Feb 27 16:37 mysql.innodb_index_stats.sql
-rw-r--r-- 1 root root 578 Feb 27 16:37 mysql.innodb_table_stats-schema.sql
-rw-r--r-- 1 root root 372 Feb 27 16:37 mysql.innodb_table_stats.sql
-rw-r--r-- 1 root root 592 Feb 27 16:37 mysql.ndb_binlog_index-schema.sql
-rw-r--r-- 1 root root 259 Feb 27 16:37 mysql.plugin-schema.sql
-rw-r--r-- 1 root root 1929 Feb 27 16:37 mysql.proc-schema.sql
-rw-r--r-- 1 root root 820 Feb 27 16:37 mysql.procs_priv-schema.sql
-rw-r--r-- 1 root root 708 Feb 27 16:37 mysql.proxies_priv-schema.sql
-rw-r--r-- 1 root root 240 Feb 27 16:37 mysql.proxies_priv.sql
-rw-r--r-- 1 root root 567 Feb 27 16:37 mysql.servers-schema.sql
-rw-r--r-- 1 root root 2805 Feb 27 16:37 mysql.slave_master_info-schema.sql
-rw-r--r-- 1 root root 1122 Feb 27 16:37 mysql.slave_relay_log_info-schema.sql
-rw-r--r-- 1 root root 907 Feb 27 16:37 mysql.slave_worker_info-schema.sql
-rw-r--r-- 1 root root 916 Feb 27 16:37 mysql.tables_priv-schema.sql
-rw-r--r-- 1 root root 302 Feb 27 16:37 mysql.time_zone_leap_second-schema.sql
-rw-r--r-- 1 root root 258 Feb 27 16:37 mysql.time_zone_name-schema.sql
-rw-r--r-- 1 root root 300 Feb 27 16:37 mysql.time_zone-schema.sql
-rw-r--r-- 1 root root 359 Feb 27 16:37 mysql.time_zone_transition-schema.sql
-rw-r--r-- 1 root root 471 Feb 27 16:37 mysql.time_zone_transition_type-schema.sql
-rw-r--r-- 1 root root 3140 Feb 27 16:37 mysql.user-schema.sql
-rw-r--r-- 1 root root 2018 Feb 27 16:37 mysql.user.sql
[[email protected] bin]#
metadata這個檔案記錄的是當裡的binlog檔案及pos,可以使用這個資訊搭建slave.
[[email protected] bin]# cat /opt/backup/all_database_0227.dmp/metadata
Started dump at: 2017-02-27 16:37:52
SHOW MASTER STATUS:
Log: mysql-bin.000006
Pos: 6487
Finished dump at: 2017-02-27 16:37:52
[[email protected] bin]#
二、誤操作truncate table gyj_t1;利用mysqldump的備份和binlog日誌對錶gyj_t1做完全恢復
2.1 備份前檢視binlog檔案。
[[email protected] ~]# ll /opt/mysql/data
total 123012
-rw-r----- 1 mysql mysql 56 Feb 24 00:32 auto.cnf
drwxr-x--- 2 mysql mysql 4096 Feb 28 00:32 erp
-rw-r----- 1 mysql mysql 453 Feb 28 01:54 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Feb 28 01:55 ibdata1
-rw-r----- 1 mysql mysql 50331648 Feb 28 01:55 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Feb 24 00:32 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 Feb 28 18:38 ibtmp1
drwxr-x--- 2 mysql mysql 4096 Feb 28 00:45 jfedu
-rw-r----- 1 mysql mysql 130 Feb 28 18:38 master.info
drwxr-x--- 2 mysql mysql 4096 Feb 24 01:05 mysql
-rw-r----- 1 mysql mysql 201 Feb 28 18:38 mysql-bin.000001
-rw-r----- 1 mysql mysql 201 Feb 28 18:38 mysql-bin.000002
-rw-r----- 1 mysql mysql 154 Feb 28 18:38 mysql-bin.000003
-rw-r----- 1 mysql mysql 10199 Feb 28 19:20 mysql-bin.000004
-rw-r----- 1 mysql mysql 5131 Feb 28 19:27 mysql-bin.000005
-rw-r----- 1 mysql mysql 4331 Mar 1 14:00 mysql-bin.000006
-rw-r----- 1 mysql mysql 5321 Mar 1 14:31 mysql-bin.000007
-rw-r----- 1 mysql mysql 57 Feb 28 18:38 mysql-bin.index
-rw-rw---- 1 root root 6 Feb 28 01:55 mysqld_safe.pid
drwxr-x--- 2 mysql mysql 4096 Feb 24 00:32 performance_schema
-rw-r----- 1 mysql mysql 61 Feb 28 18:38 relay-log.info
-rw-r----- 1 mysql mysql 42355 Feb 28 18:31 sdw2.err
-rw-r----- 1 mysql mysql 6 Feb 28 01:55 sdw2.pid
-rw-r----- 1 mysql mysql 325 Feb 28 18:38 sdw2-relay-bin.000020
-rw-r----- 1 mysql mysql 273 Feb 28 18:38 sdw2-relay-bin.000021
-rw-r----- 1 mysql mysql 48 Feb 28 18:38 sdw2-relay-bin.index
drwxr-x--- 2 mysql mysql 12288 Feb 24 00:32 sys
drwxr-x--- 2 mysql mysql 4096 Feb 24 01:05 test
[[email protected] ~]#
2.2 備份
[[email protected] ~]# mysqldump -uroot -p -l -F -S /tmp/mysql3310.sock jfedu > /tmp/0301jfedu.dmpEnter password:
[[email protected] ~]# ll /tmp/0301jfedu.dmp
-rw-r--r-- 1 root root 2464 Feb 28 18:38 /tmp/0301jfedu.dmp
2.3 備份完成後,檢視 binlog生成的新檔案 mysql-bin.000008
[[email protected] ~]# ll /opt/mysql/data/total 188592
-rw-r----- 1 mysql mysql 56 Feb 24 00:32 auto.cnf
drwxr-x--- 2 mysql mysql 4096 Mar 1 14:12 erp
-rw-r----- 1 mysql mysql 453 Feb 28 01:54 ib_buffer_pool
-rw-r----- 1 mysql mysql 79691776 Mar 1 14:18 ibdata1
-rw-r----- 1 mysql mysql 50331648 Mar 1 14:18 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Feb 24 00:32 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 Mar 1 14:31 ibtmp1
drwxr-x--- 2 mysql mysql 4096 Feb 28 19:23 jfedu
-rw-r----- 1 mysql mysql 130 Mar 1 14:31 master.info
drwxr-x--- 2 mysql mysql 4096 Feb 24 01:05 mysql
-rw-r----- 1 mysql mysql 201 Feb 28 18:38 mysql-bin.000001
-rw-r----- 1 mysql mysql 201 Feb 28 18:38 mysql-bin.000002
-rw-r----- 1 mysql mysql 201 Feb 28 18:41 mysql-bin.000003
-rw-r----- 1 mysql mysql 10199 Feb 28 19:20 mysql-bin.000004
-rw-r----- 1 mysql mysql 5131 Feb 28 19:27 mysql-bin.000005
-rw-r----- 1 mysql mysql 4331 Mar 1 14:00 mysql-bin.000006
-rw-r----- 1 mysql mysql 5321 Mar 1 14:31 mysql-bin.000007
-rw-r----- 1 mysql mysql 154 Mar 1 14:31 mysql-bin.000008
-rw-r----- 1 mysql mysql 152 Mar 1 14:31 mysql-bin.index
-rw-rw---- 1 root root 6 Feb 28 01:55 mysqld_safe.pid
drwxr-x--- 2 mysql mysql 4096 Feb 24 00:32 performance_schema
-rw-r----- 1 mysql mysql 61 Mar 1 14:31 relay-log.info
-rw-r----- 1 mysql mysql 42908 Mar 1 14:18 sdw2.err
-rw-r----- 1 mysql mysql 6 Feb 28 01:55 sdw2.pid
-rw-r----- 1 mysql mysql 325 Mar 1 14:31 sdw2-relay-bin.000025
-rw-r----- 1 mysql mysql 273 Mar 1 14:31 sdw2-relay-bin.000026
-rw-r----- 1 mysql mysql 48 Mar 1 14:31 sdw2-relay-bin.index
drwxr-x--- 2 mysql mysql 12288 Feb 24 00:32 sys
drwxr-x--- 2 mysql mysql 4096 Feb 24 01:05 test
3.1 備份後,做資料插入及清空表操作
mysql> insert into gyj_t1 values(3,'dumped 3');
Query OK, 1 row affected (0.00 sec)
mysql> insert into gyj_t1 values(4,'dumped 4');
Query OK, 1 row affected (0.01 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from gyj_t1;
+------+----------+
| id | name |
+------+----------+
| 1 | a name |
| 2 | b name |
| 3 | dumped 3 |
| 4 | dumped 4 |
+------+----------+
4 rows in set (0.00 sec)
mysql> truncate table gyj_t1;
Query OK, 0 rows affected (0.01 sec)
mysql> select * from gyj_t1;
Empty set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2017-03-01 14:33:58 |
+---------------------+
1 row in set (0.00 sec)
mysql> truncate table gyj_t1;
Query OK, 0 rows affected (0.07 sec)
mysql> select * from gyj_t1;
Empty set (0.00 sec)
4. 恢復
4.1 恢復
[[email protected] ~]# mysql -uroot -p -S /tmp/mysql3310.sock jfedu < /tmp/0301jfedu.dmpEnter password:
4.2 檢視恢復後的資料:
mysql> mysql> select * from gyj_t1;
+------+--------+
| id | name |
+------+--------+
| 1 | AAAAA |
| 2 | BBBBBB |
+------+--------+
2 rows in set (0.00 sec)
只有備份前的資料
4.3 使用mysqlbinlog 恢復
[[email protected] ~]# mysqlbinlog '/opt/mysql/data/mysql-bin.000008' > gyj.sql[[email protected] ~]# vi gyj.sql
#170301 14:34:14 server id 201710 end_log_pos 1447 CRC32 0x4e16da5d Anonymous_GTID last_committed=5 sequence_number=6
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 1447
#170301 14:34:14 server id 201710 end_log_pos 1536 CRC32 0x30efcd28 Query thread_id=20 exec_time=47 error_code=0
SET TIMESTAMP=1488407654/*!*/;
SET @@session.sql_mode=1075838976/*!*/;
truncate table gyj_t1
/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
#按前面 查詢的當前時間 2017-03-01 14:33:58 查詢到truncate 語句是在 end_log_pos 1536 後。可以恢復可以恢復到這個點。
4.3 按時間恢復
[[email protected] ~]# mysql -uroot -p -S /tmp/mysql3310.sock jfedu < /tmp/0301jfedu.dmp
Enter password:
mysqlbinlog '/opt/mysql/data/mysql-bin.000008' --start-position=1036 --stop-position=1447 |mysql -uroot -p -S /tmp/mysql3310.sock
(前幾次按時間點恢復失敗,主要原因是我沒想到,最後一次使用 備份/tmp/0301jfedu.dmp 做恢復時,也是會寫到binlog日誌中的,
沒指定恢復時間段範圍,其實是又把恢復重做了一次。最後新增的資料還是沒有出來)
#再次查詢,發現數據已恢復。
mysql> select * from gyj_t1;
+------+----------+
| id | name |
+------+----------+
| 1 | a name |
| 2 | b name |
| 3 | dumped 3 |
| 4 | dumped 4 |
+------+----------+
三、利用Innobackupex的備份和binlog日誌對MySQL資料庫做完全恢復。
誤操作MySQL資料庫:rm /u01/my3306/data/*; 再利用Innobackupex的備份和binlog日誌對MySQL資料庫做完全恢復。
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.3.3/binary/redhat/6/x86_64/percona-xtrabackup-2.3.3-1.el6.x86_64.rpm
yum install percona-xtrabackup-2.3.3-1.el6.x86_64.rpm
#完全備份
#完全備份放到/opt/backup/full
#日誌備份放到 /opt/backup/log
#增量備份放到 /opt/backup/inc
[[email protected] ~]# ll /opt/backup
total 12
drwxr-xr-x 2 mysql mysql 4096 Mar 2 00:40 config
drwxr-xr-x 2 mysql mysql 4096 Mar 2 00:26 full
drwxr-xr-x 2 mysql mysql 4096 Mar 2 00:27 inc
[[email protected] ~]# mkdir /opt/backup/log
[[email protected] ~]# chown mysql:mysql /opt/backup/log
[[email protected] ~]# innobackupex -uroot -psa123 -S /tmp/mysql3310.sock /opt/backup/full #做個完全備份
170302 18:28:40 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!".
170302 18:28:41 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql3310.sock' as 'root' (using password: YES).
170302 18:28:41 version_check Connected to MySQL server
......
170302 18:28:51 Executing UNLOCK TABLES
170302 18:28:51 All tables unlocked
170302 18:28:51 [00] Copying ib_buffer_pool to /opt/backup/full/2017-03-02_18-28-40/ib_buffer_pool
170302 18:28:51 [00] ...done
170302 18:28:51 Backup created in directory '/opt/backup/full/2017-03-02_18-28-40/'
MySQL binlog position: filename 'mysql-bin.000008', position '9677'
170302 18:28:51 [00] Writing backup-my.cnf
170302 18:28:51 [00] ...done
170302 18:28:52 [00] Writing xtrabackup_info
170302 18:28:52 [00] ...done
xtrabackup: Transaction log of lsn (3145618) to (3145627) was copied.
170302 18:28:52 completed OK!
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# ll /opt/backup/full
total 4
drwxr-x--- 8 root root 4096 Mar 2 18:28 2017-03-02_18-28-40
#在做備份的同時,多插入幾條資料,確認後面恢復後是否已恢復期間插入的資料
mysql> select * from gyj_t1;
+------+----------+
| id | name |
+------+----------+
| 1 | a name |
| 2 | b name |
| 4 | dumped 4 |
+------+----------+
3 rows in set (0.00 sec)
mysql> insert into gyj_t1 values(5,'innobakupex ing insert');
ERROR 1406 (22001): Data too long for column 'name' at row 1
mysql> insert into gyj_t1 values(5,'bakupex ing insert');
Query OK, 1 row affected (0.07 sec)
mysql> insert into gyj_t1 values(5,'bakupex ing insert');
Query OK, 1 row affected (0.14 sec)
mysql> insert into gyj_t1 values(5,'bakupex ing insert');
Query OK, 1 row affected (1.63 sec)
mysql> select * from gyj_t1;
+------+--------------------+
| id | name |
+------+--------------------+
| 1 | a name |
| 2 | b name |
| 4 | dumped 4 |
| 5 | bakupex ing insert |
| 5 | bakupex ing insert |
| 5 | bakupex ing insert |
+------+--------------------+
6 rows in set (0.00 sec)
mysql>
#刪除mysql 資料目錄中所有檔案
[[email protected] ~]# ll /opt/mysql/data/
total 188748
-rw-r----- 1 mysql mysql 56 Feb 24 00:32 auto.cnf
drwxr-x--- 2 mysql mysql 4096 Mar 1 14:12 erp
-rw-r----- 1 mysql mysql 453 Feb 28 01:54 ib_buffer_pool
-rw-r----- 1 mysql mysql 79691776 Mar 2 18:33 ibdata1
-rw-r----- 1 mysql mysql 50331648 Mar 2 18:33 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Feb 24 00:32 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 Mar 2 18:27 ibtmp1
drwxr-x--- 2 mysql mysql 4096 Mar 2 18:27 jfedu
-rw-r----- 1 mysql mysql 130 Mar 1 01:18 master.info
drwxr-x--- 2 mysql mysql 4096 Feb 24 01:05 mysql
-rw-r----- 1 mysql mysql 201 Feb 28 18:38 mysql-bin.000001
-rw-r----- 1 mysql mysql 201 Feb 28 18:38 mysql-bin.000002
-rw-r----- 1 mysql mysql 201 Feb 28 18:41 mysql-bin.000003
-rw-r----- 1 mysql mysql 10199 Feb 28 19:20 mysql-bin.000004
-rw-r----- 1 mysql mysql 5131 Feb 28 19:27 mysql-bin.000005
-rw-r----- 1 mysql mysql 4331 Mar 1 14:00 mysql-bin.000006
-rw-r----- 1 mysql mysql 5321 Mar 1 14:31 mysql-bin.000007
-rw-r----- 1 mysql mysql 10520 Mar 2 18:33 mysql-bin.000008
-rw-r----- 1 mysql mysql 152 Mar 1 14:31 mysql-bin.index
-rw-rw---- 1 root root 6 Feb 28 01:55 mysqld_safe.pid
drwxr-x--- 2 mysql mysql 4096 Feb 24 00:32 performance_schema
-rw-r----- 1 mysql mysql 61 Mar 1 14:31 relay-log.info
-rw-r----- 1 mysql mysql 194838 Mar 2 18:35 sdw2.err
-rw-r----- 1 mysql mysql 6 Feb 28 01:55 sdw2.pid
-rw-r----- 1 mysql mysql 325 Mar 1 14:31 sdw2-relay-bin.000025
-rw-r----- 1 mysql mysql 273 Mar 1 14:31 sdw2-relay-bin.000026
-rw-r----- 1 mysql mysql 48 Mar 1 14:31 sdw2-relay-bin.index
drwxr-x--- 2 mysql mysql 12288 Feb 24 00:32 sys
drwxr-x--- 2 mysql mysql 4096 Feb 24 01:05 test
[[email protected] ~]# rm -rif /opt/mysql/data/*
[[email protected] ~]# ll /opt/mysql/data
total 0
[[email protected] ~]#
#關閉程序
[[email protected] ~]# ps -ef|grep mysqld
root 23771 1 0 03:42 ? 00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql 23944 23771 0 03:42 ? 00:00:48 ./bin/mysqld --basedir=/opt/mysql/mysql5.7.17 --datadir=/opt/mysql/data --plugin-dir=/opt/mysql/mysql5.7.17/lib/plugin --user=mysql --log-error=/opt/mysql/data/sdw2.err --pid-file=/opt/mysql/data/sdw2.pid --socket=/tmp/mysql3310.sock --port=3310
root 37391 37073 0 18:40 pts/2 00:00:00 grep mysqld
[[email protected] ~]# kill -9 23771
[[email protected] ~]# kill -9 23944
[[email protected] ~]# ps -ef|grep mysqld
root 37396 37073 0 18:40 pts/2 00:00:00 grep mysqld
[[email protected] ~]#
#恢復
[[email protected] /]# innobackupex --defaults-file=/opt/backup/config/backup-my.cnf -uroot -psa123 --copy-back --rsync /opt/backup/full/2017-03-02_18-33-34/
170302 21:49:23 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.6 based on MySQL server 5.7.13 Linux (x86_64) (revision id: 8ec05b7)
170302 21:49:23 [01] Copying ib_logfile0 to /opt/mysql/data/ib_logfile0
170302 21:49:24 [01] ...done
......
#修改目錄使用者
[[email protected] config]# chown -R mysql:mysql /opt/mysql/data
#啟動mysqld
[[email protected] mysql5.7.17]# ps -ef|grep mysqld
root 45731 37073 0 21:50 pts/2 00:00:00 /bin/sh bin/mysqld_safe -user=mysql
mysql 45905 45731 6 21:50 pts/2 00:00:00 ./bin/mysqld --basedir=/opt/mysql/mysql5.7.17 --datadir=/opt/mysql/data --plugin-dir=/opt/mysql/mysql5.7.17/lib/plugin --user=mysql -user=mysql --log-error=/opt/mysql/data/sdw2.err --pid-file=/opt/mysql/data/sdw2.pid --socket=/tmp/mysql3310.sock --port=3310
root 45937 37073 0 21:51 pts/2 00:00:00 grep mysqld
#登入 mysql 測試資料是否已恢復。
[[email protected] mysql5.7.17]# mysql -uroot -psa123 -S /tmp/mysql3310.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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 jfedu;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select *from gyj_t1;
+------+--------------------+
| id | name |
+------+--------------------+
| 1 | a name |
| 2 | b name |
| 4 | dumped 4 |
| 5 | bakupex ing insert |
| 5 | bakupex ing insert |
+------+--------------------+
5 rows in set (0.00 sec)
mysql>
#昨天和同事討論MYSQL 的恢復備份,說binlog是不能刪除的,刪除後不能恢復,但我的binlog 和資料檔案是在同一目錄下。
刪除了,照樣可以恢復。
相關推薦
mysqldumper 與 Innobackupex的備份和恢復操作實驗過程
一、mysqldumper 1.1 mysqldumper 編譯安裝 wget https://launchpadlibrarian.net/185032423/mydumper-0.6.2.tar.gz [[email protecte
[實驗-視訊過程]oracle熱備份-整個資料庫-備份和恢復操作演示
先檢視資料版本和資料檔案所在位置 10g以上版本支援整體表空間熱備份 select * from v$version; select name from v$datafiles; 確認是否為歸檔模式 archive log list; 如果不是改成歸檔模
Gitlab備份和恢復操作
hive 分享圖片 手動 環境變量 ide nta pre mkdir -p blog 參考:https://www.cnblogs.com/kevingrace/p/7821529.html 一,設置開啟備份以及備份路徑 /etc/gitlab/gitl
iptables規則備份和恢復 firewalld的9個zone與zone的操作service的操作
wal zone tts alt 51cto roc ble nag image 10.19 iptables規則備份和恢復10.20 firewalld的9個zone9個zone的介紹10.21 firewalld關於zone的操作10.22 firewalld關於ser
iptables規則備份和恢復,firewalld的9個zone,firewalld關於zone的操作,firewalld關於service的操作
firewalld service zone iptables 筆記內容:l 10.19 iptables規則備份和恢復l 10.20 firewalld的9個zonel 10.21 firewalld關於zone的操作l 10.22 firewalld關於service的操作筆記日期:201
數據庫的備份與還原系列——單表備份和恢復詳細完整實現
單表備份 單表還原 表定義備份還原 表數據備份還原 參考實現:https://www.percona.com/doc/percona-xtrabackup/LATEST/innobackupex/innobackupex_script.htmlRestoring Individual Tabl
三十三、iptables規則備份和恢復、firewalld的9個zone、關於zone的操作、
iptables規則備份和恢復 firewalld的9個zone 關於zone的操作 關於service的操作 三十三、iptables規則備份和恢復、firewalld的9個zone、firewalld關於zone的操作、firewalld關於service的操作一、iptables規則備份
iptables的備份和恢復、firewalld的9個zone、firewalld關於zone的操作
mark permanent fir 規則 def ESS lis walle rest 一:iptables的備份和恢復 備份和恢復規則:拷貝一下/etc/sysconfig/iptables文件。或者iptables-save - > 1.iptiptables-
MongoDB操作-備份和恢復
Mongodb資料庫操作-備份 恢復 匯出 匯入 mongodb資料備份和恢復主要分為二種:一種是針對庫的mongodump和mongorestore,一種是針對庫中表的mongoexport和mongoimport。 一、 mongodump備份資料庫 1. 常
資料庫的備份和恢復以及mysql賬戶的操作
資料庫匯出sql指令碼 命令:mysqldump -uroot -proot 資料庫名稱>生成的檔案路徑 例如:mysqldump -uroot -proot mmm>D:/a.sql
OpenShift 項目的備份和恢復實驗
read cati show 開始 style tar builder str pod 本測試記錄從openshift 3.6環境中導出項目,然後在將項目環境恢復到Openshift 3.11中所需要的步驟 從而指導導入導出的升級過程。 1.安裝Openshift
表中 的數據 備份 和 恢復
delete -- lac values reat varchar let color into -- 建表 create table emp( sid int(8) primary key, sname varchar(10), sex varchar(2), chu
GIt的備份和恢復
gitlab備份 恢復 1、GItlab備份Gitlab默認的備份路徑都是在配置文件中指定的,所以我們可以去配置文件中查看vim /etc/gitlab/gitlab.rb# gitlab_rails[‘manage_backup_path‘] = true # gitlab_rails[‘backu
Ubuntu14.04如何備份和恢復系統
軟件 現在 完整 force 告訴 and 擴展 體積 讓我 http://www.cnblogs.com/alexanderkun/p/5008514.html 本文由魔鬼艦長為您整理編寫。安裝好Ubuntu之後,別忘了安裝 for linux 防火墻和殺毒軟件。在備
20170623_oracle備份和恢復_常見問題
為什麽 exp 程序 模式 imp 全備 命令 恢復 bsp 1 為什麽需要備份?備份分類? 1)故障、遷移、誤操作 2)備份分類: 物理與邏輯角度:物理備份、邏輯備份 備份策略角度:完全備份、增量備份、差異備份 2 使用導入導出進
linux 系統備份和恢復
系統 版本 備份命令 是你 nor 例子 dir del log 轉自:http://blog.csdn.net/sunnylgz/article/details/8055315 在 使用Ubuntu之前,相信很多人都有過使用Windows系統的經歷。如果你備份過Wind
postgresql數據庫備份和恢復(超快)
我們 其中 -- 數據庫 過程 back 手動 文件導入 必須 PostgreSQL自帶一個客戶端pgAdmin,裏面有個備份,恢復選項,也能對數據庫進行備份 恢復(還原),但最近發現數據庫慢慢龐大的時候,經常出錯,備份的文件過程中出錯的幾率那是相當大,手動調節灰常有限。所
Linux下MySQL的備份和恢復
mysql備份 再也不用擔心數據丟失了 MySQL備份的原因 1. 災難恢復 2. 審計 3. 測試1234512345mysql的備份類型 1. 根據服務器的在線狀態: 熱備:服務器處於運行狀態 冷備:服務器出去停止狀態 溫備:服務器處於半離線狀態,只能讀,但是不能
數據庫備份和恢復
file str ase 數據庫 .sql 使用 geo spec ecif mysqldump命令備份:將數據庫中的數據備份成一個文本文件,表結構和表中的數據將存儲在生成的文本中。 ->工作原理:先查出需要備份的表結構,再在文本文件中生成一個create語句,然後將
Oracle 的備份和恢復
改變 方式 冷備份 div 可能 例子 數據庫 速度 外部 Oracle數據庫有三種標準的備份方法,它們分別是導出/導入(EXP/IMP)、熱備份和冷備 份。導出備件是一種邏輯備份,冷備份和熱備份是物理備份。 一、 導出/導入(Export/Import) 利用