• ceph之ceph-client安装


    1、安装ceph-client

    ceph-deploy  install ceph-client

    2、创建块设备

    [root@mon1 ~]# rbd create test1 --image-format 1 --size 5G

    rbd: image format 1 is deprecated
    [root@mon1 ~]#

    [root@mon1 ~]# rbd info test1
    rbd image 'test1':
        size 5120 MB in 1280 objects
        order 22 (4096 kB objects)
        block_name_prefix: rb.0.20bd3.2ae8944a
        format: 1
    [root@mon1 ~]#

    3、映射

    [root@mon1 ~]# rbd map test1
    /dev/rbd0

    [root@mon1 ~]# rbd showmapped
    id pool image snap device
    0  rbd  test1 -    /dev/rbd0

    4、格式化

    [cephuser@ceph-admin rbd]$ sudo mkfs.ext4 -q /dev/rbd/rbd/test1
    
    [root@mon1 ~]# lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sr0     11:0    1  422K  0 rom
    vda    253:0    0   20G  0 disk
    └─vda1 253:1    0   20G  0 part /
    rbd0   252:0    0    5G  0 disk

    5、挂载

    [root@mon1 ~]# mkdir -p /mnt/rbd-test1
    [root@mon1 ~]# mount /dev/rbd0 /mnt/rbd-test1/

    6、查看

    [root@mon1 ~]# lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sr0 11:0 1 422K 0 rom
    vda 253:0 0 20G 0 disk
    └─vda1 253:1 0 20G 0 part /
    rbd0 252:0 0 5G 0 disk /mnt/rbd-test1

    7、设置自动map

    [root@mon1 ~]# vim /etc/ceph/rbdmap
    
    rbd/test1   id=admin,keyring=/etc/ceph/ceph.client.admin.keyring

    8、修改fstab

    [root@mon1 ~]# vim /etc/fstab
    /dev/rbd/rbd/test1  /mnt/rbd-test1  ext4    defaults,noatime,_netdev         0 0

    9、设置rbdmap开机启动

    systemctl enable rbdmap

    ps:设置开机启动后,磁盘总是挂载不上,发现systemctl is-enable rbdmap是static状态,不是enable,经查,这里的static是指Unit的文件中没有[Install]区域,因此需要添加此区域,即

    vim /usr/lib/systemd/system/rbdmap.servic
    [Install] WantedBy
    =multi-user.target

    10、重启

    reboot或systemctl restart rbdmap

    11、rbd扩容

    [root@mon1 ~]# rbd resize rbd/test1 --size 10G
    Resizing image: 100% complete...done.
    [root@mon1 ~]# resize2fs /mnt/rbd-test1
    resize2fs 1.42.9 (28-Dec-2013)
    open: Is a directory while opening /mnt/rbd-test1
    [root@mon1 ~]# resize2fs /dev/rbd/rbd/test1
    resize2fs 1.42.9 (28-Dec-2013)
    Filesystem at /dev/rbd/rbd/test1 is mounted on /mnt/rbd-test1; on-line resizing required
    old_desc_blocks = 1, new_desc_blocks = 2
    The filesystem on /dev/rbd/rbd/test1 is now 2621440 blocks long.

    12、删除rbd

    [root@mon1 ~]# umount /mnt/rbd-test1/ [root@mon1 ~]# vim /etc/ceph/rbdmap rbd/test1 id=admin,keyring=/etc/ceph/ceph.client.admin.keyring #删除 [root@mon1 ~]# vim /etc/fstab

    /dev/rbd/rbd/test1  /mnt/rbd-test1  ext4    defaults,noatime,_netdev         0 0   #删除

    13、创建快照

    [root@mon1 ~]# rbd snap create test3@snap-test3

    14、查看快照

    [root@mon1 ~]# rbd snap ls test3
    SNAPID NAME          SIZE
         4 snap-test3 2048 MB

    15、快照回滚

    [root@mon1 ~]# rbd snap rollback test3@snap-test3
    Rolling back to snapshot: 100% complete...done.

    ps:回滚以后要重新挂载卷

    16、删除快照

    [root@mon1 ~]# rbd snap rm test3@snap-test3
    删除快照是指删除某个特定的快照

    17、清除快照

    [root@mon1 ~]# rbd snap purge test3
    Removing all snapshots: 100% complete...done.

    ps:清除快照是指删除该rbd的所有快照

    18、保护快照

    [root@mon1 ~]# rbd snap protect test4@snap-test

    ps:被保护的快照的format类型必须是format 2

    19、快照克隆

    [root@mon1 ~]# rbd clone test4@snap-test snap-test-clone


    [root@mon1 ~]# rbd list
    chen
    snap-test-clone
    test
    test2
    test4
    [root@mon1 ~]#

  • 相关阅读:
    浅谈C#托管程序中的资源释放问题
    c#基本语法学习笔记
    深入剖析C#多态性
    Reporting Services API
    进程和线程的区别
    化妆品网站,饰品网站
    宠物销售网站
    卖地方特色才产品,类似湖南味道那样的网上专卖店
    建立友情链接联盟
    DIY最残忍U盘
  • 原文地址:https://www.cnblogs.com/netmouser/p/6879534.html
Copyright © 2020-2023  润新知