1.创建LVM (mysql迁移到LVM上,再做快照)
fdisk pvcreate vgcreate lvcreate mkfs
2.停止mysql服务
3.挂载LV到临时目录
4. tar方式迁移数据
tar cf - . | tar xf - -C /var/mymnt
5. 重新挂载LV到/var/lib/mysql
6. 测试
*tail /var/log/mysqld.log 查看日志
*挂载后/var/lib/mysql目录安全上下文需修改 mysqld_db_t
restorecon -R /var/lib/mysql
备份步骤:
1 锁表
mysql> flush tables with read lock;
2 创建快照(快照大小事先一定要预估发生改变的数据量)
lvcreate -s -n mysnap -L 1G /dev/mapper/vg0-lv0
3 记录pos号
show master status;
4 解锁
mysql> unlock tables;
5 挂载快照
mkdir /var/mymnt
mount /dev/mapper/vg0-lv0 /var/mymnt
6 tar方式备份
tar czf /tmp/mysql.all.tgz 文件名(绝对路径)
7 删除快照(先卸载,再删除)
umount /var/mymnt
lvremove /dev/vg0/mysnap
恢复步骤:
1 service mysqld stop
2 tar xf /tmp/mysql.all.tgz
3 service mysqld start
4 mysqlbinlog mylog.000002 --start-position="106"|mysql
阅读(2087) | 评论(0) | 转发(0) |