Skip to content

Instantly share code, notes, and snippets.

@congto
Last active February 6, 2020 17:42
Show Gist options
  • Save congto/94e40b523fa4a9035587d54597142194 to your computer and use it in GitHub Desktop.
Save congto/94e40b523fa4a9035587d54597142194 to your computer and use it in GitHub Desktop.
ghi_chep_cac_lenh_cua_CEPH.md

Ghi chép các lệnh của CEPH

1. Các lệnh chung

Đây là các lệnh kiểm tra chung về cluster của CEPH

1.1. Lệnh xem phiên bản của CEPH cluster là bao nhiêu

Lệnh kiểm tra phiên bản của CEPH cluster đang được triển khai là bao nhiêu.

ceph -v

Kết quả:

[root@ceph1 ~]# ceph -v
ceph version 14.2.7 (3d58626ebeec02d8385a4cefb92c6cbc3a45bfe8) nautilus (stable)

1.2. Lệnh kiểm tra trạng thái của cluster CEPH.

Đây là lệnh để biết xem tổng thể cụm CEPH cluster có OK hay không OK. Ta cần quan sát dòng health trong kết quả trả về để nhận biết.

ceph -s

Kết quả ta thu được như sau:

root@ceph1 ~]# ceph -s
  cluster:
    id:     3ce5c9e9-ae08-4475-abad-0e3d36a01df6
    health: HEALTH_OK

  services:
    mon: 3 daemons, quorum ceph1,ceph2,ceph3 (age 10m)
    mgr: ceph1(active, since 10m), standbys: ceph2, ceph3
    osd: 9 osds: 9 up (since 10m), 9 in (since 10m)
    rgw: 3 daemons active (ceph1, ceph2, ceph3)

  data:
    pools:   7 pools, 544 pgs
    objects: 235 objects, 29 MiB
    usage:   9.3 GiB used, 522 GiB / 531 GiB avail
    pgs:     544 active+clean

  io:
    client:   42 KiB/s rd, 0 B/s wr, 41 op/s rd, 27 op/s wr

Ta có thể sử dụng lệnh ceph health detail để thay thế lệnh trên, kết quả sẽ ra dòng trạng thái của CEPH cluster.

[root@ceph1 ~]# ceph health detail
HEALTH_OK

1.3. Lệnh xem trạng thái của cluser CEPH theo thời gian thực.

Lệnh này tương tự lệnh trên nhưng trạng thái và các sự kiện của cụm CEPH cluster được cập nhật theo thời gian thực.

ceph -w

Kết quả ta sẽ thấy được cập nhật ở dòng cuối cùng.

[root@ceph1 ~]# ceph -w
  cluster:
    id:     3ce5c9e9-ae08-4475-abad-0e3d36a01df6
    health: HEALTH_WARN
            3 osds down
            1 host (3 osds) down
            Degraded data redundancy: 235/705 objects degraded (33.333%), 62 pgs degraded, 544 pgs undersized
            9 slow ops, oldest one blocked for 43 sec, daemons [osd.6,osd.8] have slow ops.
            clock skew detected on mon.ceph3

  services:
    mon: 3 daemons, quorum ceph1,ceph2,ceph3 (age 9m)
    mgr: ceph1(active, since 13h), standbys: ceph2, ceph3
    osd: 9 osds: 4 up (since 4m), 7 in (since 9m)
    rgw: 3 daemons active (ceph1, ceph2, ceph3)

  data:
    pools:   7 pools, 544 pgs
    objects: 235 objects, 29 MiB
    usage:   7.2 GiB used, 406 GiB / 413 GiB avail
    pgs:     235/705 objects degraded (33.333%)
             482 active+undersized
             62  active+undersized+degraded
2020-02-06 22:50:10.784188 mon.ceph3 [WRN] message from mon.0 was stamped 1.647173s in the future, clocks not synchronized
2020-02-06 22:50:16.955002 mon.ceph1 [WRN] 2 clock skew 1.66304s > max 0.05s

1.4. Lệnh kiểm tra xem các pool hiện có

  • Cách 1:
ceph osd pool ls

Kết quả

[root@ceph1 ~]# ceph osd pool ls
.rgw.root
default.rgw.control
default.rgw.meta
default.rgw.log
rbd
kythuat
ketoan
  • Cách 2:
ceph  osd lspools

Kết quả:

[root@ceph1 ~]# ceph  osd lspools
1 .rgw.root
2 default.rgw.control
3 default.rgw.meta
4 default.rgw.log
5 rbd
6 kythuat
7 ketoan

1.5. Lệnh xem tình trạng sử dụng tài nguyên

Lệnh này hiển thị tài nguyên của CEPH bao gồm các thông tin về dung lượng tổng, dung lượng trống, dung lượng raw của cả cụm CEPH cluster và các pool.

ceph df

Kết quả của ceph df:

[root@ceph1 ~]# ceph df
RAW STORAGE:
    CLASS     SIZE        AVAIL       USED        RAW USED     %RAW USED
    hdd       413 GiB     406 GiB     246 MiB      7.2 GiB          1.75
    TOTAL     413 GiB     406 GiB     246 MiB      7.2 GiB          1.75

POOLS:
    POOL                    ID     STORED      OBJECTS     USED        %USED     MAX AVAIL
    .rgw.root                1     1.8 KiB           4     768 KiB         0       248 GiB
    default.rgw.control      2         0 B           8         0 B         0       248 GiB
    default.rgw.meta         3         0 B           0         0 B         0       165 GiB
    default.rgw.log          4         0 B         175         0 B         0       248 GiB
    rbd                      5      19 MiB          24      41 MiB         0       248 GiB
    kythuat                  6      20 MiB          24      43 MiB         0       248 GiB
    ketoan                   7         0 B           0         0 B         0       165 GiB

2. Các lệnh đối với block storge

Đây là các lệnh dùng để làm việc với block storage (RBD).

2.1 Lệnh xem các image trong pool của block storage

Lệnh xem trong pool của block storage có các image nào, sử dụng theo cú pháp rbd ls ten_pool. Ví dụ xem các image trong pool có tên là rbd hoặc pool có tên là kythuat

Xem các image trong pool rbd

rbd ls rbd
  • Kết quả
    [root@ceph1 ~]# rbd ls rbd
    disk01
    

Xem các image trong pool kythuat

rbd ls kythuat
  • Kết quả
    [root@ceph1 ~]# rbd ls kythuat
    disk02
    

2.2. Lệnh kiểm tra thông tin của một image rbd

  • Sử dụng lệnh rbd help info để xem cú pháp sử dụng lệnh.

Kiểm tra thông tin của một image trong block storage ta sử dụng cú pháp sau

rbd info -p ten_pool --image ten_image

hoặc

rbd ten_pool/ten_image

Trong đó:

  • ten_pool được kiểm tra bằng lệnh ceph osd pool ls hoặc ceph osd lspools
  • ten_image thuộc pool được kiểm tra bằng lệnh ở mục 2.1 theo cú pháp rbd ls ten_pool.

Ví dụ:

rbd info -p kythuat --image disk02
  • Kết quả:
    rbd image 'disk02':
           size 20 GiB in 5120 objects
           order 22 (4 MiB objects)
           snapshot_count: 0
           id: 2d00c79151dd
           block_name_prefix: rbd_data.2d00c79151dd
           format: 2
           features: layering
           op_features:
           flags:
           create_timestamp: Wed Feb  5 22:26:15 2020
           access_timestamp: Wed Feb  5 22:26:15 2020
           modify_timestamp: Wed Feb  5 22:26:15 2020
    

Hoặc

rbd info kythuat/disk02
  • Kết quả
rbd image 'disk02':
       size 20 GiB in 5120 objects
       order 22 (4 MiB objects)
       snapshot_count: 0
       id: 2d00c79151dd
       block_name_prefix: rbd_data.2d00c79151dd
       format: 2
       features: layering
       op_features:
       flags:
       create_timestamp: Wed Feb  5 22:26:15 2020
       access_timestamp: Wed Feb  5 22:26:15 2020
       modify_timestamp: Wed Feb  5 22:26:15 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment