* lighting repo to simple master-slave replication
This commit is contained in:
@ -6,26 +6,20 @@ set -a
|
|||||||
. "${CONFIG_FILE}"
|
. "${CONFIG_FILE}"
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
replication_user=`cat ./.remote.my.cnf | grep user | cut -d'=' -f2`
|
|
||||||
replication_password=`cat ./.remote.my.cnf | grep password | cut -d'=' -f2`
|
|
||||||
replication_host=`cat ./.remote.my.cnf | grep host | cut -d'=' -f2`
|
|
||||||
|
|
||||||
# Установка локально и удаленно MASTER-параметров
|
# Установка локально и удаленно MASTER-параметров
|
||||||
echo "Get master status from remote server" >> $log_file
|
echo "Get master status from remote server" >> $log_file
|
||||||
remote_master_status=`mysql --defaults-extra-file=./.remote.my.cnf -e "SHOW MASTER STATUS;" -N`
|
remote_master_status=`mysql --defaults-extra-file=./.remote.my.cnf -e "SHOW MASTER STATUS;
|
||||||
|
" -N`
|
||||||
|
|
||||||
remote_master_log_file=`echo $remote_master_status | cut -d' ' -f1`
|
remote_master_log_file=`echo $remote_master_status | cut -d' ' -f1`
|
||||||
remote_master_log_pos=`echo $remote_master_status | cut -d' ' -f2`
|
remote_master_log_pos=`echo $remote_master_status | cut -d' ' -f2`
|
||||||
|
|
||||||
echo "Apply bin log position to local mariadb db instance" >> $log_file
|
echo "Apply bin log position to local mariadb db instance" >> $log_file
|
||||||
mysql --defaults-extra-file=./.my.cnf -e "CHANGE MASTER TO MASTER_HOST = '$replication_host', MASTER_USER = '$replication_user', MASTER_PASSWORD = '$replication_password', MASTER_LOG_FILE = '$remote_master_log_file', MASTER_LOG_POS = $remote_master_log_pos;"
|
|
||||||
|
|
||||||
#echo "Get master status from local server" >> $log_file
|
replication_user=`cat ./.remote.my.cnf | grep user | cut -d'=' -f2`
|
||||||
#local_master_status=`mysql --defaults-extra-file=./.my.cnf -e "SHOW MASTER STATUS;" -N`
|
replication_password=`cat ./.remote.my.cnf | grep password | cut -d'=' -f2`
|
||||||
|
replication_host=`cat ./.remote.my.cnf | grep host | cut -d'=' -f2`
|
||||||
|
|
||||||
#local_master_log_file=`echo $local_master_status | cut -d' ' -f1`
|
mysql --defaults-extra-file=./.my.cnf -e "CHANGE MASTER TO MASTER_HOST = '$replication_hos
|
||||||
#local_master_log_pos=`echo $local_master_status | cut -d' ' -f2`
|
t', MASTER_USER = '$replication_user', MASTER_PASSWORD = '$replication_password', MASTER_L
|
||||||
|
OG_FILE = '$remote_master_log_file', MASTER_LOG_POS = $remote_master_log_pos;"
|
||||||
#echo "Apply bin log position to remote mariadb db instance" >> $log_file
|
|
||||||
#TODO: $local_host replace to option --master-to-master=self_ip_address
|
|
||||||
#mysql --defaults-extra-file=./.remote.my.cnf -e "CHANGE MASTER TO MASTER_HOST = '$local_host', MASTER_USER = 'replication_user', MASTER_PASSWORD = 'replication_password', MASTER_LOG_FILE = '$local_master_log_file', MASTER_LOG_POS = $local_master_log_pos;"
|
|
||||||
|
@ -6,33 +6,6 @@ set -a
|
|||||||
. "${CONFIG_FILE}"
|
. "${CONFIG_FILE}"
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
readopt='getopts $opts opt;rc=$?;[ $rc$opt == 0? ]&&exit 1;[ $rc == 0 ]||{ shift $[OPTIND-1];false; }'
|
|
||||||
|
|
||||||
opts=vfdo:
|
|
||||||
|
|
||||||
# Enumerating options
|
|
||||||
#while eval $readopt
|
|
||||||
#do
|
|
||||||
# echo OPT:$opt ${OPTARG+OPTARG:$OPTARG}
|
|
||||||
#done
|
|
||||||
|
|
||||||
# Enumerating arguments
|
|
||||||
databases=( )
|
|
||||||
|
|
||||||
for arg
|
|
||||||
do
|
|
||||||
databases=( $databases $arg )
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -z "$databases" ]]; then
|
|
||||||
cat <<EOF
|
|
||||||
Usage: $0 database_one [...database_two]
|
|
||||||
EOF
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Set replication databases to: ${databases[@]}"
|
|
||||||
|
|
||||||
for i in ${databases[@]}
|
for i in ${databases[@]}
|
||||||
do
|
do
|
||||||
REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
|
REMOTE_SQL=$REMOTE_SQL' USE '$i'; FLUSH TABLES WITH READ LOCK;'
|
||||||
|
Reference in New Issue
Block a user