4、将快照挂载到临时目录里
[root@Admin ~]# mkdir /mnt/mysql && mount /dev/vg01/lv_mysql_s /mnt/mysql/
5、备份数据
[root@Admin ~]# ls /mnt/mysql/ # 可以看到新的挂载目录里面的数据 Admin.pid db01 ib_logfile0 mysql mysql-bin.000003 mysql-bin.000006 mysql-bin.000009 performance_schema auto.cnf db02 ib_logfile1 mysql-bin.000001 mysql-bin.000004 mysql-bin.000007 mysql-bin.000010 test binlog ibdata1 login mysql-bin.000002 mysql-bin.000005 mysql-bin.000008 mysql-bin.index [root@Admin ~]# mkdir /backup && rsync -av /mnt/mysql /backup
6、卸载快照并删除
[root@Admin ~]# umount /mnt/mysql/ && lvremove /dev/vg01/lv_mysql_s
7、测试验证(将数据目录里面的东西全部删除)然后再将备份的数据目录恢复过来
1>我们来点狠的,直接把mysql的数据目录/data/DB/删除。 [root@Admin ~]# rm -rf /data/DB/* && ls /data/DB/ 2>删除后可以看到重启mysql直接报错了 [root@Admin ~]# service mysqld restart MySQL server PID file could not be found! [失败] Starting MySQL...The server quit without updating PID file [失败]/DB/Admin.pid). 3>根据上面的/backup里面备份的数据进行恢复 [root@Admin ~]# mv /backup/mysql/* /data/DB/ [root@Admin ~]# ls /data/DB/ auto.cnf db02 ib_logfile1 mysql-bin.000001 mysql-bin.000004 mysql-bin.000007 mysql-bin.000010 test binlog ibdata1 login mysql-bin.000002 mysql-bin.000005 mysql-bin.000008 mysql-bin.index db01 ib_logfile0 mysql mysql-bin.000003 mysql-bin.000006 mysql-bin.000009 performance_schema 4>重新启动 [root@Admin ~]# chown mysql. /data/DB/ -R [root@Admin ~]# service mysqld restart 这里权限更改了如果启动还是报错的话,查看下是否mysql进程还存在,如果存在,将其kill掉再重启就OK [root@Admin ~]# mysql -p123 mysql> show databases; +--------------------+ (北联网教程,专业提供视频软件下载)
……