• Ceph运维之换盘

1、定位故障磁盘

#MegaCli -PDList -aALL|grep "Media Error"

2、定位故障OSD

#lsblk -i|grep /dev/sdb

3、停止故障OSD

systemctl status [email protected]
ceph osd out osd.1
ceph status

4、删除故障OSD

ceph osd crush rm osd.1
ceph auth del osd.1
ceph osd rm osd.1

5、重新组建RAID

[[email protected] ~]# MegaCli -CfgLdAdd -r0 [0:3] WB Direct -a0
ceph-deploy disk list ceph-node1
ceph-deploy disk zap ceph-node2:sdc
ceph-deploy --overwrite-conf osd create ceph-node1:sdc
  • Ceph运维之横向扩展

1、 在新节点上安装ceph软件包,保证和ceph集群的软件版本一致

#ceph-deploy install ceph-node3 --release jewel

2、 列出新节点上所有可用磁盘

#ceph-deploy disk list ceph-node3

3、 将ceph-node3上的磁盘加入到ceph集群

#ceph-deploy disk zap ceph-node3:sdb ceph-node3:sdc ceph-node3:sdd
#ceph-deploy osd create ceph-node3:sdb ceph-node3:sdc ceph-node3:sdd

当新的节点加入到集群,ceph集群开始将部分现有的数据重新平衡到新加入的OSD上,可用下面命令查看平衡过程

#watch ceph -s

4、 检查集群的存储容量

#rados df

5、 查看OSD tree,查看新加入的OSD

#ceph osd tree

6、 注意事项:在生产环境中,一般不会在新节点加入ceph集群后,立即开始数据回填,这样会影响集群性能,我们需要设置一些标志位,来完成这个目的。

#ceph osd noin
#ceph osd set nobackfill

在用户访问的非高峰期,取消这些标志位,集群开始平衡任务。

ceph osd unset noin
ceph osd unset nobackfill
  • 查看Ceph CRUSH map
    1、从monitor节点上获取CRUSH map

    [[email protected] ceph]# ceph osd getcrushmap -o crushmap_compiled_file

2、反编译CRUSH map

[[email protected] ceph]# crushtool -d crushmap_compiled_file -o crushmap_decompiled_file

3、修改完后,我们需要编译他

[[email protected] ceph]# crushtool -c crushmap_decompiled_file -o newcrushmap

4、将新的CRUSH map导入集群中

[[email protected] ceph]# ceph osd setcrushmap -i newcrushmap
[[email protected] ceph]# cat crushmap_decompiled_file
  • Ceph块存储操作
    1、 创建一个1024MB大小的块设备

    #rbd create rbd1 --size 1024 -p compute

2、 列出创建的块image

#rbd ls -p compute

3、 检查image的细节

#rbd --image rbd1 info -p compute

4、 映射ceph块设备
映射设备到client

[[email protected] ceph]# rbd feature disable rbd1 -p compute exclusive-lock object-map fast-diff deep-flatten
[[email protected] ceph]# rbd map --image rbd1 -p compute
检查被映射的设备
[[email protected] ceph]# rbd showmapped
使用这个设备
[[email protected] ceph]# fdisk -l /dev/rbd0
[[email protected] ceph]# mkfs.xfs /dev/rbd0
[[email protected] ceph]# mkdir /mnt/ceph-disk1
[[email protected] ceph]# mount /dev/rbd0 /mnt/ceph-disk1
[[email protected] ceph]# df -h /mnt/ceph-disk1
  • Ceph块存储实践

1、查看ceph集群健康状态

[[email protected]~]# ceph –s

Ceph基础之运维
2、创建1G大小的rbd,名字是foo;查看rbd信息;列出新建的文件。

[[email protected]~]# rbd create foo --size 1024
[[email protected]~]# rbd info foo
[[email protected]~]# rados -p rbd ls

Ceph基础之运维
3、查看两个文件中的信息

[[email protected]~]# rados -p rbd get rbd_id.foo rbd_id.foo
[[email protected]~]# rados -p rbd get rbd_directory rbd_directory
[[email protected]~]# hexdump –vC rbd_id.foo
[[email protected]~]# hexdump –vC rbd_directory

Ceph基础之运维
4、删除bar(前提是创建了bar)

[[email protected]~]# rbd rm bar

Ceph基础之运维
5、将foo映射到操作系统,报错!

[[email protected]~]# rba map foo

Ceph基础之运维
解决方法:当前系统不支持feature,禁用当前系统内核不支持的feature

[[email protected]~]# rbd feature disable foo exclusive-lock, object-map, fast-diff, deep-flatten
[[email protected]~]# rbd map foo

Ceph基础之运维
6、格式化

[[email protected]~]# mkfs.xfs /dev/rbd0

Ceph基础之运维
7、新建目录并挂载

[[email protected]~]# mkdir /foo
[[email protected]~]# mount /dev/rbd0 /foo/
[[email protected]~]# df -h

Ceph基础之运维
8、查看文件

[[email protected]~]# rados -p rbd ls |sort

Ceph基础之运维
9、

[[email protected]~]# rbd export foo hahahaha
[[email protected]~]# file hahahaha

Ceph基础之运维
Ceph基础之运维
10、将磁盘写满

[[email protected]~]# dd if=/dev/zero of=/foo/full-me

Ceph基础之运维

[[email protected]~]# ceph -s

Ceph基础之运维

  • RBD操作:

1、建pool,名字是pool_1;查看建的pool
Ceph基础之运维
2、在pool中建一个大小为1GB的image
Ceph基础之运维
3、查看image详细信息
Ceph基础之运维
4、ceph中一个object对象默认大小是4MB,可以在创建image时指定object大小
Ceph基础之运维
5、删除image
Ceph基础之运维

相关文章: