#!/bin/bash yum -y install mariadb mariadb-server systemctl stop firewalld setenforce 0 cat /etc/my.cnf|grep server-id if [ $? -ne 0 ];then sed -i '10a server-id=1\nlog-bin=MysqL-bin\nrelay-log=MysqL-relay' /etc/my.cnf fi systemctl restart mariadb if [ $? -ne 0 ];then systemctl stop mariadb systemctl start mariadb fi MysqL -e "grant all on *.* to 'tom'@'10.0.0.%' identified by'123';" MysqL -e "flush privileges;" log_file=`MysqL -e "show master status;"|grep MysqL-bin|awk '{print $1}'` log_pos=`MysqL -e "show master status;"|grep MysqL-bin|awk '{print $2}'` ssh root@10.0.0.46 > /dev/null <<eeooff systemctl stop firewalld setenforce 0 yum -y install mariadb mariadb-server sed -i 's#server-id=2# #g' /etc/my.cnf sed -i 's#log-bin=MysqL-bin# #g' /etc/my.cnf sed -i 's#relay-log=MysqL-relay# #g' /etc/my.cnf sed -i '10a server-id=2\nlog-bin=MysqL-bin\nrelay-log=MysqL-relay' /etc/my.cnf systemctl stop mariadb systemctl start mariadb MysqL -e "stop slave;" MysqL -e "reset slave;" MysqL -e "change master to master_host='10.0.0.45',master_user='tom',master_password='123',master_log_file='$log_file',master_log_pos=$log_pos;\r" MysqL -e "start slave;" exit eeooff echo "ok"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。