Ceph块存储-4·删除快照

作者: 技术老男孩 | 来源:发表于2022-11-27 12:20 被阅读0次

    删除一个受保护的快照困难重重,那就演示一下如何一步步操作进行删除的

    一、删除镜像步骤思路:

    • 将受保护的镜像修改为不受保护
    • 删除镜像下面的所有快照
    • 取消访问者挂载连接
    • rbd删除镜像

    二、开始实操

    第一步:将受保护的镜像修改为不受保护

    • 查看当前存储池情况
    [root@crontrol7 ~]# rbd ls
    mysql
    mysql-snap1-1
    mysql-snap1-2
    new
    [root@crontrol7 ~]# rbd showmapped
    id pool image snap device    
    0  rbd  mysql -    /dev/rbd0 
    
    • 尝试直接删除镜像快照
    [root@crontrol7 ~]# rbd snap purge mysql
    Removing all snapshots: 0% complete...failed.
    rbd: snapshot 'mysql-snap1' is protected from removal.
    
    • 提示需要mysql-snap1快照是受保护的不能被移除,那就尝试解除受保护的状态
    # 将mysql镜像中的快照mysql-snap1取消保护
    [root@crontrol7 ~]# rbd snap unprotect mysql --snap mysql-snap1
    2022-11-28 11:36:41.231903 7f22ee444700 -1 librbd::SnapshotUnprotectRequest: cannot unprotect: at least 2 child(ren) [104b2ae8944a,104f238e1f29] in pool 'rbd'
    2022-11-28 11:36:41.231918 7f22ee444700 -1 librbd::SnapshotUnprotectRequest: encountered error: (16) Device or resource busy
    2022-11-28 11:36:41.231927 7f22ee444700 -1 librbd::SnapshotUnprotectRequest: 0x5642da665db0 should_complete_error: ret_val=-16
    rbd: unprotecting snap failed: (16) Device or resource busy
    2022-11-28 11:36:41.235134 7f22ee444700 -1 librbd::SnapshotUnprotectRequest: 0x5642da665db0 should_complete_error: ret_val=-16
    
    • 提示我cannot unprotect: at least 2 child(ren) [104b2ae8944a,104f238e1f29] in pool 'rbd',那就把他们先进行删除(这个二个镜像也是从mysql-snap1这个快照克隆出来的,所以必须要先把他们删除)
    [root@crontrol7 ~]# rbd rm mysql-snap1-1
    Removing image: 100% complete...done.
    [root@crontrol7 ~]# rbd rm mysql-snap1-2
    Removing image: 100% complete...done.
    
    • 然后就很顺利的将mysql-snap1快照取消保护了
    [root@crontrol7 ~]# rbd snap unprotect mysql --snap mysql-snap1
    

    第二步:删除镜像下面的所有快照

    • 用rbd snap purge进行删除所有镜像的快照
    [root@crontrol7 ~]# rbd snap purge mysql
    Removing all snapshots: 100% complete...done.
    
    • 尝试再删除镜像
    [root@crontrol7 ~]# rbd rm mysql 
    2022-11-28 11:39:47.365860 7fbe4859fd80 -1 librbd: image has watchers - not removing
    Removing image: 0% complete...failed.
    rbd: error: image still has watchers
    This means the image is still open or the client using it crashed. Try again after closing/unmapping it or waiting 30s for the crashed client to timeout.
    
    • 提示librbd: image has watchers - not removing,有人正在使用,不能进行删除

    第三步:取消访问者挂载连接

    • 查看下谁在挂载访问
    [root@crontrol7 ~]# rbd status mysql
    Watchers:
        watcher=192.168.88.253:0/3603526388 client.4172 cookie=18446462598732840961
    
    • 原来小丑是我自己,自己挂载访问中,那就解除解除挂载和映射
    # 解除挂载
    [root@crontrol7 ~]# umount /mnt
    # 解除映射
    [root@crontrol7 ~]# rbd unmap mysql
    
    # 再次确认watcher,显示none为正常
    [root@crontrol7 ~]# rbd status mysql
    Watchers: none
    

    第四步:rbd删除镜像

    • 最后就顺利删除了镜像
    [root@crontrol7 ~]# rbd rm mysql
    Removing image: 100% complete...done.
    

    相关文章

      网友评论

        本文标题:Ceph块存储-4·删除快照

        本文链接:https://www.haomeiwen.com/subject/cglxfdtx.html