Skip to content

Instantly share code, notes, and snippets.

@borama
Created February 6, 2020 15:30
Show Gist options
  • Save borama/0fef678d59ac8dd9604ed1bddc3fcb1b to your computer and use it in GitHub Desktop.
Save borama/0fef678d59ac8dd9604ed1bddc3fcb1b to your computer and use it in GitHub Desktop.
Helper shell script for running the gh-ost tool
#!/bin/bash
function usage {
echo "Use ./run_ghost.sh table_name 'alter_command' [other_ghost_args]"
exit 1
}
database="MY_DATABASE_NAME"
table=$1
shift
if [ "$table" == "" ]; then
usage
fi
alter=$1
shift
if [ "$alter" == "" ]; then
usage
fi
cut_over_file=/root/bin/gh-ost-cut-over.txt
touch $cut_over_file
./gh-ost --host=localhost --conf=/root/.my-ghost.cnf --database=$database \
--table=$table \
--alter="$alter" \
--chunk-size=2000 --max-load=Threads_connected=50 \
--allow-on-master --ssl --ssl-allow-insecure --exact-rowcount \
--initially-drop-ghost-table --initially-drop-socket-file \
--postpone-cut-over-flag-file=$cut_over_file \
--verbose $*
@borama
Copy link
Author

borama commented Feb 7, 2020

This likely won't make much sense without reading the accompanying arcticle at dev.to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment