Onsql and MySQL start-stop scripts

Source: Internet
Author: User


Start-Stop Onesql, a total of four parameters {Start|stop|restart|status}, as long as a slight change in the head of the three file path, you can complete the start and stop MySQL single instance.

[#9 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~] #service onesql5.6.26 usage:sh/etc/init.d/onesql5.6.26  {Start|stop|restart|status}

Detailed execution results are as follows:

[#2 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~] #service onesql5.6.26 statusthere is no mysqld process! [#3 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~] #service onesql5.6.26 stopthe mysqld process is already Stopped! [#4 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~] #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)) #[email protected]~]#[#5 (ZHOUXX_VM (node3:192.168.56.103)) #[email  protected]~] #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 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: [Email          protected]ssl: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 Querie s per second avg:1.000--------------[#6 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~]#[#6 (ZHOUXX_VM ( node3:192.168.56.103)) #[email protected]~]#[#6 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~]# 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)) #[email protected]~] #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)) #[email protected]~] #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 13:15 pts/0 00:00:02/usr/local/onesql5.6/bin/mysqld--defaults-fil E=/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) US                    ing editline wrapperconnection id:4current database:current User: [Email protected]ssl: 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 charact  Erset:utf8conn. Characterset:utf8unix socket:/tmp/mysql_3307.sockuptime:4 secthreads:4 questions:5 Sl ow queries:0 opens:18 Flush tables:1 Open tables:11 queries per second avg:1.250--------------[#9 (ZHOUXX_VM (node3 : 192.168.56.103)) #[email protected]~]#


Detailed script

[#10 (ZHOUXX_VM (node3:192.168.56.103)) #[email protected]~] #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 $} ' 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 ' {p            Rint "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 $ {} ' mysqld_pid1= ' $mysqld _pid ' 0 if [$MYSQLD_PID1-GT 1] Then #clear echo "Starting mysql$pppct Succe Ss!                 "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 $} ' 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 $} ' 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 $} ' 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 $ "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" #m   Ysqladmin-s "$mysql _sock" status $MYSQL _home/bin/mysql-s "$mysql _sock"-E "\s;" Echo-e "\ n" fi}case "$" instart) start; stop) stop;; status) status; restart) stop start;; *) echo "Usage:sh $ {start|stop|restart|status}" esacexit[#11 (ZHOUXX_VM (node3:192.168.56.103)) #[email  protected]~]#




Copyright NOTICE: Disclaimer: This document can be reproduced, must be signed by the original author. Inaction qq:490073687

Onsql and MySQL start-stop scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.