下載croncie 使用rmp方式安裝 **文件在個人微雲 **mysql
amoeba安裝和配置sql
#!/bin/sh # check_mysql_slave status ip=eth0 #網卡名稱 mysql_binfile=mysql mysql_user=root #MySQL數據庫帳號 mysql_pass='' #密碼 mysql_sockfile=/var/lib/mysql/mysql.sock datetime=`date +"%Y-%m-%d/%H:%M:%S"` #獲取當前時間 mysql_slave_logfile=/home/logs/check_mysql_slave.log #日誌文件路徑,必須提早建立好 slave_ip=`ifconfig $ip|grep "inet addr" | awk -F[:" "]+ '{print $4}'` mastatus="$mysql_binfile -h 118.xx8.xx.52 -u$mysql_user -p$mysql_pass -P 3306" file=`$mastatus -e "show master status\G" | grep File | awk ' {print $2}'` pos=`$mastatus -e "show master status\G" | grep Position | awk ' {print $2}'` echo "$datetime mastatus $mastatus" >> $mysql_slave_logfile echo "$datetime file=$file pos=$pos" >> $mysql_slave_logfile status=$($mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "show slave status\G" | grep -i "running") Slave_IO_Running=`echo $status | grep Slave_IO_Running | awk ' {print $2}'` Slave_SQL_Running=`echo $status | grep Slave_SQL_Running | awk '{print $2}'` if [ "$Slave_IO_Running" = "Yes" -a "$Slave_SQL_Running" = "Yes" ] then echo "$datetime $slave_ip Slave is Running!" >> $mysql_slave_logfile else echo " $datetime $slave_ip Slave is not running!" >> $mysql_slave_logfile $mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "stop slave;change master to master_host='118.xx8.xx.52',master_port=3306,master_user='xxxx',master_password='xxxxx%$^5',master_log_file='$file',master_log_pos=$pos;SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;start slave;" fi