Skip to content

Instantly share code, notes, and snippets.

@ksingh7
Created March 11, 2016 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksingh7/ae09f33eded05e8215aa to your computer and use it in GitHub Desktop.
Save ksingh7/ae09f33eded05e8215aa to your computer and use it in GitHub Desktop.
Ceph pool migration
#!/bin/bash
src_pool_name=data
dest_pool_name=data_temp
crush_ruleset=1
pg_count=64
touch pool_migration.log
> pool_migration.log
error(){
echo "Error: $1"
echo "----Error: $1 ----" >> pool_migration.log
}
echo "----Creating destination Pool----" >> pool_migration.log
ceph osd pool create $dest_pool_name $pg_count $pg_count >> pool_migration.log
echo "----setting crush ruleset for destination pool----" >> pool_migration.log
ceph osd pool set $dest_pool_name crush_ruleset $crush_ruleset >> pool_migration.log
echo "----Snapshotting source pool----" >> pool_migration.log
rados -p $src_pool_name mksnap $src_pool_name'-'`date +"%d-%m-%Y-%H-%M-%S"` >> pool_migration.log
echo "----Copying source pool to destination pool----" >> pool_migration.log
rados cppool $src_pool_name $dest_pool_name >> pool_migration.log
if [ $? -eq 0 ]; then
echo "----Renaming source pool----" >> pool_migration.log
ceph osd pool rename $src_pool_name $src_pool_name'_backup'
ceph osd pool rename $dest_pool_name $src_pool_name
if [ ! $? -eq 0 ]; then
message="Unable to rename, pool already exists"
error "$message"
else
echo "Pool migration successfully completed"
echo "----Pool migration successfully completed----" >> pool_migration.log
fi
else
message="Unable to copy $src_poo_name pool contents to $dest_poo_name"
error "$message"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment