91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何重寫啟動腳本

發布時間:2020-06-03 21:46:07 來源:億速云 閱讀:342 作者:Leah 欄目:MySQL數據庫

這篇文章給大家分享的是重寫啟動腳本的方法,相信大部分人都還沒學會這個技能,為了讓大家學會,給大家總結了以下內容,話不多說,一起往下看吧。

!/bin/bash

user=root
port=3306
CmdPath=/opt/mysql/bin
password=xxxxxxxxxx

base_dir=/opt/mysql
inst_dir=/data/3306
alive="00"
sMysqld=0
sMysqldSafe=0
fSock=0
fPID=0

check_alive()
{
echo "running check_alive..."      
if [ ps -ef | grep $port | grep -v grep | grep 'mysqld ' |awk '{print $2}' ];then
echo "Process mysqld is running!"
sMysqld=1
else
echo "Process mysqld is not running!"
sMysqld=0       
fi

   

if [  `ps -ef | grep 3306 | grep -v grep | grep 'mysqld_safe' |awk '{print $2}'` ];then

       echo "Process mysqld_safe is running!"        sMysqldSafe=1 else    echo "Process mysqld_safe is not running!"    sMysqldSafe=0     fi     if [ -e  ${inst_dir}/mysql.sock ];then        echo "socked file exists!"        fSock=1 else    echo "socked file not exists!"    fSock=0     fi     if [ -e  ${inst_dir}/mysql.pid ];then        echo "pid file exists!"        fPID=1 else    echo "pid file  not exists!"    fPID=0     fi     if [ $sMysqld -eq 1 ];then        if [ $fPID -eq 0 ];then            echo "PID is missing, tring to recreate..."            ps -ef | grep $port | grep -v grep | grep 'mysqld ' |awk '{print $2}' > ${inst_dir}/mysql.pid            if [ -e ${inst_dir}/mysql.pid ]; then                echo "pid file is created!"            else                echo "can not create PID file, please have a check!"            fi        fi        if [ $sMysqldSafe -eq 0 ];then            echo "Process mysqld_safe is missing, please have a check! May cause mysqld crash!"        fi        if [ $fSock -eq 1 ];then            echo "MySQL running fine!!!"            alive="11"        else            echo "socket file is missing, you may have to login without socket!"            alive="10"                  fi                               else        echo "process mysqld is missing, mysql is stopped!"        if [ $fSock -eq 1 ] | [ $fPID -eq 1 ];then            echo "mysql was stopped abnormality!"            echo "cleaning socket file and pid file"            alive="01"        else            alive="00"    fi

    fi

}

start_mysql()
{   
check_alive 
printf "MySQL is starting ... \n"
if [ $alive == "00" ]; then
${CmdPath}/mysqld_safe --defaults-file=${inst_dir}/my.cnf --user=${user} 2>&1 >/dev/null &
else
if [  $alive == "11" ]; then
echo "MySQL is runnig!"
else
if [ $alive == "01" ]; then
echo "MySQL was stopped but pid or sock file still exits!"
echo "Cleanning pid or sock files!"
if [ $fSock -eq 1 ];then
rm -f ${inst_dir}/mysql.sock
fi
if [ $fPID -eq 1 ];then
rm -f ${inst_dir}/mysql.pid
fi
echo "Tring to start MySQL again!!!"
${CmdPath}/mysqld_safe --defaults-file=${inst_dir}/my.cnf --user=${user} 2>&1 >/dev/null &
fi
fi
fi
}

stop_mysql()
{
check_alive
printf "MySQL is Stopping...\n" 
if [ $alive == "11" ]; then
${CmdPath}/mysqladmin -u root -p${password} -S ${inst_dir}/mysql.sock shutdown 2>&1 >/dev/null &       
else
if [ $alive == "10" ]; then
${CmdPath}/mysqladmin -u root -p${password} -h $HOSTNAME -P $port --protocol tcp shutdown 2>&1 >/dev/null &
else
echo "MySQL is not running, no need stop!" 
fi               
fi
}

restart_mysql()
{
stop_mysql
sleep 5
if [ $? == 0 ];then
start_mysql
else
echo "stop mysql failed!"
fi
}

case $1 in

start)
start_mysql
;;
stop)
stop_mysql       
;;
restart)
restart_mysql
;;
status)
status_mysql
;;
alive)
check_alive
;;
*)
printf "Please in put start|stop|restart|status as input"
;;
esac


}

以上就是重寫啟動腳本的方法,代碼示例簡單明了,如果在日常工作遇到此問題。通過這篇文章,希望你能有所收獲,更多詳情敬請關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

巴塘县| 舟山市| 子洲县| 南昌县| 元江| 宜君县| 邯郸市| 科尔| 洪江市| 方城县| 泰顺县| 关岭| 贡觉县| 桦南县| 玛沁县| 沂南县| 进贤县| 攀枝花市| 桓台县| 巍山| 呼玛县| 永平县| 合水县| 昌江| 赤峰市| 东平县| 定结县| 河东区| 庆安县| 九台市| 通州市| 湖口县| 南漳县| 蛟河市| 壶关县| 玉田县| 安国市| 长海县| 富宁县| 西峡县| 土默特右旗|