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

初めのmonitor構築

初めのmonitorノードとなる ceph01 にてリポジトリとcephパッケージをインストールします

[root@ceph01 ~]# vi /etc/yum.repos.d/ceph.repo
[ceph]
name=Ceph packages for $basearch
baseurl=https://download.ceph.com/rpm-squid/el9/$basearch
enabled=1
priority=2
gpgcheck=1
gpgkey=https://download.ceph.com/keys/release.asc
 
[ceph-noarch]
name=Ceph noarch packages
baseurl=https://download.ceph.com/rpm-squid/el9/noarch
enabled=1
priority=2
gpgcheck=1
gpgkey=https://download.ceph.com/keys/release.asc
[root@ceph01 ~]#

っでアプリを入れます

[root@ceph01 ~]# dnf install epel-release -y
[root@ceph01 ~]# dnf install ceph-mon -y
[root@ceph01 ~]# id ceph
uid=167(ceph) gid=167(ceph) groups=167(ceph)    <-- ユーザ ceph が用意されます
[root@ceph01 ~]#
[root@ceph01 ~]# ls -l /var/lib/ceph/
total 0
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-mds
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-mgr
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-osd
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-rbd
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-rbd-mirror
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-rgw
drwxr-x---. 3 ceph ceph 20 Apr 25 00:24 crash
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 mon
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 tmp
[root@ceph01 ~]# ls -l /etc/ceph/
total 4
-rw-r--r--. 1 root root 92 Apr  9 07:06 rbdmap
[root@ceph01 ~]#
[root@ceph01 ~]# ps -ef |grep ceph
ceph        1230       1  0 00:24 ?        00:00:00 /usr/bin/python3 -s /usr/bin/ceph-crash    <--インストール直後からプロセスが動く
[root@ceph01 ~]#

まずceph構成ファイル(/etc/ceph/ceph.conf)を作成します. これは初めからは存在していないファイルです
ただ、その前にクラスターの一意のID(fsid)が必要なので、それを uuidgen コマンドで用意します

[root@ceph01 ~]# uuidgen
c2d06c20-9197-40b4-a8c4-1a0604936ce8
[root@ceph01 ~]#

っと得られたので、この「c2d06c20-9197-40b4-a8c4-1a0604936ce8」をここでのcephクラスターのIDとします.
っで下記のようにceph構成ファイル(/etc/ceph/ceph.conf)を作る

[root@ceph01 ~]# vi /etc/ceph/ceph.conf
[global]
fsid = c2d06c20-9197-40b4-a8c4-1a0604936ce8
mon_initial_members = ceph01
mon_host = 192.168.0.47
public_network = 192.168.0.0/24
cluster_network = 10.10.10.0/24
 
[root@ceph01 ~]#

その後クラスターの「キーリング」を作る.
1.まず枠を用意します

[root@ceph01 ~]# ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
creating /tmp/ceph.mon.keyring
 
[root@ceph01 ~]# cat /tmp/ceph.mon.keyring
[mon.]
        key = AQChgcRnjeyWFBAAT3xVV6rai3ImWe52WUEzUA==
        caps mon = "allow *"
 
[root@ceph01 ~]#

2−1.次にclient.adminユーザ名目で管理者権限を持つ「管理者キーリング」を作る

[root@ceph01 ~]# 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 *'
creating /etc/ceph/ceph.client.admin.keyring
 
[root@ceph01 ~]# cat /etc/ceph/ceph.client.admin.keyring
[client.admin]
        key = AQDbgcRn4KXBDxAA/m4UAFVbQcbeQdjTg01XaA==
        caps mds = "allow *"
        caps mgr = "allow *"
        caps mon = "allow *"
        caps osd = "allow *"
 
[root@ceph01 ~]# ls -l /etc/ceph/ceph.client.admin.keyring
-rw-------. 1 root root 151 Mar  3 01:05 /etc/ceph/ceph.client.admin.keyring
 
[root@ceph01 ~]# chown ceph. /etc/ceph/ceph.client.admin.keyring
 
[root@ceph01 ~]# ls -l /etc/ceph/ceph.client.admin.keyring
-rw-------. 1 ceph ceph 151 Mar  3 01:05 /etc/ceph/ceph.client.admin.keyring
 
[root@ceph01 ~]#

2−2.client.bootstrap-osdユーザ名目でbootstrap向けの「bootstrap-osd キーリング」を用意します

[root@ceph01 ~]# 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'
creating /var/lib/ceph/bootstrap-osd/ceph.keyring
[root@ceph01 ~]# cat /var/lib/ceph/bootstrap-osd/ceph.keyring
[client.bootstrap-osd]
        key = AQApgsRnM8CXIRAAUDQ0xlYmGQeBDNjOdRlKvA==
        caps mgr = "allow r"
        caps mon = "profile bootstrap-osd"
 
[root@ceph01 ~]#

2−1と2−2で作ったキーを1.の「枠」に組み込みます

[root@ceph01 ~]# ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
importing contents of /etc/ceph/ceph.client.admin.keyring into /tmp/ceph.mon.keyring
 
[root@ceph01 ~]# ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
importing contents of /var/lib/ceph/bootstrap-osd/ceph.keyring into /tmp/ceph.mon.keyring
 
[root@ceph01 ~]# cat /tmp/ceph.mon.keyring
[mon.]
        key = AQChgcRnjeyWFBAAT3xVV6rai3ImWe52WUEzUA==
        caps mon = "allow *"
[client.admin]
        key = AQDbgcRn4KXBDxAA/m4UAFVbQcbeQdjTg01XaA==
        caps mds = "allow *"
        caps mgr = "allow *"
        caps mon = "allow *"
        caps osd = "allow *"
[client.bootstrap-osd]
        key = AQApgsRnM8CXIRAAUDQ0xlYmGQeBDNjOdRlKvA==
        caps mgr = "allow r"
        caps mon = "profile bootstrap-osd"
 
[root@ceph01 ~]#

その後に「モニターマップ」を作る

[root@ceph01 ~]# 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 = quincy
monmaptool: set fsid to c2d06c20-9197-40b4-a8c4-1a0604936ce8
monmaptool: writing epoch 0 to /tmp/monmap (1 monitors)
 
[root@ceph01 ~]# file /tmp/monmap
/tmp/monmap: data
 
[root@ceph01 ~]#

準備できた「キーリング」と「モニターマップ」をモニターデーモンに組み込みます

[root@ceph01 ~]# ls -l /tmp/ceph.mon.keyring
-rw-------. 1 root root 357 Mar  3 01:08 /tmp/ceph.mon.keyring
 
[root@ceph01 ~]# chown ceph. /tmp/ceph.mon.keyring
[root@ceph01 ~]# ls -l /tmp/ceph.mon.keyring
-rw-------. 1 ceph ceph 357 Mar  3 01:08 /tmp/ceph.mon.keyring
 
[root@ceph01 ~]#
 
[root@ceph01 ~]# sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph01
(「/var/lib/ceph/mon/{cluster-name}-{hostname}」形式)
 
[root@ceph01 ~]# sudo -u ceph ceph-mon --cluster ceph --mkfs -i ceph01 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
(「/var/lib/ceph/mon/ceph-ceph01」フォルダが作られて、その中に「ceph-ceph01/store.db」コンテンツが作られます)
 
[root@ceph01 ~]#

っでモニターデーモンを起動します.
デーモンファイル「ceph-mon@.service」を拝見するとExecStartで「%i」が使われているので「ceph-mon@ceph01」として有効にする.

[root@ceph01 ~]# cat /usr/lib/systemd/system/ceph-mon@.service
 :
ExecStart=/usr/bin/ceph-mon -f --cluster ${CLUSTER} --id %i --setuser ceph --setgroup ceph
 :
[root@ceph01 ~]# systemctl enable ceph-mon@ceph01.service
Created symlink /etc/systemd/system/ceph-mon.target.wants/ceph-mon@ceph01.service → /usr/lib/systemd/system/ceph-mon@.service.
 
[root@ceph01 ~]# systemctl start ceph-mon@ceph01.service

もしエラーが発生したら調整後「systemctl reset-failed ceph-mon@mgr.service」を実施してから起動させます

動作確認

[root@ceph01 ~]# ceph -s
  cluster:
    id:     c2d06c20-9197-40b4-a8c4-1a0604936ce8
    health: HEALTH_WARN
            mon is allowing insecure global_id reclaim
 
  services:
    mon: 1 daemons, quorum ceph01 (age 12s)
    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@ceph01 ~]#

「mon is allowing insecure global_id reclaim」と表示されますが、パラメータを調整して無効にします

[root@ceph01 ~]# ceph config set mon  mon_warn_on_insecure_global_id_reclaim_allowed false
[root@ceph01 ~]# ceph config set mon  mon_warn_on_insecure_global_id_reclaim false
 
[root@ceph01 ~]# ceph -s
  cluster:
    id:     c2d06c20-9197-40b4-a8c4-1a0604936ce8
    health: HEALTH_OK
 :
[root@ceph01 ~]#

ファイアウォールにcephの穴をあけておきます

[root@ceph01 ~]# firewall-cmd --add-service=ceph-mon --permanent
[root@ceph01 ~]# firewall-cmd --reload

Monitorを追加する(ceph02を追加)

Monitorは奇数個必要です。ここでは ceph01とceph02,ceph-osd1の3つをmonitor対応にします
参照先https://docs.ceph.com/en/latest/rados/operations/add-or-rm-mons/

はじめのMonitor(ceph01)の「/etc/ceph/ceph.conf」と「/etc/ceph/ceph.client.admin.keyring」を追加Monitor(ceph02)にコピーします
事前にcephパッケージ(ceph-mon)のインストールは済んでいることとします

[root@ceph01 ~]# scp /etc/ceph/ceph.conf                     root@ceph02:/etc/ceph/ceph.conf
[root@ceph01 ~]# scp /etc/ceph/ceph.client.admin.keyring     root@ceph02:/etc/ceph/ceph.client.admin.keyring
 
[root@ceph01 ~]# ssh ceph02 chown -R ceph:ceph /etc/ceph    <-- 所有権を変更しておきます

コピー後、追加するMonitorノード(ceph02)にて下記を実行します

[root@ceph02 ~]# ls -l /etc/ceph/
total 12
-rw-------. 1 ceph ceph 151 Apr 25 00:27 ceph.client.admin.keyring
-rw-r--r--. 1 ceph ceph 170 Apr 25 00:27 ceph.conf
-rw-r--r--. 1 ceph ceph  92 Apr  9 07:06 rbdmap
[root@ceph02 ~]# ls -l /var/lib/ceph/
total 0
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-mds
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-mgr
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-osd
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-rbd
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-rbd-mirror
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 bootstrap-rgw
drwxr-x---. 3 ceph ceph 20 Apr 25 00:24 crash
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 mon
drwxr-x---. 2 ceph ceph  6 Apr  9 07:06 tmp
[root@ceph02 ~]#
 
[root@ceph02 ~]# sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph02
 
[root@ceph02 ~]# ceph auth get mon. -o /tmp/key-filename
[root@ceph02 ~]# cat /tmp/key-filename
[mon.]
        key = AQChgcRnjeyWFBAAT3xVV6rai3ImWe52WUEzUA==
        caps mon = "allow *"
 
[root@ceph02 ~]# ceph mon getmap -o /tmp/map-filename
got monmap epoch 1
 
[root@ceph02 ~]# sudo -u ceph ceph-mon -i ceph02 --mkfs --monmap /tmp/map-filename --keyring /tmp/key-filename
 
[root@ceph02 ~]# sudo -u ceph ceph-mon -i ceph02 --public-addr 192.168.0.48
 
[root@ceph02 ~]# systemctl enable ceph-mon@ceph02.service --now

これで2つめのmonitorが起動します.
最後にceph02にもfirewallにcephの穴を開けておきます

[root@ceph02 ~]# firewall-cmd --add-service=ceph-mon --permanent
[root@ceph02 ~]# firewall-cmd --reload

っで三つ目を作ります

Monitorを追加する(その2)(ceph-osd1を追加)

同じように ceph-osd1 にもMonitorを導入します. これでmonitorは3つになります.
ceph02と同じようにリポジトリとcephパッケージを入れてから

[root@ceph01 ~]# scp /etc/ceph/ceph.conf                   root@ceph-osd1:/etc/ceph/ceph.conf
[root@ceph01 ~]# scp /etc/ceph/ceph.client.admin.keyring   root@ceph-osd1:/etc/ceph/ceph.client.admin.keyring
[root@ceph01 ~]# ssh ceph-osd1 chown -R ceph:ceph /etc/ceph    <-- 所有権を変更しておきます

その後上記と同じように設定します

ssh -l root ceph-osd1
 
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
systemctl enable ceph-mon@ceph-osd1.service --now
firewall-cmd --add-service=ceph-mon --permanent
firewall-cmd --reload

このあと、どのMonitorでもいいのだが、「ceph -s」とすると下記のようになる

[root@ceph01 ~]# ceph -s
  cluster:
    id:     c2d06c20-9197-40b4-a8c4-1a0604936ce8
    health: HEALTH_OK
 
  services:
    mon: 3 daemons, quorum ceph01,ceph02,ceph-osd1 (age 1.13904s)    <--- monitorが3になりました
    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@ceph01 ~]#

そして最後に全てのMonitorノード(ceph01,ceph02,ceph-osd1)の /etc/ceph/ceph.conf を書き換える

[global]
fsid = c2d06c20-9197-40b4-a8c4-1a0604936ce8
mon_initial_members = ceph01,ceph02,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として追加登録したら、その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
最新の60件
2025-06-18 2025-06-17 2025-06-15 2025-06-14 2025-06-11 2025-06-09 2025-06-08 2025-06-07 2025-06-05 2025-06-02 2025-06-01 2025-05-31 2025-05-30 2025-05-25 2025-05-22 2025-05-21 2025-05-20 2025-05-18 2025-05-17 2025-05-14 2025-05-13 2025-05-12 2025-05-11 2025-05-08 2025-05-07 2025-05-06 2025-05-05 2025-05-04 2025-05-03 2025-04-27 2025-04-26 2025-04-25 2025-04-24

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2025-04-25 (金) 17:09:03