CephFS Monitors
https://ceph.readthedocs.io/en/latest/start/intro/より
Monitors: A Ceph Monitor (ceph-mon) maintains maps of the cluster state, including the monitor map, manager map, the OSD map, the MDS map, and the CRUSH map.
These maps are critical cluster state required for Ceph daemons to coordinate with each other.
Monitors are also responsible for managing authentication between daemons and clients.
At least three monitors are normally required for redundancy and high availability.
(deepL先生訳)
モニタ: Cephモニタ(ceph-mon)は、モニタマップ、マネージャマップ、OSDマップ、データシートマップ、およびCRUSHマップなど、クラスタ状態のマップを保持します。
これらのマップは、Cephデーモンが互いに連携するために必要な重要なクラスタ状態です。
モニタは、デーモンとクライアント間の認証の管理も担当します。
通常、冗長性と高可用性のために少なくとも3つのモニタが必要です。
各ノードの状態を監視しているノードっていう感じかな. っで運用時には最低3台必要みたい. cephadmでは5つが既定のように作らてている
作り方はhttps://docs.ceph.com/en/latest/install/manual-deployment/#monitor-bootstrapping
まずceph構成ファイル(/etc/ceph/ceph.conf)を作成します. これは初めからは存在していないファイルです
ただ、その前にクラスターの一意のID(fsid)が必要なので、それを uuidgen コマンドで用意します
[root@ceph-mgr ~]# uuidgen
c2d06c20-9197-40b4-a8c4-1a0604936ce8
[root@ceph-mgr ~]#
っと得られたので、この「c2d06c20-9197-40b4-a8c4-1a0604936ce8」をここでのcephクラスターのIDとします.
っで下記のようにceph構成ファイル(/etc/ceph/ceph.conf)を作る
[root@ceph-mgr ~]# vi /etc/ceph/ceph.conf
[global]
fsid = c2d06c20-9197-40b4-a8c4-1a0604936ce8
mon_initial_members = ceph-mgr
mon_host = 192.168.0.47
public_network = 192.168.0.0/24
cluster_network = 10.10.10.0/24
[root@ceph-mgr ~]#
その後クラスターの「キーリング」を作る.
1.まず枠を用意します
[root@ceph-mgr ~]# ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
[root@ceph-mgr ~]# cat /tmp/ceph.mon.keyring
[mon.]
key = AQA3SJVla9NWMxAATD9GW2dRoJdnsse9REYc+w==
caps mon = "allow *"
[root@ceph-mgr ~]#
2−1.次にclient.adminユーザ名目で管理者権限を持つ「管理者キーリング」を作る
[root@ceph-mgr ~]# ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'
[root@ceph-mgr ~]# cat /etc/ceph/ceph.client.admin.keyring
[client.admin]
key = AQDbS5VlVukfHhAA6anPiPtOMu5F1cNyaNb0Fg==
caps mds = "allow *"
caps mgr = "allow *"
caps mon = "allow *"
caps osd = "allow *"
[root@ceph-mgr ~]# chown ceph. /etc/ceph/ceph.client.admin.keyring
2−2.client.bootstrap-osdユーザ名目でbootstrap向けの「bootstrap-osd キーリング」を用意します
[root@ceph-mgr ~]# ceph-authtool --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd' --cap mgr 'allow r'
[root@ceph-mgr ~]# cat /var/lib/ceph/bootstrap-osd/ceph.keyring
[client.bootstrap-osd]
key = AQC7TZVltEraAxAAoK7wlF2A0I8m87DAASRSLQ==
caps mgr = "allow r"
caps mon = "profile bootstrap-osd"
[root@ceph-mgr ~]#
2−1と2−2で作ったキーを1.の「枠」に組み込みます
[root@ceph-mgr ~]# ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
[root@ceph-mgr ~]# ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
[root@ceph-mgr ~]#
[root@ceph-mgr ~]# cat /tmp/ceph.mon.keyring
[mon.]
key = AQA3SJVla9NWMxAATD9GW2dRoJdnsse9REYc+w==
caps mon = "allow *"
[client.admin]
key = AQDbS5VlVukfHhAA6anPiPtOMu5F1cNyaNb0Fg==
caps mds = "allow *"
caps mgr = "allow *"
caps mon = "allow *"
caps osd = "allow *"
[client.bootstrap-osd]
key = AQC7TZVltEraAxAAoK7wlF2A0I8m87DAASRSLQ==
caps mgr = "allow r"
caps mon = "profile bootstrap-osd"
[root@ceph-mgr ~]#
その後に「モニターマップ」を作る
[root@ceph-mgr ~]# monmaptool --create --add mgr 192.168.0.47 --fsid c2d06c20-9197-40b4-a8c4-1a0604936ce8 /tmp/monmap
monmaptool: monmap file /tmp/monmap
setting min_mon_release = pacific
monmaptool: set fsid to c2d06c20-9197-40b4-a8c4-1a0604936ce8
monmaptool: writing epoch 0 to /tmp/monmap (1 monitors)
[root@ceph-mgr ~]# file /tmp/monmap
/tmp/monmap: data
[root@ceph-mgr ~]#
準備できた「キーリング」と「モニターマップ」をモニターデーモンに組み込みます
[root@ceph-mgr ~]# chown ceph. /tmp/ceph.mon.keyring
[root@ceph-mgr ~]# sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph-mgr
(「/var/lib/ceph/mon/{cluster-name}-{hostname}」形式)
[root@ceph-mgr ~]# sudo -u ceph ceph-mon --cluster ceph --mkfs -i ceph-mgr --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
(「/var/lib/ceph/mon/ceph-ceph-mgr」と「/var/lib/ceph/mon/ceph-ceph-mgr/store.db」コンテンツが作られます)
[root@ceph-mgr ~]#
このceph-monの実行で下記のように新たなファイルが用意される
[root@ceph-mgr ~]# ls -l /var/lib/ceph/mon/
total 0
drwxr-xr-x. 3 ceph ceph 55 Jan 3 23:13 ceph-ceph-mgr
[root@ceph-mgr ~]# ls -R /var/lib/ceph/mon/ceph-ceph-mgr/
/var/lib/ceph/mon/ceph-ceph-mgr/:
keyring kv_backend store.db
/var/lib/ceph/mon/ceph-ceph-mgr/store.db:
000004.log CURRENT IDENTITY LOCK MANIFEST-000005 OPTIONS-000007
[root@ceph-mgr ~]#
っでモニターデーモンを起動します.
デーモンファイル「ceph-mon@.service」を拝見するとExecStartで「%i」が使われているので「ceph-mon@ceph-mgr」として有効にする.
[root@ceph-mgr ~]# less /usr/lib/systemd/system/ceph-mon@.service
:
ExecStart=/usr/bin/ceph-mon -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph
:
[root@ceph-mgr ~]# systemctl enable ceph-mon@ceph-mgr.service
Created symlink /etc/systemd/system/ceph-mon.target.wants/ceph-mon@ceph-mgr.service → /usr/lib/systemd/system/ceph-mon@.service.
[root@ceph-mgr ~]# systemctl start ceph-mon@ceph-mgr.service
もしエラーが発生したら調整後「systemctl reset-failed ceph-mon@mgr.service」を実施してから起動させます
動作確認
[root@ceph-mgr ~]# ceph -s
cluster:
id: c2d06c20-9197-40b4-a8c4-1a0604936ce8
health: HEALTH_WARN
mon is allowing insecure global_id reclaim
services:
mon: 1 daemons, quorum ceph-mgr (age 15s)
mgr: no daemons active
osd: 0 osds: 0 up, 0 in
data:
pools: 0 pools, 0 pgs
objects: 0 objects, 0 B
usage: 0 B used, 0 B / 0 B avail
pgs:
[root@ceph-mgr ~]#
あ「mon is allowing insecure global_id reclaim」と出る. これについては後述
初回の「/etc/ceph/ceph.conf」に全てのMonitorを登録してもいいのですが、
後に追加の事もあり得るのでその方法を示す.
参照先https://docs.ceph.com/en/latest/rados/operations/add-or-rm-mons/
はじめに初期のMonitor(ceph-mgr)の「/etc/ceph/ceph.conf」と「/etc/ceph/ceph.client.admin.keyring」を追加Monitor(ceph-mds)にコピーします
事前にcephパッケージのインストールは済んでいることとします
[root@ceph-mgr ~]# scp /etc/ceph/ceph.conf root@ceph-mds:/etc/ceph/ceph.conf
[root@ceph-mgr ~]# scp /etc/ceph/ceph.client.admin.keyring root@ceph-mds:/etc/ceph/ceph.client.admin.keyring
コピー後、追加するMonitorノードにて下記を実行します
[root@ceph-mgr ~]# ssh ceph-mds
root@ceph-mds's password:
Last login: Wed Jan 3 23:48:49 2024 from 192.168.0.3
[root@ceph-mds ~]# id ceph
uid=167(ceph) gid=167(ceph) groups=167(ceph)
[root@ceph-mds ~]# chown ceph. /etc/ceph/*
[root@ceph-mds ~]# sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph-mds
[root@ceph-mds ~]# ceph auth get mon. -o /tmp/key-filename
[root@ceph-mds ~]# ceph mon getmap -o /tmp/map-filename
[root@ceph-mds ~]# sudo -u ceph ceph-mon -i ceph-mds --mkfs --monmap /tmp/map-filename --keyring /tmp/key-filename
[root@ceph-mds ~]# sudo -u ceph ceph-mon -i ceph-mds --public-addr 192.168.0.48
これで2つめのmonitorが起動します. っで三つ目を作ります
同じように mon2 にもMonitorを導入します
[root@ceph-mgr ~]# scp /etc/ceph/ceph.conf root@ceph-osd1:/etc/ceph/ceph.conf
[root@ceph-mgr ~]# scp /etc/ceph/ceph.client.admin.keyring root@ceph-osd1:/etc/ceph/ceph.client.admin.keyring
その後上記と同じように設定します
ssh -l root ceph-osd1
chown ceph. /etc/ceph/*
sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph-osd1
ceph auth get mon. -o /tmp/key-filename
ceph mon getmap -o /tmp/map-filename
sudo -u ceph ceph-mon -i ceph-osd1 --mkfs --monmap /tmp/map-filename --keyring /tmp/key-filename
sudo -u ceph ceph-mon -i ceph-osd1 --public-addr 192.168.0.49
このあと、どのMonitorでもいいのだが、「ceph -s」とすると下記のようになる
[root@ceph-osd1 ~]# ceph -s
cluster:
id: c2d06c20-9197-40b4-a8c4-1a0604936ce8
health: HEALTH_WARN
mons are allowing insecure global_id reclaim
services:
mon: 3 daemons, quorum ceph-mgr,ceph-mds,ceph-osd1 (age 2s)
mgr: no daemons active
osd: 0 osds: 0 up, 0 in
data:
pools: 0 pools, 0 pgs
objects: 0 objects, 0 B
usage: 0 B used, 0 B / 0 B avail
pgs:
[root@ceph-osd1 ~]#
3つ揃えても「mons are allowing insecure global_id reclaim」と表示されてしまう.
これは
ceph config set mon mon_warn_on_insecure_global_id_reclaim_allowed false
ceph config set mon mon_warn_on_insecure_global_id_reclaim false
で逃げられます.
そして全てのMonitorノードの /etc/ceph/ceph.confを書き換える
[global]
fsid = c2d06c20-9197-40b4-a8c4-1a0604936ce8
mon_initial_members = ceph-mgr,ceph-mds,ceph-osd1
mon_host = 192.168.0.47,192.168.0.48,192.168.0.49
public_network = 192.168.0.0/24
cluster_network = 10.10.10.0/24
留意
一度Monitorとして追加登録したら、そのMonitorを/etc/ceph/ceph.confに登録すること。
それをしないでMonitoを再起動するとcephにアクセスできなくなる
修正方法はこちらhttps://docs.ceph.com/en/latest/rados/operations/add-or-rm-mons/#removing-monitors-from-an-unhealthy-cluster
systemctl stop ceph-mon@mgr
sudo -u ceph ceph-mon -i mgr --extract-monmap /tmp/monmap
sudo -u ceph monmaptool /tmp/monmap --rm mon1
sudo -u ceph ceph-mon -i a --inject-monmap /tmp/monmap
systemctl start ceph-mon@mgr