ceph集群常见命令
1、ceph health 或者 ceph health detail (输出信息更详细) 查看集群的健康状态
-s, --status show cluster status
-w, --watch watch live cluster changes
–watch-debug watch debug events
–watch-info watch info events
–watch-sec watch security events
–watch-warn watch warn events
–watch-error watch error events
–version, -v display version
–verbose make verbose
–concise make less verbose
2、ceph df 查看当前集群下有多少个存储池以及分布情况
新版本新增ceph osd df 命令,可以详细列出集群每块磁盘的使用情况,包括大小、权重、使用多少空间、使用率等等
检查mon的状态
ceph mon stat
ceph osd tree
3、检查 MDS 状态
元数据服务器为 Ceph 文件系统提供元数据服务,元数据服务器有两种状态: up | \ down 和 active | inactive
执行下面的命令查看元数据服务器状态为 up 且 active :
ceph mds stat
ceph mds dump
4、为ceph创建一个admin用户并为admin用户创建一个密钥,把密钥保存到/etc/ceph目录下
ceph auth get-or-create client.admin mds ‘allow’ osd ‘allow *’ mon ‘allow *’ > /etc/ceph/ceph.client.admin.keyring
或
ceph auth get-or-create client.admin mds ‘allow’ osd ‘allow *’ mon ‘allow *’ -o /etc/ceph/ceph.client.admin.keyring
5、为osd.0创建一个用户并创建一个key
ceph auth get-or-create osd.0 mon ‘allow rwx’ osd ‘allow *’ -o /var/lib/ceph/osd/ceph-0/keyring
6、为mds.node1创建一个用户并创建一个key
ceph auth get-or-create mds.node1 mon ‘allow rwx’ osd ‘allow *’ mds ‘allow *’ -o /var/lib/ceph/mds/ceph-node1/keyring
7、查看ceph集群中的认证用户及相关的key
ceph auth list
8、查看ceph log日志所在的目录
[root@node1 ~]# ceph-conf --name mon.node1 --show-config-value log_file
/var/log/ceph/ceph-mon.node1.log
简短命令总结
rbd snap ls pool01/pool01_rbd01 --format json 获得快照状态
ceph status -f json-pretty 获得集群状态
rados df --format=json 获取存储池状态
rbd --image rbd31 -p testwg --pretty-format --format json info 获取某个卷的状态
rbd --image rbd31 -p testwg rm 删除某个rbd
rbd status rbdname -p poolname
删除某个rbd失败时
看下谁在连着然后到那个机器上看rbd相关进程,实在不行把这些进程杀掉,然后大概等30s看行不行
for((i=0; i<1000;i++)); do rbd --image rbd_-$i -p pool-1 rm;done 批量删除
ceph osd dump -f json-pretty get_pool_status
ceph osd pool stats -f json-pretty get_pool_stats
ceph osd crush rule dump -f json-pretty get_crush_rule_dump
ceph df --format=json [pools]
ceph osd pool ls detail 查看各个存储池的详情
rbd list -p <pool_name> 查看pool下面所有的rbd
rados df (ceph df) 查看存储池的使用率
建议在创建池时候就定义好合理的 pg-num 与 pgp-num 因为在改变(增加) pg-num 与 pgp-num 时候, 会自动产生 rebalance 操作, 会严重影响 ceph cluster io 性能
查询 ceph osd pool get {pool_name} pg_num(pgp_num)
ceph osd pool set {pool_name} pg_num(pgp_num) 3000 修改存储池的pg_num(pgp_num)
pool size 用于指定当前存放在对应池中的文件实际保存的文件副本数量, 常见为 3
ceph osd pool get {pool_name}size 获得存储池实际保存的副本数
ceph osd pool set {pool_name} size 3 修改存储池实际保存的副本数
pool rule
获得 rule
ceph osd dump | grep “^pool” | grep “crush”
ceph osd pool get {pool_name} crush_rule 获取pool的rule
ceph osd pool application enable {pool_name} rbd 设定池类型方法
cephfs、rbd、rgw 当前常见池使用类型有三种
rbd pool init volumes 初始化rbd池
rbd -p volumes import 7.tar 8.tar (rbd --dest-pool volumes import 7.tar 9.tar) rbd 文件导入
rbd -p volumes export 8.tar 8.tar rbd 文件导出
删除池
当执行删除操作, 池中所有数据都会清空
ceph osd pool delete volumes volumes --yes-i-really-really-mean-it
你需要配置 mon_allow_pool_delete 配置后才允许对 pool 进行删除
查询配置
ceph --admin-daemon /var/run/ceph/ceph-osd.0.asok config show | grep mon_allow_pool_delete
修改配置
获得ceph mon socket 位置
ceph-conf --name mon.$(hostname -s) --show-config-value admin_socket
显示mon配置
ceph daemon /var/run/ceph/ceph-mon.$(hostname -s).asok config show | grep mon_allow_pool_delete
修改mon_allow_pool_delete
ceph tell mon.hh-ceph-128040 injectargs ‘–mon_allow_pool_delete=true’
ceph osd pool get-quota rbd 查看当前pool配额
ceph osd pool set-quota rbd max_objects 10 设置pool配额
rados put obj-1 chrony.conf -p rbd 上传object到pool
ceph osd pool set-quota rbd max_objects 0 取消配额限制
rados –help
ceph mds stat -f json-pretty 查看mds状态
systemctl status ceph-mon@ceph01.service 查看mon的状态
systemctl status ceph-radosgw.target 查看rgw的状态