├── README.md ├── auto.cnf ├── check_node.sh ├── conn_node.sh ├── init.lst ├── init.sh ├── reset_node.sh ├── s.cnf ├── start_node.sh └── stop_node.sh /README.md: -------------------------------------------------------------------------------- 1 | # mysql_mgr_test 2 | use script to create MySQL Group Replication environments fast and efficiently. 3 | 4 | 1. download MySQL installation packages. www.mysql.com and ensure IP is configured is /etc/hosts. 5 | for example, /etc/hosts as below, 10.127.1.18 is current machine IP, and mysqltestdb is hostname,else MGR creation will have issues. 6 | 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 7 | ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 8 | 10.127.1.18 mysqltestdb 9 | 10 | 2. change parameters from file auto.cnf following your environment needs. 11 | for example, change below parameter values, you need to put mysql running path to /usr/local/mysql and create directory /home/data 12 | these can be changed following your needs. 13 | 14 | base_dir=/usr/local/mysql 15 | base_data_dir=/home/data 16 | 17 | 3. config file init.lst following your environments needs. 18 | for example ,I need to crate 5 nodes in one machine, I should config init.lst as below. 19 | 24801 s1 24901 Y 20 | 24802 s2 24902 Y 21 | 24803 s3 24903 Y 22 | 24804 s4 24904 Y 23 | 24805 s5 24905 Y 24 | 25 | 4. run script init.sh to start MGR environments creation. 26 | 27 | if you need to create single Primary environments, you should put seconds onwards rows, the last values as N,for example. 28 | 24801 s1 24901 Y 29 | 24802 s2 24902 N 30 | 24803 s3 24903 N 31 | 24804 s4 24904 N 32 | 24805 s5 24905 N 33 | if you need to create multi-Primary environments, you should put node role as Y, for example. 34 | 24801 s1 24901 Y 35 | 24802 s2 24902 Y 36 | 24803 s3 24903 Y 37 | 24804 s4 24904 Y 38 | 24805 s5 24905 Y 39 | 40 | 5. use check.sh to check node status, you should use input parameter node_name which is included in init.lst 41 | for example, we want to check node status ,node name is s2 which is from init.lst 42 | I should use below command to check 43 | sh check_node.sh s2 44 | 45 | 6. enjoy and feedback if you have more questions, mail to jeanrock@126.com 46 | -------------------------------------------------------------------------------- /auto.cnf: -------------------------------------------------------------------------------- 1 | # This file should be configured following your needs 2 | export base_dir=/usr/local/mysql_5.7 3 | export base_data_dir=/U01/mgr 4 | -------------------------------------------------------------------------------- /check_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | new_node_name=$1 3 | . ./auto.cnf 4 | 5 | if [[ -z ${new_node_name} ]]; then 6 | echo Node Name is needed ~~~ 7 | exit 8 | fi 9 | node_port=`cat init.lst|grep -w ${new_node_name}|awk '{print $1}'` 10 | node_name=`cat init.lst|grep -w ${new_node_name}|awk '{print $2}'` 11 | echo ${node_port} 12 | if [[ ${node_name} = ${new_node_name} ]];then 13 | ${base_dir}/bin/mysql -P${node_port} -S ${base_data_dir}/${node_name}/${node_name}.sock -e "select uuid(); select *from performance_schema.replication_group_members;" 14 | ${base_dir}/bin/mysql -P${node_port} -S ${base_data_dir}/${node_name}/${node_name}.sock -e " select *from performance_schema. replication_group_member_stats \G" 15 | else 16 | echo Node Name not found in init.lst ~~~ 17 | fi 18 | -------------------------------------------------------------------------------- /conn_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | new_node_name=$1 3 | . ./auto.cnf 4 | 5 | if [[ -z ${new_node_name} ]]; then 6 | echo Node Name is needed ~~~ 7 | exit 8 | fi 9 | node_name=`cat init.lst|grep -w ${new_node_name}|awk '{print $2}'` 10 | if [[ ${node_name} = ${new_node_name} ]];then 11 | ${base_dir}/bin/mysql -P${node_port} -S ${base_data_dir}/${node_name}/${node_name}.sock 12 | else 13 | echo Node Name not found in init.lst ~~~ 14 | fi 15 | -------------------------------------------------------------------------------- /init.lst: -------------------------------------------------------------------------------- 1 | 24801 s1 24901 Y 2 | 24802 s2 24902 Y 3 | 24803 s3 24903 Y 4 | 24804 s4 24904 Y 5 | 24805 s5 24905 Y 6 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ./auto.cnf 3 | base_conf_dir=`pwd` 4 | 5 | init_node_flag=`cat init.lst|head -1|awk '{print $4}'` 6 | 7 | function get_seed_list 8 | { 9 | while read line 10 | do 11 | tmp_port='127.0.0.1:'`echo $line|awk '{print $3}'` 12 | echo ${tmp_port} 13 | done