前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ceph集群常用命令参考

Ceph集群常用命令参考

作者头像
dogfei
发布2020-07-31 14:23:55
9310
发布2020-07-31 14:23:55
举报
文章被收录于专栏:devops探索

进到Ceph集群的目录

交互模式

代码语言:javascript
复制
直接输入ceph进入交互模式
$ ceph

查看集群状态
ceph> status

检查集群的健康状态
ceph> health

查看monitors的状态
ceph> mon_status

检查集群状态

代码语言:javascript
复制
ceph status 或 ceph -s

检查OSD状态

代码语言:javascript
复制
ceph osd stat
或 
ceph osd dump

$ ceph osd stat
     osdmap e30: 3 osds: 3 up, 3 in
            flags sortbitwise,require_jewel_osds

OSD的状态

在集群内为“in”

在集群外为 “out”

运行着的为 “up”

不在运行的为 “down”

如果一个OSD处于up状态,那么它可以是在集群内,也可以是在集群外,如果之前的状态为 up 且 in,现在变成 up out了,那么ceph会把PG迁移到其他的OSD上。如果某个OSD的变成out了,则crush就不会再分配PG给它,如果状态为down,那么它的状态就会为out,默认在OSD down掉300s后标记它为out状态

如果某个OSD处于down且in的状态,那么肯定是有问题的,集群则处于非健康状态。

我们还可以查看详细的OSD的状态

代码语言:javascript
复制
$ ceph osd tree
ID WEIGHT  TYPE NAME           UP/DOWN REWEIGHT PRIMARY-AFFINITY 
-1 0.04376 root default                                          
-2 0.01459     host ceph-node1                                   
 0 0.01459         osd.0            up  1.00000          1.00000 
-3 0.01459     host ceph-node2                                   
 1 0.01459         osd.1            up  1.00000          1.00000 
-4 0.01459     host ceph-node3                                   
 2 0.01459         osd.2            up  1.00000          1.00000

那么如果有OSD处于down状态该如何启动呢?

代码语言:javascript
复制
sudo systemctl start ceph-osd@{id}

这里的id对应这里的的{0,1,2}

查看任意一个状态

代码语言:javascript
复制
# systemctl status ceph-osd@0
● ceph-osd@0.service - Ceph object storage daemon
   Loaded: loaded (/usr/lib/systemd/system/ceph-osd@.service; enabled-runtime; vendor preset: disabled)
   Active: active (running) since Mon 2019-05-13 16:36:41 CST; 3 days ago
 Main PID: 2277 (ceph-osd)
   CGroup: /system.slice/system-ceph\x2dosd.slice/ceph-osd@0.service
           └─2277 /usr/bin/ceph-osd -f --cluster ceph --id 0 --setuser ceph --setgroup ceph

May 17 09:31:11 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:11.726254 7f52e5898700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.155:6806 osd.1 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:51.726252)
May 17 09:31:11 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:11.726264 7f52e5898700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.156:6806 osd.2 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:51.726252)
May 17 09:31:12 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:12.538595 7f53030d3700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.155:6806 osd.1 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:52.538592)
May 17 09:31:12 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:12.538653 7f53030d3700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.156:6806 osd.2 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:52.538592)
May 17 09:31:13 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:13.427236 7f52e5898700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.155:6806 osd.1 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:53.427231)
May 17 09:31:13 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:13.427241 7f52e5898700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.156:6806 osd.2 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:53.427231)
May 17 09:31:13 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:13.539323 7f53030d3700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.155:6806 osd.1 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:53.539302)
May 17 09:31:13 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:13.539388 7f53030d3700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.156:6806 osd.2 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:53.539302)
May 17 09:31:14 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:14.541007 7f53030d3700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.155:6806 osd.1 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:54.541004)
May 17 09:31:14 ceph-node1 ceph-osd[2277]: 2019-05-17 09:31:14.541025 7f53030d3700 -1 osd.0 23 heartbeat_check: no reply from 192.168.152.156:6806 osd.2 since back 2019-05-17 09:30:19.920217 front 2019-05-17 09:30:...09:30:54.541004)
Hint: Some lines were ellipsized, use -l to show in full.

检查mon状态

代码语言:javascript
复制
ceph mon stat
或
ceph mon dump

检查mon的法定人数状态

代码语言:javascript
复制
$ ceph quorum_status -f json-pretty

{
    "election_epoch": 3,
    "quorum": [
        0
    ],
    "quorum_names": [
        "ceph-admin"
    ],
    "quorum_leader_name": "ceph-admin",
    "monmap": {
        "epoch": 1,
        "fsid": "dd6219bd-db70-46dc-82fb-f5ea31cfa727",
        "modified": "2019-05-13 16:33:58.012658",
        "created": "2019-05-13 16:33:58.012658",
        "mons": [
            {
                "rank": 0,
                "name": "ceph-admin",
                "addr": "192.168.152.153:6789\/0"
            }
        ]
    }
}

检查mds状态

代码语言:javascript
复制
ceph mds stat
或
ceph mds dump

检查PG状态

代码语言:javascript
复制
ceph pg stat

查看OSD在 crush map里的位置

代码语言:javascript
复制
$ ceph osd tree
ID WEIGHT  TYPE NAME           UP/DOWN REWEIGHT PRIMARY-AFFINITY 
-1 0.04376 root default                                          
-2 0.01459     host ceph-node1                                   
 0 0.01459         osd.0            up  1.00000          1.00000 
-3 0.01459     host ceph-node2                                   
 1 0.01459         osd.1            up  1.00000          1.00000 
-4 0.01459     host ceph-node3                                   
 2 0.01459         osd.2            up  1.00000          1.00000

观察集群内发生的事件

代码语言:javascript
复制
$ ceph -w
    cluster dd6219bd-db70-46dc-82fb-f5ea31cfa727      #集群ID
     health HEALTH_OK                                 #集群健康状态
     monmap e1: 1 mons at {ceph-admin=192.168.152.153:6789/0}
            election epoch 3, quorum 0 ceph-admin
      fsmap e7: 1/1/1 up {0=ceph-admin=up:active}
     osdmap e30: 3 osds: 3 up, 3 in
            flags sortbitwise,require_jewel_osds
      pgmap v123: 84 pgs, 3 pools, 4516 bytes data, 20 objects
            323 MB used, 45723 MB / 46046 MB avail
                  84 active+clean

2019-05-17 09:31:52.670689 mon.0 [INF] pgmap v123: 84 pgs: 84 active+clean; 4516 bytes data, 323 MB used, 45723 MB / 46046 MB avail

检查集群使用情况

代码语言:javascript
复制
$ ceph df
GLOBAL:
    SIZE       AVAIL      RAW USED     %RAW USED 
    46046M     45723M         323M          0.70 
POOLS:
    NAME                ID     USED     %USED     MAX AVAIL     OBJECTS 
    rbd                 0         0         0        14473M           0 
    cephfs_data         1         0         0        14473M           0 
    cephfs_metadata     2      4516         0        14473M          20 


SIZE 集群总容量
AVAIL 集群可用空间总量
RAW USED 集群已用空间总量
%RAW USED 以用存储空间比例
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-05-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 交互模式
  • 检查集群状态
  • 检查OSD状态
  • 检查mon状态
  • 检查mon的法定人数状态
  • 检查mds状态
  • 检查PG状态
  • 查看OSD在 crush map里的位置
  • 观察集群内发生的事件
  • 检查集群使用情况
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档