Skip to content

Instantly share code, notes, and snippets.

@palmamartin
Forked from wido/ceph-upgrade-hammer-jewel.sh
Last active August 9, 2016 13:37
Show Gist options
  • Save palmamartin/34e35a960b8d44454129ab8721eea4d1 to your computer and use it in GitHub Desktop.
Save palmamartin/34e35a960b8d44454129ab8721eea4d1 to your computer and use it in GitHub Desktop.
Ceph upgrade OSD from Hammer to Jewel
#!/bin/bash
#
# Script for updating a running Ceph Hammer cluster to Jewel
#
# This has to be run on the OSD node(s) as root
#
# Written for and tested on CentOS 7
#
# Used to upgrade Ceph at EURAC Research
#
# Original from: https://gist.github.com/wido/06eac901bd42f01ca2f4f1a1d76c49a6
#
# Adapted to use multiple chown processes, since chowning can take a long time
CEPH_MAJOR_VERSION=$(ceph -v|awk '{print $3}'|cut -d '.' -f 1)
if [ ${CEPH_MAJOR_VERSION} -lt 10 ]; then
echo "Error: This script requires at least Ceph Major version 10"
ceph -v
exit 1
fi
DONE_FILE="/var/tmp/ceph.jewel.upgrade.done"
test -f $DONE_FILE && exit 0
echo "Killing all OSDs"
killall ceph-osd || echo "No running OSDs found"
echo "Changing permissions of /var/lib/ceph"
find /var/lib/ceph/osd -maxdepth 1 -mindepth 1 -print | xargs -P14 -n1 chown -R 167:167
chown 167:167 /var/lib/ceph
chown 167:167 /var/lib/ceph/*
chown 167:167 /var/lib/ceph/bootstrap-*/*
chown 167:167 /var/lib/ceph/tmp/*
echo "Changing permissions of /var/log/ceph"
chown -R ceph:ceph /var/log/ceph
for ID in $(ls /var/lib/ceph/osd/|cut -d '-' -f 2); do
JOURNAL=$(readlink -f /var/lib/ceph/osd/ceph-${ID}/journal)
chown ceph ${JOURNAL}
systemctl start ceph-osd@${ID}.service
systemctl enable ceph-osd@${ID}.service
done
# Try to start the OSDs again due to this bug
# http://tracker.ceph.com/issues/16672
systemctl daemon-reload
echo "Going to sleep for 10s"
sleep 10
for ID in $(ls /var/lib/ceph/osd/|cut -d '-' -f 2); do
systemctl reset-failed ceph-osd@${ID}.service
systemctl start ceph-osd@${ID}.service
done
echo "Going to sleep for 5s"
sleep 5
for ID in $(ls /var/lib/ceph/osd/|cut -d '-' -f 2); do
systemctl reset-failed ceph-osd@${ID}.service
systemctl start ceph-osd@${ID}.service
done
touch $DONE_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment