ceph command

deploy

cephadm

1
2
3
4
5
6
7
8
# step1 monitor
cephadm bootstrap --mon-ip *<mon-ip>*

# ceph shell
sudo ./cephadm shell

# You can access the Ceph CLI as following in case of multi-cluster or non-default config:
sudo /usr/sbin/cephadm shell --fsid <fsid> -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring

service

1
2
3
4
5
# check all vaild service
ceph orch ls

# check all vaild/invaild service
ceph orch ps

cluster

1
2
3
4
5
# method 1
ceph fsid

# method 2
cat /etc/ceph/ceph.conf | grep fsid

User

1
2
3
4
5
6
7
# check regular user key
ceph auth list

# add user

# check admin key
ceph auth get client.admin

health

1
ceph df

host

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# list host
ceph orch host ls --detail

# add host
ssh-copy-id -f -i /etc/ceph/ceph.pub root@*<new-host>*
ceph orch host add *<newhost>* [*<ip>*] [*<label1> ...*]
# e.g. ceph orch host add host2 10.10.0.102 --labels _admin

# remove host
ceph orch host drain *<host>*
ceph orch ps <host> # daemons on the host
ceph orch host rm <host> # remove the host from the cluster after all daemons have been removed

# add storage
ceph orch apply osd --all-available-devices

osd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# list all device 
ceph orch device ls

# list device used by ceph
ceph device ls

# locate current ods node used disk
ceph-volume lvm list

# locate specify ods's devices, e.g. ceph device ls-by-daemon osd.1
ceph device ls-by-daemon <daemon>

# check
ceph ods tree

# Creating New OSDs
ceph orch apply osd --all-available-devices
# or
ceph orch daemon add osd *<host>*:*<device-path>*
# e.g.
ceph orch daemon add osd host1:/dev/sdb
ceph orch daemon add osd host1:data_devices=/dev/sda,/dev/sdb,db_devices=/dev/sdc,osds_per_device=2

pool

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# list available pool
ceph osd pool ls

# Check PG status:
ceph pg stat

# config Replica count: For a replicated pool, size sets how many copies of each object Ceph keeps, and min_size sets the minimum number of replicas that must be available before I/O is allowed.For an erasure-coded pool, Ceph says size is reported as K+M, but it cannot be set directly with ceph osd pool set ... size ...., For EC pools, you control redundancy through the erasure-code profile (k and m), and you can still set min_size; Ceph recommends setting min_size to a value greater than K.
ceph osd pool set {pool-name} size 3
ceph osd pool set {pool-name} min_size 2

# config Capacity quota
ceph osd pool set-quota {pool-name} max_bytes <bytesSize>
ceph osd pool set-quota {pool-name} max_objects <objectsSize>

# Check current settings
ceph osd pool get {pool-name} size
ceph osd pool get {pool-name} min_size
ceph osd pool get-quota {pool-name}
ceph osd pool ls detail | grep {pool-name}

replicated pool

If not specify the pool type, the default is replicated; Ceph also notes that each pool name must be unique and names beginning with . are reserved for internal use.

1
2
3
4
5
6
# template
ceph osd pool create {pool-name} [{pg-num} [{pgp-num}]] [replicated] [crush-rule-name] [expected-num-objects].

#e.g: creates a replicated pool named mypool with 32 PGs, then marks it for RBD use.
ceph osd pool create mypool 32
ceph osd pool application enable mypool rbd

erasure-coded pool

1
2
3
4
5
6
# template
ceph osd pool create {pool-name} [{pg-num} [{pgp-num}]] erasure [erasure-code-profile] [crush-rule-name] [expected_num_objects] [--autoscale-mode=<on,off,warn>]

# e.g.
ceph osd pool create ecpool 32 32 erasure
ceph osd pool application enable ecpool rgw

RGW

radosgw

1
2
3
4
5
6
7
8
9
10
11
12
# enable rgw
ceph mgr module enable rgw

# config rgw name e.g. foo
ceph orch apply rgw foo

# lable host
ceph orch host label add gwhost1 rgw # the 'rgw' label can be anything
ceph orch host label add gwhost2 rgw

# apply
ceph orch apply rgw foo '--placement=label:rgw count-per-host:2' --port=8000

radosgw-admin

1
2
3
4
5
6
7
8
9
10
# create user
radosgw-admin user create --uid=dongwei --display-name="Dongwei User"

# check user
radosgw-admin user info --uid=dongwei

# check bucket info
radosgw-admin bucket stats --bucket=<bucket-name>
or
radosgw-admin metadata get bucket:<bucket>

monitor

1
2
ceph mon dump
# <mon-ip>:6789

Ceph Object Gateway

TBD

Dashboard

1
2
# locate mgr host could use by: `ceph orch ps | grep mgr`
https://mgr-host:8443

reset password

1
2
3
4
5
# Enter Ceph shell
cephadm shell

echo "MyStr0ngNewPass" > dashboard_password.txt
ceph dashboard ac-user-set-password admin -i dashboard_password.txt