Ubuntu

在 Ubuntu Lucid 上正確命令關閉 MySQL 和 iSCSI

  • September 17, 2014

我在 Ubuntu 10.04 伺服器上執行 MySQL,MySQL $datadir 位於 iSCSI 卷上。文件系統在/etc/fstab. 在系統關閉時,upstart 向 MySQL 發送一個 SIGTERM,然後繼續關閉網路介面,無需等待 MySQL 退出或 iSCSI 磁碟被解除安裝或斷開連接。當然,這會導致 XFS 無法完全解除安裝,並且 MySQL 需要在啟動時花幾分鐘時間重播 InnoDB 日誌。

我不清楚在正確的地方開始戳來解決這個問題。根據我的閱讀,upstart 應該已經足夠聰明,可以在關閉網路介面之前等待 iSCSI 文件系統解除安裝和斷開連接,儘管這並沒有發生。而且我不知道如何告訴它它還需要等待 MySQL 的完全關閉。

這是控制台在關機過程中顯示的內容:

Broadcast message from root@mysql-a1
   (unknown) at 11:19 ...

The system is going down for halt NOW!
Power button pressed
* Stopping Bacula File daemon...                                        [ OK ]
Stopping file integrity checker: samhain.
* Running nssldap-update-ignoreusers...                                 [ OK ]
* Stopping multipath daemon multipathd                                  [ OK ]
* Stopping nagios-nrpe nagios-nrpe                                      [ OK ]
* Stopping Name Service Cache Daemon nscd                               [ OK ]
* Stopping Postfix Mail Transport Agent postfix                         [ OK ]
* Stopping SSH throttling throttle-ssh                                  [ OK ]
* Stopping puppet agent                                                 [ OK ]
* Stopping system logging syslog-ng                                     [ OK ]
Stopping statistics collection and monitoring daemon: collectdcollectd[1210]: Exiting normally.
collectd[1210]: collectd: Stopping 15 read threads.
collectdmon[1209]: Info: collectd terminated with exit status 0
collectdmon[1209]: Info: shutting down collectdmon
.
* Asking all remaining processes to terminate...                        [ OK ]
* All processes ended within 1 seconds....                              [ OK ]
* Deconfiguring network interfaces...                                          [ 2884.248199] end_request: I/O error, dev dm-0, sector 5216
[ 2884.249807] end_request: I/O error, dev dm-0, sector 4192
[ 2884.817855] end_request: I/O error, dev dm-0, sector 0
[ 2884.819347] XFS (dm-0): Device dm-0: metadata write error block 0x0
[ 2884.821281] XFS (dm-0): I/O Error Detected. Shutting down filesystem
[ 2884.823393] XFS (dm-0): Please umount the filesystem and rectify the problem(s)
[ 2885.367423] end_request: I/O error, dev dm-0, sector 0
init: mysql main process (4168) terminated with status 1
                                                                        [ OK ]
* Deactivating swap...                                                  [ OK ]
* Unmounting weak filesystems...                                        [ OK ]
* Unmounting local filesystems...                                       [ OK ]
* Disconnecting iSCSI targets                                           [ OK ]
* Stopping iSCSI initiator service                                      [ OK ]
* Will now halt
[ 2886.802324] Power down.
Connection to bottom.cw closed.
bottom:~ insyte$

這是 fstab 條目:

/dev/mapper/21db3d79bf30ef4846c9ce90069680087 /srv/mysql xfs  _netdev,noatime,nodev,noexec  0 0

你有幾個選擇:

  1. 升級為精確。問題在那裡得到解決。
  2. 將停止條件(在 /etc/init/mysql.conf 中)更改為stop on starting rc RUNLEVEL=[016]
  3. 進入任何初始化腳本(我很確定它是 sysv)關閉網路介面,並initctl emit deconfiguring-networking在介面關閉之前添加命令。然後,將 mysql 的 stop on 條件更改為stop on deconfiguring-networking or runlevel [016]

中間選項可能是最簡單的。

引用自:https://serverfault.com/questions/628956