Skip to content

Deploying CephFS via cephadm on AlmaLinux 9 — 3-node MON+MGR+OSD+MDS cluster

Stand up a CephFS cluster on AlmaLinux 9 with cephadm — three nodes collapsed into MON, MGR, OSD and MDS roles, replicated pool, kernel-mounted filesystem.

You start the project on Gluster because a replica 3 volume is the cheapest distributed filesystem to stand up. Six months in, you find yourself adding more workloads that need block, then object, then a filesystem with proper directory snapshots, then a quota tree that survives a restart, then erasure-coded cold storage. At that point you are reimplementing Ceph badly on top of Gluster. The honest move is to deploy Ceph from the start, accept that the first cluster is denser than what Gluster needed, and let CephFS, RBD, and RGW all hang off the same set of OSDs. This article stands up a 3-node Reef cluster with cephadm, collapses the MON, MGR, OSD, and MDS roles onto those three nodes, and gives you a kernel-mounted CephFS that survives a node loss.

What’s happening

A small Ceph cluster has five role types, and you collapse them onto the same hosts because three boxes is the floor for redundancy: monitors (MONs) maintain the cluster map and elect a leader via Paxos — you need an odd number, three is the minimum that survives one loss; managers (MGRs) run the dashboard, the modular telemetry, the autoscaler, and the orchestrator — one is active and the rest stand by; OSDs (object storage daemons) are the actual data — one per block device, each one a process; MDS daemons serve CephFS metadata — one active plus one standby for a single-FS cluster is the smallest correct shape; and cephadm itself runs as a podman-managed container on every host, driven by an orchestrator module in the active MGR. The data is sharded into placement groups (PGs), each PG is replicated to three OSDs on three different hosts (CRUSH rule host), and the autoscaler picks the PG count for you based on pool size and target utilization. The mistakes that break small clusters: putting all OSDs on the same physical disk so a disk failure breaks two PGs at once, leaving the default CRUSH rule of osd failure domain so two replicas land on the same host, and running with one MON because “the cluster only has three nodes” — one MON means one bootstrap, one outage, one rebuild.

How to verify

Cluster health from any node:

cephadm shell -- ceph -s
#   cluster:
#     id:     8c9f-... 
#     health: HEALTH_OK
#   services:
#     mon: 3 daemons, quorum ceph-01,ceph-02,ceph-03
#     mgr: ceph-01.abcd (active), standbys: ceph-02.efgh
#     mds: 1/1 daemons up, 1 standby
#     osd: 6 osds: 6 up (since 5m), 6 in (since 5m)

PG distribution sanity check — every PG should be on three different hosts:

cephadm shell -- ceph pg dump 2>/dev/null | awk '$1 ~ /^[0-9]+\.[0-9a-f]+$/ {print $15}' | sort | uniq -c

CephFS status:

cephadm shell -- ceph fs status
# cephfs - 1 clients
# RANK  STATE          MDS         ACTIVITY   DNS    INOS
#  0    active   cephfs.ceph-01.x  Reqs: 0/s  10    13
#  1    standby  cephfs.ceph-02.y

End-to-end from a kernel client (any node or external, with ceph-common installed):

mkdir -p /mnt/cephfs
mount -t ceph 10.30.0.11,10.30.0.12,10.30.0.13:/ /mnt/cephfs -o name=admin,secretfile=/etc/ceph/admin.secret
dd if=/dev/urandom of=/mnt/cephfs/test.bin bs=1M count=64 oflag=direct status=progress
md5sum /mnt/cephfs/test.bin

If ceph health detail reports HEALTH_WARN immediately after install with anything other than mon is allowing insecure global_id reclaim (a one-time setting to clear), pause and resolve it — operators who push past HEALTH_WARN on day one usually rediscover the same warning at 03:00 on a Saturday.

The fix

Save the script as /root/setup-cephadm-node.sh and run it on each of the three nodes after editing the variables at the top. The first node bootstraps the cluster; the second and third are added with ceph orch host add from the first node. The script does a full AlmaLinux 9 install: base hardening (SELinux enforcing, firewalld with role-specific ports, fail2ban, dnf-automatic, SSH key-only), Podman + the cephadm bootstrap binary from the Reef release, the cluster bootstrap on node 1, host add for nodes 2 and 3 (run that section only on node 1), an OSD spec that consumes any unused disk on every host, a replicated CephFS pool (size 3, min_size 2) with the autoscaler on, MDS deployment with one active and one standby, and a kernel client mount on node 1 as a smoke test.

#!/usr/bin/env bash
set -euo pipefail

### AlmaLinux 9 CephFS via cephadm — 3-node MON+MGR+OSD+MDS

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT PER NODE ===
NODE_NAME="ceph-01"             # ceph-01 / ceph-02 / ceph-03
NODE_IP="10.30.0.11"
NODE_INDEX=0                    # 0 = bootstrap, 1/2 = join later from node 0
PEER_IPS=("10.30.0.11" "10.30.0.12" "10.30.0.13")
PEER_NAMES=("ceph-01" "ceph-02" "ceph-03")
CLUSTER_NETWORK="10.30.0.0/16"
PUBLIC_NETWORK="10.30.0.0/16"
FS_NAME="cephfs"
CEPHADM_RELEASE="reef"          # Reef = Ceph 18.x
# =====================

echo
echo "========================================"
echo "Ceph node ${NODE_NAME} (${NODE_IP})"
echo "========================================"
echo

echo "==> /etc/hosts entries for peers"
for i in 0 1 2; do
  if ! grep -q "${PEER_NAMES[$i]}" /etc/hosts; then
    echo "${PEER_IPS[$i]} ${PEER_NAMES[$i]}" >> /etc/hosts
  fi
done
hostnamectl set-hostname "${NODE_NAME}"

echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y install vim curl wget chrony fail2ban dnf-automatic \
  policycoreutils-python-utils lsof tcpdump bind-utils tar gzip \
  iproute net-tools jq socat python3 lvm2 podman

systemctl enable --now chronyd

echo "==> SELinux enforcing"
sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config
setenforce 1 || true

echo "==> Kernel/sysctl"
cat > /etc/sysctl.d/99-ceph.conf <<'SYSCTL'
vm.swappiness = 10
vm.dirty_background_ratio = 5
vm.dirty_ratio = 15
fs.file-max = 4194304
fs.aio-max-nr = 1048576
net.core.somaxconn = 4096
net.core.rmem_max = 268435456
net.core.wmem_max = 268435456
net.ipv4.tcp_rmem = 4096 87380 134217728
net.ipv4.tcp_wmem = 4096 87380 134217728
net.ipv4.tcp_syncookies = 1
kernel.pid_max = 4194304
SYSCTL
sysctl --system

cat > /etc/security/limits.d/99-ceph.conf <<'LIMITS'
root soft nofile 1048576
root hard nofile 1048576
ceph soft nofile 1048576
ceph hard nofile 1048576
LIMITS

echo "==> SSH hardening"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart sshd

echo "==> fail2ban + dnf-automatic (security only)"
cat > /etc/fail2ban/jail.d/sshd.local <<'F2B'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
F2B
systemctl enable --now fail2ban

cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
DNFAUTO
systemctl enable --now dnf-automatic.timer

echo "==> firewalld (allow ceph ports between peers)"
dnf -y install firewalld
systemctl enable --now firewalld
firewall-cmd --permanent --add-service=ssh

for ip in "${PEER_IPS[@]}"; do
  firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${ip} port port=3300 protocol=tcp accept"
  firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${ip} port port=6789 protocol=tcp accept"
  firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${ip} port port=6800-7300 protocol=tcp accept"
done
# Mgmt UI + monitor traffic from operator subnet
firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${PUBLIC_NETWORK} port port=8443 protocol=tcp accept"
firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${PUBLIC_NETWORK} port port=3300 protocol=tcp accept"
firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${PUBLIC_NETWORK} port port=6789 protocol=tcp accept"
firewall-cmd --reload

echo "==> Installing cephadm bootstrap binary"
curl -fsSL "https://download.ceph.com/rpm-${CEPHADM_RELEASE}/el9/noarch/cephadm" -o /usr/local/sbin/cephadm
chmod +x /usr/local/sbin/cephadm

cephadm add-repo --release "${CEPHADM_RELEASE}"
dnf -y install ceph-common

if [[ "${NODE_INDEX}" -eq 0 ]]; then
  if [[ ! -f /etc/ceph/ceph.conf ]]; then
    echo "==> Bootstrapping cluster on ${NODE_NAME}"
    cephadm bootstrap \
      --mon-ip "${NODE_IP}" \
      --cluster-network "${CLUSTER_NETWORK}" \
      --initial-dashboard-user admin \
      --initial-dashboard-password "$(openssl rand -hex 16)" \
      --dashboard-password-noupdate \
      --skip-monitoring-stack false \
      --allow-overwrite
  else
    echo "==> Cluster already bootstrapped, skipping"
  fi

  echo "==> Distributing /etc/ceph/ceph.pub to peers (assumes SSH key auth as root)"
  for i in 1 2; do
    until ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 \
      "root@${PEER_NAMES[$i]}" 'cat >> /root/.ssh/authorized_keys' < /etc/ceph/ceph.pub; do
      echo "Waiting for SSH to ${PEER_NAMES[$i]}..."
      sleep 5
    done
  done

  echo "==> Adding peers to the cluster"
  for i in 1 2; do
    cephadm shell -- ceph orch host add "${PEER_NAMES[$i]}" "${PEER_IPS[$i]}" || true
  done

  echo "==> Waiting for orchestrator to register hosts"
  for i in {1..60}; do
    if [[ "$(cephadm shell -- ceph orch host ls 2>/dev/null | grep -c -E '^(ceph-01|ceph-02|ceph-03) ')" -eq 3 ]]; then
      break
    fi
    sleep 5
  done

  echo "==> Labeling hosts"
  for i in 0 1 2; do
    cephadm shell -- ceph orch host label add "${PEER_NAMES[$i]}" _admin || true
  done

  echo "==> Placing MONs and MGRs on all 3 hosts"
  cephadm shell -- ceph orch apply mon "${PEER_NAMES[0]},${PEER_NAMES[1]},${PEER_NAMES[2]}"
  cephadm shell -- ceph orch apply mgr 3

  echo "==> OSD spec — consume any unused device"
  cat > /tmp/osd-spec.yaml <<'OSD'
service_type: osd
service_id: all-available-devices
placement:
  host_pattern: '*'
spec:
  data_devices:
    all: true
  encrypted: true
OSD
  cephadm shell --mount /tmp/osd-spec.yaml -- ceph orch apply -i /mnt/osd-spec.yaml

  echo "==> Waiting for OSDs to come up (this can take several minutes)"
  for i in {1..120}; do
    UP=$(cephadm shell -- ceph osd stat 2>/dev/null | awk '{print $3}' | head -1)
    [[ -n "${UP}" && "${UP}" -ge 3 ]] && break
    sleep 5
  done

  if ! cephadm shell -- ceph fs ls 2>/dev/null | grep -q "name: ${FS_NAME}"; then
    echo "==> Creating CephFS ${FS_NAME}"
    cephadm shell -- ceph osd pool create "${FS_NAME}_data" replicated
    cephadm shell -- ceph osd pool create "${FS_NAME}_metadata" replicated
    cephadm shell -- ceph osd pool set "${FS_NAME}_data" size 3
    cephadm shell -- ceph osd pool set "${FS_NAME}_data" min_size 2
    cephadm shell -- ceph osd pool set "${FS_NAME}_metadata" size 3
    cephadm shell -- ceph osd pool set "${FS_NAME}_metadata" min_size 2
    cephadm shell -- ceph osd pool application enable "${FS_NAME}_data" cephfs
    cephadm shell -- ceph osd pool application enable "${FS_NAME}_metadata" cephfs
    cephadm shell -- ceph fs new "${FS_NAME}" "${FS_NAME}_metadata" "${FS_NAME}_data"
    cephadm shell -- ceph fs set "${FS_NAME}" max_mds 1
    cephadm shell -- ceph orch apply mds "${FS_NAME}" --placement="2 ${PEER_NAMES[0]} ${PEER_NAMES[1]}"
  fi

  echo "==> Exporting admin client secret for kernel mount"
  cephadm shell -- ceph auth get-or-create client.admin > /tmp/admin.keyring
  cephadm shell -- ceph-authtool -p /etc/ceph/ceph.client.admin.keyring > /etc/ceph/admin.secret
  chmod 600 /etc/ceph/admin.secret

  echo "==> Smoke-test mount"
  mkdir -p /mnt/cephfs
  if ! mountpoint -q /mnt/cephfs; then
    mount -t ceph "${PEER_IPS[0]},${PEER_IPS[1]},${PEER_IPS[2]}:/" /mnt/cephfs \
      -o "name=admin,secretfile=/etc/ceph/admin.secret" || true
  fi
else
  echo "==> Non-bootstrap node — wait for node 0 to add this host"
  echo "    (node 0 will SSH in and copy /etc/ceph/ceph.pub to authorized_keys)"
fi

echo
echo "========================================"
echo "DONE on ${NODE_NAME}"
echo "========================================"
echo

if [[ "${NODE_INDEX}" -eq 0 ]]; then
  cephadm shell -- ceph -s || true
  echo
  cephadm shell -- ceph orch host ls || true
  echo
  cephadm shell -- ceph fs status "${FS_NAME}" || true
  echo
  cephadm shell -- ceph osd tree || true
  echo
  echo "Dashboard URL: https://${NODE_IP}:8443"
fi

echo
echo "To mount from another host:"
echo "  yum -y install ceph-common"
echo "  scp ${NODE_NAME}:/etc/ceph/admin.secret /etc/ceph/admin.secret"
echo "  mount -t ceph ${PEER_IPS[0]},${PEER_IPS[1]},${PEER_IPS[2]}:/ /mnt/cephfs -o name=admin,secretfile=/etc/ceph/admin.secret"

Make it executable and run on each node. On node 0, the script bootstraps the cluster and SSH-adds the other two. Nodes 1 and 2 only need the base hardening and the cephadm binary — node 0 does the orchestration. After the install, do a failure drill before production: reboot one node and watch ceph -s stay HEALTH_OK once the OSDs come back, then mark out one OSD with ceph osd out <id> and confirm the cluster reweights and rebalances without losing the active MDS.

A few defaults worth understanding before traffic arrives: the autoscaler will adjust pg_num for the data and metadata pools over the first few minutes — that’s normal, but watch for HEALTH_WARN: pool ... pg_num X (target X) too low and let it converge before stress-testing. min_size 2 means the cluster will keep serving I/O during a single-node loss; if you ever drop two nodes simultaneously the FS will block writes until one comes back, which is the correct behaviour but worth knowing on a Saturday morning. Encrypted OSDs (encrypted: true in the spec) are the only correct default for a cloud-VM cluster; turn it off only if you’ve already proven you have full-disk encryption underneath.

For a CephFS cluster you don’t have to operate yourself, our team runs Reef and Squid clusters as part of environment management on top of cloud compute — start the conversation if you’d like us to design and operate the storage tier.