Debian 11 Bullseye
Sponsored Link

Ceph Nautilus : クラスターの設定 #12021/08/26

 
分散ファイルシステム Ceph をインストールして、ストレージクラスターを構成します。
当例では 3台 のノードでクラスターを構成します。
3台 のノードにはそれぞれ空きブロックデバイスがあることが前提です。
(当例では [/dev/sdb] を使用)
                                         |
            +----------------------------+----------------------------+
            |                            |                            |
            |10.0.0.51                   |10.0.0.52                   |10.0.0.53 
+-----------+-----------+    +-----------+-----------+    +-----------+-----------+
|   [node01.srv.world]  |    |   [node02.srv.world]  |    |   [node03.srv.world]  |
|     Object Storage    +----+     Object Storage    +----+     Object Storage    |
|     Monitor Daemon    |    |                       |    |                       |
|     Manager Daemon    |    |                       |    |                       |
+-----------------------+    +-----------------------+    +-----------------------+

[1] [Monitor Daemon] を設定するノード (以下、管理ノードと表記) から各ノードへ SSH 鍵ペア認証ができるよう設定しておきます。
当例では [root] ユーザーで、パスフレーズ無の鍵ペアを設定します。
一般ユーザーを使用する場合は root 権限が行使できるよう Sudo の設定が必要です
また、SSH 鍵ペアのパスフレーズを設定する場合は SSH Agent の設定が必要です
各ノードに SSH 鍵を設定した後は、パスワード認証での SSH ログインは禁止しておいた方がよいでしょう。
root@node01:~#
ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Xu/4ahP/3eR0PPGYuInRnNzaGiWTQjFXIdJZg5hNP9U root@node01.srv.world
The key's randomart image is:
.....
.....

root@node01:~#
vi ~/.ssh/config
# 新規作成 (各ノードと接続ユーザーを定義)

Host node01
    Hostname node01.srv.world
    User root
Host node02
    Hostname node02.srv.world
    User root
Host node03
    Hostname node03.srv.world
    User root

root@node01:~#
chmod 600 ~/.ssh/config
# 各ノードに公開鍵を転送

root@node01:~#
ssh-copy-id node01

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node01.srv.world (10.0.0.51)' can't be established.
ECDSA key fingerprint is SHA256:PBj+n3wZ5hxjaf4sAaJinv82rla20xCIuIf8J9GuPxU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node01.srv.world's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'node01'"
and check to make sure that only the key(s) you wanted were added.

root@node01:~#
ssh-copy-id node02

root@node01:~#
ssh-copy-id node03

[2] 管理ノードから各ノードへ Ceph をインストールします。
root@node01:~# for NODE in node01 node02 node03
do
    ssh $NODE "apt update; apt -y install ceph"
done 
[3] 管理ノードで [Monitor Daemon], [Manager Daemon] の設定をします。
root@node01:~#
uuidgen

92749530-d9af-4226-bfe0-ccc79a689a66
# 設定ファイル新規作成

# 設定ファイル名 ⇒ (任意のクラスター名).conf

# 当例ではデフォルトのクラスター名 [ceph] で設定 ⇒ [ceph.conf]

root@node01:~#
vi /etc/ceph/ceph.conf
[global]
# 監視用のクラスターネットワークを指定
cluster network = 10.0.0.0/24
# パブリックネットワークを指定
public network = 10.0.0.0/24
# 先に生成した UUID を指定
fsid = 92749530-d9af-4226-bfe0-ccc79a689a66
# Monitor Daemon 設定ホストの IP アドレスを指定
mon host = 10.0.0.51
# Monitor Daemon 設定ホストのホスト名を指定
mon initial members = node01
osd pool default crush rule = -1

# mon.(ノード名)
[mon.node01]
# Monitor Daemon のホスト名を指定
host = node01
# Monitor Daemon の IP アドレス
mon addr = 10.0.0.51
# プールの削除を許可する
mon allow pool delete = true

# クラスター管理用のシークレットキーを生成

root@node01:~#
ceph-authtool --create-keyring /etc/ceph/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'

creating /etc/ceph/ceph.mon.keyring
# クラスター管理者用のキーを生成

root@node01:~#
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@node01:~#
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
# 生成したキーを [ceph.mon.keyring] にインポート

root@node01:~#
ceph-authtool /etc/ceph/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring

importing contents of /etc/ceph/ceph.client.admin.keyring into /etc/ceph/ceph.mon.keyring
root@node01:~#
ceph-authtool /etc/ceph/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring

importing contents of /var/lib/ceph/bootstrap-osd/ceph.keyring into /etc/ceph/ceph.mon.keyring
# モニターマップを生成

root@node01:~#
FSID=$(grep "^fsid" /etc/ceph/ceph.conf | awk {'print $NF'})

root@node01:~#
NODENAME=$(grep "^mon initial" /etc/ceph/ceph.conf | awk {'print $NF'})

root@node01:~#
NODEIP=$(grep "^mon host" /etc/ceph/ceph.conf | awk {'print $NF'})

root@node01:~#
monmaptool --create --add $NODENAME $NODEIP --fsid $FSID /etc/ceph/monmap

monmaptool: monmap file /etc/ceph/monmap
monmaptool: set fsid to 92749530-d9af-4226-bfe0-ccc79a689a66
monmaptool: writing epoch 0 to /etc/ceph/monmap (1 monitors)
# Monitor Daemon 用データディレクトリ作成

# ディレクトリ名 ⇒ (クラスター名)-(ノード名)

root@node01:~#
mkdir /var/lib/ceph/mon/ceph-node01
# Monitor Daemon に生成したモニターマップとキーを関連付け

# --cluster (クラスター名)

root@node01:~#
ceph-mon --cluster ceph --mkfs -i $NODENAME --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring

root@node01:~#
chown ceph. /etc/ceph/ceph.*

root@node01:~#
chown -R ceph. /var/lib/ceph/mon/ceph-node01 /var/lib/ceph/bootstrap-osd

root@node01:~#
systemctl enable --now ceph-mon@$NODENAME
# Messenger v2 Protocol 有効化

root@node01:~#
ceph mon enable-msgr2
root@node01:~#
ceph config set mon auth_allow_insecure_global_id_reclaim false
# Manager Daemon 用データディレクトリ作成

# ディレクトリ名 ⇒ (クラスター名)-(ノード名)

root@node01:~#
mkdir /var/lib/ceph/mgr/ceph-node01
# 認証用キーを生成

root@node01:~#
ceph auth get-or-create mgr.$NODENAME mon 'allow profile mgr' osd 'allow *' mds 'allow *'


[mgr.node01]
        key = AQD/ASZh9RQCKBAAmM8soMAgMHBJRRXr7hSSKQ==

root@node01:~#
ceph auth get-or-create mgr.node01 | tee /etc/ceph/ceph.mgr.admin.keyring

root@node01:~#
cp /etc/ceph/ceph.mgr.admin.keyring /var/lib/ceph/mgr/ceph-node01/keyring

root@node01:~#
chown ceph. /etc/ceph/ceph.mgr.admin.keyring

root@node01:~#
chown -R ceph. /var/lib/ceph/mgr/ceph-node01

root@node01:~#
systemctl enable --now ceph-mgr@$NODENAME

[4] クラスターステータスで [Monitor Daemon], [Manager Daemon] が有効になっていれば OK です。
OSD (Object Storage Device) はこの後設定するため、現時点では [HEALTH_WARN] で問題ありません。
root@node01:~#
ceph -s

  cluster:
    id:     92749530-d9af-4226-bfe0-ccc79a689a66
    health: HEALTH_WARN
            OSD count 0 < osd_pool_default_size 3

  services:
    mon: 1 daemons, quorum node01 (age 4m)
    mgr: node01(active, since 105s)
    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:
関連コンテンツ