【Mysql】誤刪ibdata ib_logfile等檔案的恢復
背景:誤刪ibdata等檔案
此時不要驚慌,因為mysql還是在執行的,也行進行操作,,如果關了mysql那就沒辦法了,恢復步驟如下
1.關閉所有業務寫入
2.檢視mysql的pid號
3 進入linux系統自帶的虛擬目錄proc檢視檔案是否還存在
4.輸入命令讓髒快速度重新整理到磁碟
5 確保binlog pos和file不變
6.檢視engine innodb的資訊
6.將檔案恢復並修改許可權
7。重啟mysql即可
-
[root@localhost /var/lib/mysql ]# rm -rf ib*
- ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 ibtmp1
此時不要驚慌,因為mysql還是在執行的,也行進行操作,,如果關了mysql那就沒辦法了,恢復步驟如下
1.關閉所有業務寫入
- flush tables with read lock
2.檢視mysql的pid號
-
[root@localhost /var/lib/mysql ]# ps -ef | grep -i mysql
-
root 386 1 0 May06 ? 00:00:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf
-
mysql 491 386 0 May06 ? 00:16:13 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/demo --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/usr/local/mariadb/demo/mardb.err --pid-file=/usr/local/mariadb/demo/mardb.pid --socket=/usr/local/mariadb/demo/mardb.socket --port=3333
-
root 14790 1 0 14:06 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
-
mysql 15010 14790 0 14:06 ? 00:00:05 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
-
root 18180 17974 0 15:03 pts/3 00:00:00 grep -i mysql
-
[root@localhost /var/lib/mysql ]# netstat -nputl|grep -i mysql
-
tcp 0 0 :::3333 :::* LISTEN 491/mysqld
- tcp 0 0 :::3306 :::* LISTEN 15010/mysqld
3 進入linux系統自帶的虛擬目錄proc檢視檔案是否還存在
-
[root@localhost /var/lib/mysql ]# ll /proc/15010/fd | grep -i 'ib'
lrwx------ 1 root root 64 May 12 15:03 10 -> /var/lib/mysql/ibtmp1 (deleted)
lrwx------ 1 root root 64 May 12 15:03 3 -> /var/lib/mysql/ibdata1 (deleted)
lrwx------ 1 root root 64 May 12 15:03 8 -> /var/lib/mysql/ib_logfile0 (deleted)
lrwx------ 1 root root 64 May 12 15:03 9 -> /var/lib/mysql/ib_logfile1 (deleted)
4.輸入命令讓髒快速度重新整理到磁碟
-
mysql> set global innodb_max_dirty_pages_pct=0;
5 確保binlog pos和file不變
-
mysql> show master status;
-
+------------------+-----------+--------------+------------------+--------------------------------------------------+
-
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
-
+------------------+-----------+--------------+------------------+--------------------------------------------------+
-
| mysql-bin.000176 | 449250839 | | | 6c8a10ed-ed0b-11e4-91eb-00163ec546ca:1-212063619 |
-
+------------------+-----------+--------------+------------------+--------------------------------------------------+
- 1 row in set (0.00 sec)
6.檢視engine innodb的資訊
- 如:
-
mysql> show engine innodb status\G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2016-05-12 15:25:55 0x7f7692d0e700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 10 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 35 srv_active, 0 srv_shutdown, 585 srv_idle
srv_master_thread log flush and writes: 620
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 17
OS WAIT ARRAY INFO: signal count 15
RW-shared spins 0, rounds 63, OS waits 6
RW-excl spins 0, rounds 11, OS waits 0
RW-sx spins 0, rounds 0, OS waits 0
Spin rounds per wait: 63.00 RW-shared, 11.00 RW-excl, 0.00 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 3625
Purge done for trx's n:o < 3625 undo n:o < 0 state: running but idle ==確認後臺程式吧undo log全部清除掉,事物id要一致
History list length 71
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421622043023184, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
459 OS file reads, 134 OS file writes, 55 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges ===合併插入 insert buffer為1
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
Hash table size 34679, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 14905664
Log flushed up to 14905664
Pages flushed up to 14905664
Last checkpoint at 14905655 ===確保三個日誌記錄不再變化
0 pending log flushes, 0 pending chkp writes
55 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 137428992
Dictionary memory allocated 371621
Buffer pool size 8192
Free buffers 7862
Database pages 330
Old database pages 0
Modified db pages 0 ====確認髒頁書數量為0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 296, created 34, written 72
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 330, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=19640, Main thread ID=140146326370048, state: sleeping
Number of rows inserted 34, updated 0, deleted 0, read 9
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s ===確保插入 更新 刪除為0
----------------------------
END OF INNODB MONITOR OUTPUT
============================
1 row in set (0.00 sec)
ERROR:
No query specified
6.將檔案恢復並修改許可權
-
[root@localhost /proc/15010/fd ]# cp 10 /var/lib/mysql/ibtmp1
-
[root@localhost /proc/15010/fd ]# cp 3 /var/lib/mysql/ibdata1
-
[root@localhost /proc/15010/fd ]# cp 8 /var/lib/mysql/ib_logfile0
-
[root@localhost /proc/15010/fd ]# cp 9 /var/lib/mysql/ib_logfile1
-
[root@localhost /proc/15010/fd ]# chown mysql.mysql /var/lib/mysql/ibtmp1
-
[root@localhost /proc/15010/fd ]# chown mysql.mysql /var/lib/mysql/ibdata1
- [root@localhost /proc/15010/fd ]# chown mysql.mysql /var/lib/mysql/ib_logfile*
7。重啟mysql即可
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29096438/viewspace-2098612/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 5.7 刪除ibdata1 、ib_logfile 檔案的資料恢復MySql資料恢復
- MySQL資料災難挽救之ibdata檔案誤刪恢復MySql
- eclipse 恢復誤刪檔案Eclipse
- git恢復誤刪未提交的檔案Git
- 被誤刪的檔案快速恢復方法
- 如何有效恢復誤刪的HDFS檔案
- 電腦誤刪檔案怎麼恢復?
- 電腦照片誤刪了怎麼恢復?電腦誤刪檔案照片恢復教程
- mysql誤刪資料恢復MySql資料恢復
- 恢復ext4檔案系統被誤刪的檔案
- 如何恢復誤刪的檔案?2021最新教程
- win10中mdf檔案被誤刪如何恢復_win10系統mdf檔案被誤刪的恢復方法Win10
- win10誤刪檔案怎麼恢復Win10
- 電腦檔案誤刪除了怎麼恢復找回?誤刪電腦資料恢復方法教程資料恢復
- linux下恢復誤刪除oracle的資料檔案LinuxOracle
- u盤東西誤刪怎麼恢復 恢復u盤檔案的方法
- mysql關於ibdata檔案的理解MySql
- Git恢復刪除的檔案Git
- Mysql 誤刪資料進行恢復MySql
- 伺服器儲存檔案誤刪資料恢復伺服器資料恢復
- PSD檔案誤刪了怎麼恢復?教你三招
- linux系統下檔案誤刪除該如何恢復?Linux
- 行動硬碟刪除的檔案能恢復嗎,怎麼恢復硬碟刪除的檔案硬碟
- ibdata1檔案損壞時恢復InnoDB單表測試
- Linux下面誤刪除檔案使用extundelete工具恢復介紹Linuxdelete
- 電腦誤刪除檔案怎麼恢復檔案,不小心刪除了電腦的檔案怎麼辦
- 360粉碎檔案可以恢復嗎,如何恢復360強力刪除的檔案
- 【北亞資料恢復】zfs檔案系統的伺服器誤刪除的資料恢復資料恢復伺服器
- sd卡刪除的檔案如何恢復SD卡
- Shift + Delete刪除的檔案如何恢復?delete
- MySQL資料庫表誤刪除恢復(一)MySql資料庫
- 14、MySQL Case-線上表誤刪除恢復MySql
- hbase 恢復 誤刪除
- 【伺服器資料恢復】linux ext3檔案系統下誤刪除mysql資料庫的資料恢復案例伺服器資料恢復LinuxMySql資料庫
- Oracle 檔案意外刪除恢復(Linux)OracleLinux
- 如何使用 testdisk 恢復已刪除的檔案
- mysql 透過idb 恢復檔案MySql
- 【伺服器資料恢復】Zfs檔案系統下誤刪除怎麼恢復資料伺服器資料恢復
- Ubuntu boot分割槽檔案誤刪,系統無法啟動_恢復Ubuntuboot