查到mysqld的pid
[mysql@mvxl0782 binlog]$ netstat -nltp|grep mysqld
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 :::3306 :::* LISTEN 18401/mysqld
这里18401
2.利用进程pid查看对应的文件描述符
[mysql@mvxl0782 binlog]$ ll /proc/18401/fd|egrep 'ib_|ibdata'
lrwx------ 1 mysql mysql 64 8月 11 10:33 10 -> /mysql/server/data/ib_logfile1
lrwx------ 1 mysql mysql 64 8月 11 10:33 11 -> /mysql/server/data/ib_logfile2
lrwx------ 1 mysql mysql 64 8月 11 10:33 4 -> /mysql/server/data/ibdata1
lrwx------ 1 mysql mysql 64 8月 11 10:33 9 -> /mysql/server/data/ib_logfile0
上面的10、11、4和9就是我们要恢复的文件
3、关闭前端业务或执行flush tables with read lock; 不让有数据写入
4、验证有没有数据写入
a.先输入下面命令,让脏页尽快写入到磁盘里
set global innodb_max_dirty_pages_ptc=0;
b.查看binlog日志写入情况,确保file和position没有变化 show master status;
c.最后查看innodb状态信息,确保脏页已刷入到磁盘中
show engine inndodb status\G
TRANSACTIONS
...........
trx id counter A21837
Purge don for trx's n:o<A21837 undo n:o<0
##确保后台purge进程把undo log全部清除掉,事务ID要一致
INSERT BUFFER AND ADAPTIVE HASH INDEX
Ibuf:size 1,free kust keb 65,seg size67,0 merges
##插入buffer合并插入缓存等于1
LOG
Log sequence number xxxx
Log flushed up to xxxx
Last checkpoint at xxx
##确保这3个值不在变化
BUFFER POOL AND MEMORY
............
Modified db pages 0
##确保脏页数量为0
ROW OPERATIONS
..................
0.00 inserts/s,0.00 updates/s,0.00 deletes/s,0.00 reads/s
#确保插入、更新、删除为0
5.恢复操作
[mysql@mvxl0782 binlog]$ ll /proc/18401/fd|egrep 'ib_|ibdata'
lrwx------ 1 mysql mysql 64 8月 11 10:33 10 -> /mysql/server/data/ib_logfile1
lrwx------ 1 mysql mysql 64 8月 11 10:33 11 -> /mysql/server/data/ib_logfile2
lrwx------ 1 mysql mysql 64 8月 11 10:33 4 -> /mysql/server/data/ibdata1
lrwx------ 1 mysql mysql 64 8月 11 10:33 9 -> /mysql/server/data/ib_logfile0
将上面文件复制并改名:
cp 10 /mysql/server/data/ib_logfile1
cp 11 /mysql/server/data/ib_logfile2
cp 4 /mysql/server/data/ibdata1
cp 9 /mysql/server/data/ib_logfile0
授权:
cd /mysql/server/data
chown -R mysql:dba ib*
最后重启mysql
分享标题:mysqlibdata文件误删除恢复-创新互联
转载来于:https://www.cdcxhl.com/article40/dpeseo.html
成都网站建设公司_创新互联,为您提供外贸网站建设、ChatGPT、动态网站、网站排名、品牌网站制作、用户体验
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联