mysqld與mysqld_safe
啟動例項之後,可以透過ps來檢視一下mysql的程式,發現其中不僅僅有mysqld_safe,還有一個mysqld程式。
op 4546 1 0 13:13 ? 00:00:00 /bin/sh ../bin/mysqld_safe
op 10168 4546 0 13:42 ? 00:00:00 /home/op/software/mysql/bin/mysqld --basedir=/home/op/software/mysql --datadir=/home/op/software/mysql/data --plugin-dir=/home/op/software/mysql/lib/plugin --log-error=/home/op/software/mysql/data/localhost.localdomain.err --pid-file=/home/op/software/mysql/data/localhost.localdomain.pid
op 13814 8439 0 14:01 pts/1 00:00:00 grep mysql
mysqld程式就是最基本的mysql的伺服器了
man mysqld的描述如下:
mysqld, also known as MySQL Server, is the main program that does most
of the work in a MySQL installation. MySQL Server manages access to the
MySQL data directory that contains databases and tables. The data
directory is also the default location for other information such as
log files and status files.
實質上,用rpm或者yum這類包管理的工具,在linux下安裝時,所執行的 service mysqld start也就是啟動的這個程式。
而mysqld_safe呢?我man mysqld_safe了一下:
mysqld_safe is the recommended way to start a mysqld server on Unix.
mysqld_safe adds some safety features such as restarting the server
when an error occurs and logging runtime information to an error log
file. A description of error logging is given later in this section.
mysqld_safe tries to start an executable named mysqld. To override the
default behavior and specify explicitly the name of the server you want
to run, specify a --mysqld or --mysqld-version option to mysqld_safe.
You can also use --ledir to indicate the directory where mysqld_safe
should look for the server.
按mysqld_safe的manual資訊來說,它是一個當mysqld崩掉以後,能夠再次將mysqld啟動起來的程式。
測試:
op 4546 1 0 13:13 ? 00:00:00 /bin/sh ../bin/mysqld_safe
op 10168 4546 0 13:42 ? 00:00:00 /home/op/software/mysql/bin/mysqld --basedir=/home/op/software/mysql --datadir=/home/op/software/mysql/data --plugin-dir=/home/op/software/mysql/lib/plugin --log-error=/home/op/software/mysql/data/localhost.localdomain.err --pid-file=/home/op/software/mysql/data/localhost.localdomain.pid
op 19643 8439 0 14:31 pts/1 00:00:00 grep mysql
[op@localhost ~]$ kill -9 10168
[op@localhost ~]$ ps -ef | grep mysql
op 4546 1 0 13:13 ? 00:00:00 /bin/sh ../bin/mysqld_safe
op 19702 4546 4 14:31 ? 00:00:00 /home/op/software/mysql/bin/mysqld --basedir=/home/op/software/mysql --datadir=/home/op/software/mysql/data --plugin-dir=/home/op/software/mysql/lib/plugin --log-error=/home/op/software/mysql/data/localhost.localdomain.err --pid-file=/home/op/software/mysql/data/localhost.localdomain.pid
op 19736 8439 0 14:31 pts/1 00:00:00 grep mysql
此時,mysqld的程式號被修改為19702(之前是10168)
其父程式仍然為4546。
mysqld在mysqld_safe的“守衛”下,再一次的被啟動起來。
正常關閉mysql:
[op@localhost bin]$ ./mysqladmin shutdown -uroot -p
Enter password:
[op@localhost bin]$ ps -ef | grep mysql
op 21877 21454 0 14:42 pts/0 00:00:00 grep mysql
重新啟動之後:
[op@localhost bin]$ ps -ef |grep -v ‘grep’ | grep mysql
op 22482 1 0 14:45 pts/0 00:00:00 /bin/sh ./mysqld_safe
op 22568 22482 1 14:45 pts/0 00:00:00 /home/op/software/mysql/bin/mysqld --basedir=/home/op/software/mysql --datadir=/home/op/software/mysql/data --plugin-dir=/home/op/software/mysql/lib/plugin --log-error=/home/op/software/mysql/data/localhost.localdomain.err --pid-file=/home/op/software/mysql/data/localhost.localdomain.pid
[op@localhost bin]$ kill -9 22482
[op@localhost bin]$ ps -ef |grep -v 'grep'| grep mysql
op 22568 1 0 14:45 pts/0 00:00:00 /home/op/software/mysql/bin/mysqld --basedir=/home/op/software/mysql --datadir=/home/op/software/mysql/data --plugin-dir=/home/op/software/mysql/lib/plugin --log-error=/home/op/software/mysql/data/localhost.localdomain.err --pid-file=/home/op/software/mysql/data/localhost.localdomain.pid
殺掉父程式也就是mysqld_safe之後,檢查一下,確實殺掉了。
再次殺掉mysqld程式:
[op@localhost bin]$ kill -9 22568
[op@localhost bin]$ ps -ef |grep -v 'grep'| grep mysql
[op@localhost bin]$
發現已經沒有mysql相關程式了。
說明在mysqld_safe的情況下,mysqld如果“意外”退出,mysqld_safe會守衛mysqld,並保證其一直啟動。
作者公眾號(持續更新)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-1782187/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysqld_safe和mysqldMySql
- mysqld和mysqld_safeMySql
- Mysqld_safe支援選項MySql
- [mysqld_safe] 中的引數使用mysqld_safe命令啟動時不生效?MySql
- mysqld_safe之三言兩語MySql
- mysql關於mysqld_safe的總結MySql
- mysql配置檔案中mysqld_safe介紹MySql
- Starting MySQL * Couldn't find MySQL server (/usr/bin/mysqld_safe)MySqlServer
- 【MySQL】mysql啟動常見報錯 mysqld_safe mysqld from pid file hostname.pid endedMySql
- 【Mysql學習】mysqld_safe:MySQL伺服器啟動指令碼MySql伺服器指令碼
- 【MySQL】mysql啟動報錯./mysqld_safe: my_print_defaults: not foundMySql
- 【Mysql 學習】mysqld_safe:MySQL伺服器啟動指令碼MySql伺服器指令碼
- mysqld或mysqld_safe啟動時必須放在第一位的引數(first argument)MySql
- mysqld --verboseMySql
- my.cnf中[mysql]與[mysqld]下引數的區別MySql
- mysqld --skip-grant-tablesMySql
- mysqld got signal 8MySqlGo
- mysqld: Sort aborted: Server shutdown in progressMySqlServer
- mysql 5.0.41 mysqld 引數大全MySql
- mysqld_multi 無法停庫MySql
- mysqld_multi 命令使用報錯MySql
- 不重啟mysqld更改root密碼MySql密碼
- nysql 5.0.22 mysqld 引數大全MySql
- ERROR 2002 (HY000): Can't connect server socket /var/run/mysqld/mysqld.sockErrorServerMySql
- MySQL入門--Mysqld_multi多例項MySql
- Mysqld接受許多命令列選項MySql命令列
- (slave不停restart)mysqld got signal 11RESTMySqlGo
- mysql服務啟動報錯Redirecting to systemctl start mysqld.serviceFailed to start mysqld.service:Unit not found.MySqlAI
- 怎麼樣把mysqld壓測到崩潰重啟?什麼情況下mysqld崩潰重啟?MySql
- pprof 分析mysqld 記憶體呼叫(筆記)MySql記憶體筆記
- 利用mysqld_multi配置單機多例項MySql
- 利用pgrep批量kill殺死多個mysqld程式MySql
- 【MySQL】mysqld got signal 11 案例一則MySqlGo
- mysqld: Table '.mac_vod' is marked as crashed and should be repairedMySqlMacAI
- mysqld_multi安裝多個mysql例項MySql
- mysql使用mysqld_multi工具啟動多例項MySql
- mysqld_multi啟動多個mysql例項MySql
- 執行SQL語句導致mysqld的crashMySql