(3.5)mysql基礎深入——mysqld_safe腳本功能及流程


(3.5)mysql基礎深入——mysqld_safe腳本功能及流程

目錄 

1、mysqld_safe過程總結

2、mysql_safe啟動的好處

3、mysqld_safe 參數

4、mysqld_safe流程

 

詳情:

1、mysqld_safe過程總結

  【1.1】檢查環境變量  【1.2】檢查配置文件中的選項  【1.3】啟動mysqld及啟動后的一些處理

2、mysql_safe啟動的好處

  【2.1】安全性好(出現問題重啟的時候,會向錯誤日志里面寫入相關運行時間)

  【2.2】啟動時指定一些關於mysqld_safe的參數,也可以放在my.cnf里的 [mysqld_safe]

  【2.3】ulimit -c $core_file_size(文件大小)

  【2.4】unlimit -n $size(最多支持的打開文件數量)

  【2.5】檢查環境變量,檢查配置文件,檢查指定的選項

3、mysqld_safe 參數

  

 --no-defaults              Don't read the system defaults file
  --defaults-file=FILE       Use the specified defaults file
  --defaults-extra-file=FILE Also use defaults from the specified file

 Other options:
  --ledir=DIRECTORY          Look for mysqld in the specified directory
  --open-files-limit=LIMIT   Limit the number of open files
  --core-file-size=LIMIT     Limit core files to the specified size
  --timezone=TZ              Set the system timezone
  --malloc-lib=LIB           Preload shared library LIB if available
  --mysqld=FILE              Use the specified file as mysqld
  --mysqld-version=VERSION   Use "mysqld-VERSION" as mysqld
  --nice=NICE                Set the scheduling priority of mysqld
  --plugin-dir=DIR           Plugins are under DIR or DIR/VERSION, if
                             VERSION is given
  --skip-kill-mysqld         Don't try to kill stray mysqld processes
  --syslog                   Log messages to syslog with 'logger'
  --skip-syslog              Log messages to error log (default)
  --syslog-tag=TAG           Pass -t "mysqld-TAG" to 'logger'
  --mysqld-safe-log-         TYPE must be one of UTC (ISO 8601 UTC),
    timestamps=TYPE          system (ISO 8601 local time), hyphen
                             (hyphenated date a la mysqld 5.6), legacy
                             (legacy non-ISO 8601 mysqld_safe timestamps)

4、mysqld_safe流程

【4.1】查看basedir和ledir

【4.2】查看datadir和my.cnf

【4.3】對my.cnf做一些檢查

【4.4】解析My.cnf中的組 [mysqld] 和 [mysqld_safe] 並和中毒案例輸入的命令合並。

【4.5】調用parse_arguments函數解析用戶傳遞(就是【4】中的)的所有參數($@)

【4.6】對系統日志和錯誤日志的判斷和做出相應的處理,及選項--err-log參數的復制。

【4.7】對選項--user , --pid-file , --socket 及 --port 進行處理及復制,保證啟動時如果不給出這些參數也會有值。

【4.8】啟動mysqld

  (1)啟動時會判斷一個進程號是否存在,如果存在那么久在錯誤日志中記錄 "A mysqld process already exists" 並且退出

  (2)如果不存在就刪除進程文件,如果刪除不了,那么久在錯誤日志中記錄 "Fatal error : Can't remove the pid file" 並退出。

【4.9】啟動時對表進行檢查。如果啟動的時候檢查表的話設置key_buffer and sort_buffer 會提高速度並且減少磁盤空間的使用。

【4.10】如果啟動時什么參數都沒有顯示指定,那么它會選用一些特定的參數,具體參數看【3】

【4.11】如果服務器異常關閉,那么會restart。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM