Skip to content

Instantly share code, notes, and snippets.

@wido
Last active July 25, 2019 06:45
Show Gist options
  • Select an option

  • Save wido/561c69dc2ec3a49d1dba10a59b53dfe5 to your computer and use it in GitHub Desktop.

Select an option

Save wido/561c69dc2ec3a49d1dba10a59b53dfe5 to your computer and use it in GitHub Desktop.
ceph-mon database re-initialize
#!/bin/bash
set -e
#
# Re-install and re-initialize ceph-mon database
#
# Useful to go from LevelDB to RocksDB kv_backend
#
# LevelDB was the old backend used up until Jewel and
# newer versions use RocksDB
#
# Author: Wido den Hollander <[email protected]>
#
ME=$(hostname -s)
SERVICE="ceph-mon@${ME}"
MONMAP="/tmp/monmap"
OUTSIDE_QUORUM=$(ceph mon_status|jq -r '.outside_quorum[]'|wc -l)
if [ "$OUTSIDE_QUORUM" -gt 0 ]; then
echo "One or more MONs outside quorum. Exiting"
exit 1
fi
ceph mon getmap -o ${MONMAP}
systemctl stop ${SERVICE}
sleep 2
mv /var/lib/ceph/mon/ceph-${ME} /var/lib/ceph/mon/ceph-${ME}.bak
ceph-mon -i ${ME} --mkfs --monmap ${MONMAP} --keyring /var/lib/ceph/mon/ceph-${ME}.bak/keyring
chown -R ceph:ceph /var/lib/ceph/mon/ceph-${ME}
systemctl start ${SERVICE}
rm -fr /var/lib/ceph/mon/ceph-${ME}.bak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment