ceph-ops/bootstrap-ceph.sh
2024-04-19 15:36:43 +02:00

58 lines
2.4 KiB
Bash

#!/bin/bash
uuid=$(uuidgen)
#ceph likes to use short name
nodename=$(hostname -s
cat << EOF > /etc/ceph/ceph.conf
[global]
# specify public network
public network = 89.47.190.28/23
# specify UUID genarated above
fsid = ${uuid}
# specify IP address of Monitor Daemon
mon host = 89.47.190.28
# specify Hostname of Monitor Daemon
mon initial members = ${nodename}
osd pool default crush rule = -1
[mon.${nodename}]
# specify Hostname of Monitor Daemon
host = internal-sto4-test-ceph-0.platform.sunet.se
# specify IP address of Monitor Daemon
mon addr = 89.47.190.28
# allow to delete pools
mon allow pool delete = true
EOF
# generate secret key for Cluster monitoring
ceph-authtool --create-keyring /etc/ceph/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
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 *'
# generate key for bootstrap
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'
ceph-authtool /etc/ceph/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
ceph-authtool /etc/ceph/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
sudo -u ceph mkdir /var/lib/ceph/mon/ceph-${nodename}
monmaptool --create --add ${nodename} 89.47.190.28 --fsid ${uuid} /etc/ceph/monmap
ceph-mon --cluster ceph --mkfs -i i${nodename} --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
chown -R ceph /var/lib/ceph/mon/ceph-${nodename} /var/lib/ceph/bootstrap-osd
#mgr
mkdir /var/lib/ceph/mgr/ceph-${nodename}
ceph auth get-or-create mgr.${nodename} mon 'allow profile mgr' osd 'allow *' mds 'allow *'
ceph auth get-or-create mgr.${nodename} | tee /etc/ceph/ceph.mgr.admin.keyring
cp /etc/ceph/ceph.mgr.admin.keyring /var/lib/ceph/mgr/ceph-${nodename}/keyring
chown ceph:ceph /etc/ceph/ceph.mgr.admin.keyring
chown -R ceph:ceph /var/lib/ceph/mgr/ceph-${nodename}
systemctl enable --now ceph-mgr@${nodename}
systemctl enable ceph-mon
#systemctl start ceph-mon
#set some global stuff
ceph mon enable-msgr2
ceph mgr module enable pg_autoscaler
ceph config set mon auth_allow_insecure_global_id_reclaim false
#Create storage disk
sudo growpart --free-percent=80 /dev/sda 1
#FIXME create partition
ceph-volume lvm create --data /dev/sda2