Skip to content

Instantly share code, notes, and snippets.

@Kallio
Last active November 4, 2021 15:01
Show Gist options
  • Select an option

  • Save Kallio/be5b57ea09c5ad2014eb7feec1bc06e5 to your computer and use it in GitHub Desktop.

Select an option

Save Kallio/be5b57ea09c5ad2014eb7feec1bc06e5 to your computer and use it in GitHub Desktop.
#!/bin/bash
osds=`ls -d /var/lib/ceph/osd/ceph-* |grep -o [0-9]*$`
noop=0
for osd in $osds; do
date
echo "Starting trimming for ${osd}"
if [ $noop -eq 1 ] ; then
echo "systemctl disable --now ceph-osd@${osd}"
else
systemctl disable --now ceph-osd@${osd}
fi
if [ $noop -eq 1 ] ; then
echo 'CEPH_ARGS="--bluestore_hybrid_alloc_mem_cap=0 " ceph-objectstore-tool --op list-pgs --data-path /var/lib/ceph/osd/ceph-${osd} >/tmp/trimming${osd}.txt'
echo "" > /tmp/trimming${osd}.txt
else
date; CEPH_ARGS="--bluestore_hybrid_alloc_mem_cap=0 " ceph-objectstore-tool --op list-pgs --data-path /var/lib/ceph/osd/ceph-${osd} >/tmp/trimming${osd}.txt
fi
wc -l /tmp/trimming${osd}.txt
pgs=`cat /tmp/trimming${osd}.txt`
for pg in $pgs; do
if [ $noop -eq 1 ] ; then
echo 'CEPH_ARGS="--bluestore_hybrid_alloc_mem_cap=0" ceph-objectstore-tool --op trim-pg-log --data-path /var/lib/ceph/osd/ceph-${osd} --pgid ${pg}'
else
date; CEPH_ARGS="--bluestore_hybrid_alloc_mem_cap=0" ceph-objectstore-tool --op trim-pg-log --data-path /var/lib/ceph/osd/ceph-${osd} --pgid ${pg}
fi
done
if [ $noop -eq 1 ] ; then
echo "systemctl enable --now ceph-osd@${osd}"
else
systemctl enable --now ceph-osd@${osd}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment