mysql主从自动部署

#!/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 [email protected] > /dev/null < 
 

  

你可能感兴趣的:(mysql主从自动部署)