From b659ca769d47ff6c9512c52cc81ffd32c70a1a88 Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 13 Mar 2014 19:55:12 +0100 Subject: added bigcouch_compact_all_shards.sh (#4798) --- bigcouch_compact_all_shards.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 bigcouch_compact_all_shards.sh diff --git a/bigcouch_compact_all_shards.sh b/bigcouch_compact_all_shards.sh new file mode 100755 index 0000000..2d46a9b --- /dev/null +++ b/bigcouch_compact_all_shards.sh @@ -0,0 +1,29 @@ +#!/bin/sh -e + +SHARDSDIR='/opt/bigcouch/var/lib/' +NETRC='/etc/couchdb/couchdb.netrc' +SIZE='1M' + +#shards=`find ${SHARDSDIR}/shards/ -name '*5a66957c1c93aa637d241484912c61f8*' -size +${SIZE}` +shards=`find ${SHARDSDIR}/shards/ -type f -size +${SIZE}` + +echo +echo "Disk usage before: `df -h $SHARDSDIR`" +echo + +for i in $shards +do + shard=`echo $i | sed "s/^.*shards\///" | cut -d'/' -f 1` + db=`basename $i .couch` + #echo $shard + #echo $db + echo -n "compacting ${i}:" + curl -X POST --netrc-file $NETRC -H "Content-Type: application/json" "http://127.0.0.1:5986/shards%2F${shard}%2F${db}/_compact" + sleep 1 +done + +echo +echo "Disk usage after: `df -h $SHARDSDIR`" +echo + +echo "$0 ran successful" -- cgit v1.2.3