passwd=123456
User=root
rep_host=10.10.10.70
rep_port=3306
Rep_user=slave
[Email protected]
rep_file=mysql-bin.000021
rep_pos=863718
if [!-f/var/lock/mysql-zc.lock];then
Mysql-u$user-p$passwd-e "Change Master to master_host= ' $REP _host ', master_port= $REP _port, master_user= ' $REP _user ', master_password= ' $REP _passwd ', master_log_file= ' $REP _file ', master_log_pos= $REP _pos; "
Touch/var/lock/mysql-zc.lock
Fi
Start () {
if [!-f/var/lock/mysql-start.lock];then
Mysql-u$user-p$passwd-e "Start slave;"
Sleep 1
Mysql-u$user-p$passwd-e "show slave status\g;" | Grep-e "Slave_sql_running| Slave_io_running "
Touch/var/lock/mysql-start.lock
[-f/var/lock/mysql-stop.lock]&&rm-rf/var/lock/mysql-stop.lock
Else
echo "Slave is start!!!"
Fi
}
Stop () {
if [!-f/var/lock/mysql-stop.lock];then
Mysql-u$user-p$passwd-e "Stop Slave;"
Mysql-u$user-p$passwd-e "show slave status\g;" | Grep-e "Slave_sql_running| Slave_io_running "
Touch/var/lock/mysql-stop.lock
[-f/var/lock/mysql-start.lock]&&rm-rf/var/lock/mysql-start.lock
Else
echo "Slave is STOP!!!"
Fi
}
Case "$" in
Start
Start
;;
Stop
Stop
;;
Status
Mysql-u$user-p$passwd-e "show slave status\g;" | Grep-e "Slave_sql_running| Slave_io_running "
;;
*)
echo "usage:start| Stop|status "
;;
Esac
MySQL master-slave configuration script