- Ceph运维之换盘
1、定位故障磁盘
#MegaCli -PDList -aALL|grep "Media Error"
2、定位故障OSD
#lsblk -i|grep /dev/sdb
3、停止故障OSD
systemctl status ceph-osd@1.service
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
[root@hh-yun-ceph-cinder016-128056 ~]# 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[root@ceph ceph]# ceph osd getcrushmap -o crushmap_compiled_file
2、反编译CRUSH map
[root@ceph ceph]# crushtool -d crushmap_compiled_file -o crushmap_decompiled_file
3、修改完后,我们需要编译他
[root@ceph ceph]# crushtool -c crushmap_decompiled_file -o newcrushmap
4、将新的CRUSH map导入集群中
[root@ceph ceph]# ceph osd setcrushmap -i newcrushmap
[root@ceph 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
[root@ceph ceph]# rbd feature disable rbd1 -p compute exclusive-lock object-map fast-diff deep-flatten
[root@ceph ceph]# rbd map --image rbd1 -p compute
检查被映射的设备
[root@ceph ceph]# rbd showmapped
使用这个设备
[root@ceph ceph]# fdisk -l /dev/rbd0
[root@ceph ceph]# mkfs.xfs /dev/rbd0
[root@ceph ceph]# mkdir /mnt/ceph-disk1
[root@ceph ceph]# mount /dev/rbd0 /mnt/ceph-disk1
[root@ceph ceph]# df -h /mnt/ceph-disk1
- Ceph块存储实践
1、查看ceph集群健康状态
[root@ceph-node1~]# ceph –s
2、创建1G大小的rbd,名字是foo;查看rbd信息;列出新建的文件。
[root@ceph-node1~]# rbd create foo --size 1024
[root@ceph-node1~]# rbd info foo
[root@ceph-node1~]# rados -p rbd ls
3、查看两个文件中的信息
[root@ceph-node1~]# rados -p rbd get rbd_id.foo rbd_id.foo
[root@ceph-node1~]# rados -p rbd get rbd_directory rbd_directory
[root@ceph-node1~]# hexdump –vC rbd_id.foo
[root@ceph-node1~]# hexdump –vC rbd_directory
4、删除bar(前提是创建了bar)
[root@ceph-node1~]# rbd rm bar
5、将foo映射到操作系统,报错!
[root@ceph-node1~]# rba map foo
解决方法:当前系统不支持feature,禁用当前系统内核不支持的feature
[root@ceph-node1~]# rbd feature disable foo exclusive-lock, object-map, fast-diff, deep-flatten
[root@ceph-node1~]# rbd map foo
6、格式化
[root@ceph-node1~]# mkfs.xfs /dev/rbd0
7、新建目录并挂载
[root@ceph-node1~]# mkdir /foo
[root@ceph-node1~]# mount /dev/rbd0 /foo/
[root@ceph-node1~]# df -h
8、查看文件
[root@ceph-node1~]# rados -p rbd ls |sort
9、
[root@ceph-node1~]# rbd export foo hahahaha
[root@ceph-node1~]# file hahahaha
10、将磁盘写满
[root@ceph-node1~]# dd if=/dev/zero of=/foo/full-me
[root@ceph-node1~]# ceph -s
- RBD操作:
1、建pool,名字是pool_1;查看建的pool
2、在pool中建一个大小为1GB的image
3、查看image详细信息
4、ceph中一个object对象默认大小是4MB,可以在创建image时指定object大小
5、删除image