ceph应知应会

云计算 waitig 495℃ 百度已收录 0评论

作者:【吴业亮】云计算开发工程师
博客:http://blog.csdn.net/wylfengyujiancheng

创建pool

ceph osd pool create volumes 64

创建rbd

# rbd create --size 12G wyl --pool test

列出rbd

# rbd ls -p test
demo
wyl

查看rbd具体信息

# rbd --image test/demo info
rbd image 'demo':
        size 102400 MB in 25600 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.3e4ec74b0dc51
        format: 2
        features: layering
        flags:

修改rbd大小

# rbd resize demo -p test --size 150G
Resizing image: 100% complete...done

缩小

# rbd resize demo  --pool test  --size 99G  --allow-shrink

识别文件系统大小

resize2fs /dev/rbd/test/demo(非xfs文件系统)
xfs_growfs /dev/rbd/test/demo(xfs文件系统)

删除rbd

# rbd rm -p test wyl

自动map

/etc/ceph/rbdmap

volumes/wyl             id=admin,keyring=/etc/ceph/ceph.client.admin.keyring
多集群“,cluster=

映射rbd

# rbd feature disable sip/rbd exclusive-lock object-map fast-diff deep-flatten 
# rbd map wyl --pool test --id {user-name}

取消映射

rbd unmap /dev/rbd/test/wyl

查看映射

# rbd showmapped
id pool image snap device
0  test demo  -    /dev/rbd0
1  test wyl   -    /dev/rbd1

自动map

/etc/ceph/rbdmap

格式

pool/image  id=client,keyring=/etc/ceph/keyring.admin
# service rbdmap start

开机启动

自动挂载

/etc/fstab


/dev/rbd/test/wyl  /mnt xfs default,noatime,_netdev

创建快照
方法一:

# rbd –p {pool-name } snap create –snap {snap-name}   {image-name}

方法二:

# rbd snap create {pool-name}/{image-name}@{snap-name}

举例

# rbd –p test snap create –snap demo-snap1 demo
# rbb snap create test/demo@demo-snap

列出快照

# rbd –pool {pool-name} snap ls {image-name}
# rbd snap ls {pool-name}/{image-name}

举例:

# rbd snap ls test/demp
# rbd --pool test snap ls demo

回滚:

# rbd –pool {pool-name} snap rollback --snap {snap-name} {image-name}
# rbd snap rollback {pool-name}/{image-name}@{snap-name}

举例

# rbd --pool test snap rollback --snap demo-snap1 demo
# rbd snap rollback test/demo@demo-snap1

清除所有快照

# rbd –pool {pool-name} snap purge {image-name}
# rbd snap purge {pool-name}/{image-name}

删除指定快照

# rbd –pool {pool-name}  snap rm {snap-name} {image-name}
# rbd snap rm {pool-name}/{image-name}@{snap-name}

保护快照
创建指定格式

# rbd create test1 --pool  test --image-format 2 --size 10G

查看信息

# rbd info test/test1
rbd image 'test1':
        size 10240 MB in 2560 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.fa38b238e1f29
        format: 2
        features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
        flags:

保护快照

# rbd --pool {pool-name} snap protect --snap {snap-name} {image-name}
# rbd snap protect {pool-name}/{image-name}@{snap-name}
# rbd snap protect test/test1@snap1-test1   
# rbd --pool test snap protect --snap snap1-test1 test1

取消保护

# rbd --pool {pool-name} snap unprotect --snap {snap-name} {image-name}
# rbd snap unprotect {pool-name}/{image-name}@{snap-name}
# rbd snap unprotect test/test1@snap1-test1
# rbd --pool test snap unprotect --snap snap1-test1 test1

克隆必须是保护的快照

# rbd clone test/test1@snap@test1 test/test2

克隆必须是保护的快照

克隆

# rbd create wyl –size 10G –-pool –image-format 2
# rbd  snap create test/wyl@snap-wyl
# rbd snap protect test/wyl@snap-wyl
# rbd clone capacity1/wyl@snap-wyl  capacity1/wyl2

查看克隆

#  rbd –pool {pool-name} children –image {image-name} –snap {snap-name}
# rbd children {pool-name}/{image-name}@{snap-name}

# rbd children capacity1/wyl@snap-wyl

crush map
下载

# ceph osd getcrushmap  -o aa.txt

反编译

# crushtool -d aa.txt -o  bb.txt

修改后编译

# crushtool -c bb.txt -o  cc.txt

导入

# ceph osd setcrushmap  -i cc.txt

手动删除osd
停止服务

# systemctl stop ceph-osd@1

从crush map中移除osd

# ceph osd out osd.1
# ceph osd crush remove osd1

删除认证信息

# ceph auth del osd.1

删除osd

# ceph osd rm 1

rbd的利用率

mon osd full ratio = 0.98

本文由【waitig】发表在等英博客
本文固定链接:ceph应知应会
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)