keepalived: nodedb1_start.sh

File nodedb1_start.sh, 1.6 KB (added by krit, 2 years ago)
Line 
1#!/usr/bin/bash
2
3logfile=/tmp/nodedb1.log
4container_name=nodedb1
5/usr/bin/docker start $container_name
6echo "docker start $container_name" >> $logfile
7sleep 10
8if [ "$( docker container inspect -f '{{.State.Status}}' $container_name )" == "running" ]; then
9   echo "$container_name is running" >> $logfile
10else
11   echo "$container_name is not running, we will start again" >> $logfile
12   /usr/bin/docker start $container_name
13   echo "start $container_name Done!!" >> $logfile
14fi
15
16if [ "$( docker container inspect -f '{{.State.Status}}' $container_name )" == "running" ]; then
17   cmd1="/usr/bin/docker exec -i $container_name mysql -uroot -pmypass -e \"STOP GROUP_REPLICATION;\" \
18                      -e \"SET @@GLOBAL.group_replication_group_name='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';\" \
19                      -e \"SET @@GLOBAL.group_replication_local_address='$container_name:33061';\"\
20                      -e \"SET @@GLOBAL.group_replication_group_seeds='$container_name:33061,nodedb2:33061,nodedb3:33061';\" \
21                      -e \"change master to master_user='repl' for channel 'group_replication_recovery';\" \
22                      -e \"START GROUP_REPLICATION;\"  "
23   echo "$cmd1" >> $logfile
24   eval "$cmd1" 2> /tmp/err.log 1>> $logfile
25   sleep 10
26   echo "$container_name join group_replication" >> $logfile
27   cmd2="/usr/bin/docker exec -i $container_name mysql -uroot -pmypass -e \"SELECT * FROM performance_schema.replication_group_members;\" "
28   echo "$cmd2" >> $logfile
29   eval "$cmd2" 2> /tmp/err.log 1>> $logfile
30else
31   echo "$container_name still not start" >> $logfile
32fi