Onsql和MySQL的啟停指令碼,onsqlmysql指令碼

來源:互聯網
上載者:User

Onsql和MySQL的啟停指令碼,onsqlmysql指令碼


啟停onesql,總共四個參數{start|stop|restart|status},只要稍微改一下頭部的三個檔案路徑,即可完成mysql單一實例的啟停。

[#9(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 Usage:sh /etc/init.d/onesql5.6.26  {start|stop|restart|status}

詳細執行效果如下:

[#2(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 statusThere is no mysqld process  ! [#3(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 stopThe mysqld process is already stopped ! [#4(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 startStarting MySQL.150830 13:15:06 mysqld_safe Logging to '/data/mysql/mysql_3307/logs/error3307.log'.150830 13:15:06 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3307/dataStarting MySQL.. SUCCESS! [#5(zhouxx_vm(node3:192.168.56.103))#root@node3~]#[#5(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 statusroot      2319     1  2 13:15 pts/0    00:00:00 /bin/sh /usr/local/onesql5.6/bin/mysqld_safe --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --user=mysql --datadir=/data/mysql/mysql_3307/data --basedir=/usr/local/onesql5.6mysql     3163  2319 44 13:15 pts/0    00:00:02 /usr/local/onesql5.6/bin/mysqld --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --basedir=/usr/local/onesql5.6 --datadir=/data/mysql/mysql_3307/data --plugin-dir=/usr/local/onesql5.6/lib/plugin --user=mysql --log-error=/data/mysql/mysql_3307/logs/error3307.log --open-files-limit=58000 --pid-file=/data/mysql/mysql_3307/logs/mysql_3307.pid --socket=/tmp/mysql_3307.sock --port=3307MySQL(pid=3163) Status  --------------/usr/local/onesql5.6/bin/mysql  Ver 14.14 Distrib 5.6.25, for Linux (x86_64) using  EditLine wrapperConnection id:          4Current database:Current user:           root@localhostSSL:                    Not in useCurrent pager:          stdoutUsing outfile:          ''Using delimiter:        ;Server version:         5.6.26-log (OneSQL) Source distributionProtocol version:       10Connection:             Localhost via UNIX socketServer characterset:    utf8Db     characterset:    utf8Client characterset:    utf8Conn.  characterset:    utf8UNIX socket:            /tmp/mysql_3307.sockUptime:                 5 secThreads: 4  Questions: 5  Slow queries: 0  Opens: 18  Flush tables: 1  Open tables: 11  Queries per second avg: 1.000--------------[#6(zhouxx_vm(node3:192.168.56.103))#root@node3~]#[#6(zhouxx_vm(node3:192.168.56.103))#root@node3~]#[#6(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 stop150830 13:15:19 mysqld_safe mysqld from pid file /data/mysql/mysql_3307/logs/mysql_3307.pid endedStopping MySQL SUCCESS! [#7(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 restartThe mysqld process is already stopped ! 150830 13:15:32 mysqld_safe Logging to '/data/mysql/mysql_3307/logs/error3307.log'.150830 13:15:32 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3307/dataStarting MySQL. SUCCESS! [#8(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 statusroot      3266     1  3 13:15 pts/0    00:00:00 /bin/sh /usr/local/onesql5.6/bin/mysqld_safe --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --user=mysql --datadir=/data/mysql/mysql_3307/data --basedir=/usr/local/onesql5.6mysql     4107  3266 63 13:15 pts/0    00:00:02 /usr/local/onesql5.6/bin/mysqld --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --basedir=/usr/local/onesql5.6 --datadir=/data/mysql/mysql_3307/data --plugin-dir=/usr/local/onesql5.6/lib/plugin --user=mysql --log-error=/data/mysql/mysql_3307/logs/error3307.log --open-files-limit=58000 --pid-file=/data/mysql/mysql_3307/logs/mysql_3307.pid --socket=/tmp/mysql_3307.sock --port=3307MySQL(pid=4107) Status  --------------/usr/local/onesql5.6/bin/mysql  Ver 14.14 Distrib 5.6.25, for Linux (x86_64) using  EditLine wrapperConnection id:          4Current database:Current user:           root@localhostSSL:                    Not in useCurrent pager:          stdoutUsing outfile:          ''Using delimiter:        ;Server version:         5.6.26-log (OneSQL) Source distributionProtocol version:       10Connection:             Localhost via UNIX socketServer characterset:    utf8Db     characterset:    utf8Client characterset:    utf8Conn.  characterset:    utf8UNIX socket:            /tmp/mysql_3307.sockUptime:                 4 secThreads: 4  Questions: 5  Slow queries: 0  Opens: 18  Flush tables: 1  Open tables: 11  Queries per second avg: 1.250--------------[#9(zhouxx_vm(node3:192.168.56.103))#root@node3~]#


詳細指令碼

[#10(zhouxx_vm(node3:192.168.56.103))#root@node3~]#cat /etc/init.d/onesql5.6.26 #!/bin/sh##source /etc/profile#MYSQL_HOME=/usr/local/mysql5.6.26MYSQL_HOME=/usr/local/onesql5.6datadir=/data/mysql/mysql_3307/datamysql_cnf="/data/mysql/mysql_3307/my_3307.cnf"mysql_sock="/tmp/mysql_3307.sock"function start(){mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`if [ "0" = "$mysqld_pid"0 ]then            $MYSQL_HOME/bin/mysqld_safe --defaults-file="$mysql_cnf" --user=mysql --datadir="$datadir" --basedir="$MYSQL_HOME" &            sleep 1            mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`            mysqld_pid1="$mysqld_pid"0            pppct="."            while  [[ $mysqld_pid1 -lt 1 ]]            do                 mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`                 mysqld_pid1="$mysqld_pid"0                 if  [ $mysqld_pid1 -gt 1 ]                 then                      #clear                      echo "Starting MySQL$pppct SUCCESS! "                 else                      #clear                      echo "Starting MySQL$pppct"                 fi                 pppct="$pppct."                 sleep 1            doneelse    echo "A mysqld process already exists ! pid:$mysqld_pid"fi}function stop(){mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`if [ "0" = "$mysqld_pid"0 ]then   echo "The mysqld process is already stopped ! "else#/usr/local/mysql/bin/mysqladmin –S "$mysql_sock" shutdown &$MYSQL_HOME/bin/mysqladmin  -S "$mysql_sock" shutdown &sleep 2mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`if [ "0" = "$mysqld_pid"0 ]then    echo "Stopping MySQL$pppct SUCCESS! "else   mysqld_pid1="$mysqld_pid"0   pppct="."   while  [ "$mysqld_pid1" != "0" ]   do      mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`      mysqld_pid1="$mysqld_pid"0      if  [ "$mysqld_pid1" = "0" ]      then           #clear           echo "Stopping MySQL$pppct SUCCESS! "      else           #clear           echo "Stopping MySQL$pppct"      fi      pppct="$pppct."      sleep 1   donefifi}function status(){mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'`if [ "0" = "$mysqld_pid"0 ]then   echo "There is no mysqld process  ! "else   echo -e "\n"   ps -ef|grep mysqld|grep "$mysql_cnf"|grep -v grep   echo -e "MySQL(pid=$mysqld_pid) Status \n "   #mysqladmin  -S "$mysql_sock" status     $MYSQL_HOME/bin/mysql -S "$mysql_sock"   -e "\s;"   echo -e "\n"fi}case "$1" instart)    start  ;;stop)     stop    ;;status)       status  ;;restart)       stop       start  ;;*)     echo "Usage:sh $0  {start|stop|restart|status}" esacexit[#11(zhouxx_vm(node3:192.168.56.103))#root@node3~]#




著作權聲明:聲明:本文檔可以轉載,須署名原作者。 作者:無為 qq:490073687

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.