mysql5.6が突然起動しなくなった件の原因と対策
昨日まで動いてたmysqlが突然起動できなくなった。以下、ログ周りのオプションを変更してみた時のエラーログまとめ
# error1 /usr/sbin/mysqld: File './mysql-bin.000023' not found (Errcode: 28 - No space left on device) 2016-09-14 08:52:37 23762 [ERROR] Could not open mysql-bin for logging (error 28). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it. 2016-09-14 08:52:37 23762 [ERROR] Aborting # error2 /usr/sbin/mysqld: File './mysql-bin.~rec~' not found (Errcode: 28 - No space left on device) 2016-09-14 08:56:13 24546 [ERROR] MYSQL_BIN_LOG::open_purge_index_file failed to open register file. 2016-09-14 08:56:13 24546 [ERROR] MYSQL_BIN_LOG::open failed to sync the index file. 2016-09-14 08:56:13 24546 [ERROR] Aborting # error3 2016-09-14 09:09:32 25665 [ERROR] Can't start server : Bind on unix socket: No space left on device 2016-09-14 09:09:32 25665 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ? 2016-09-14 09:09:32 25665 [ERROR] Aborting # error4 2016-09-14 09:17:20 2022 [ERROR] /usr/sbin/mysqld: Sort aborted: Can't create/write to file '/tmp/MYCUjmDB' (Errcode: 28 - No space left on device)
ディスク容量は問題無い。
# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda3 28G 17G 9.1G 66% / tmpfs 499M 0 499M 0% /dev/shm /dev/vda1 239M 58M 168M 26% /boot
原因はi-node数だった。
# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/vda3 1819680 1819680 0 100% / tmpfs 127509 1 127508 1% /dev/shm /dev/vda1 64000 44 63956 1% /boot
よくよく調べてみるとphpのセッションファイルが大量に作成されていた。
# ll /var/lib/php/session/ | wc -l 1736291
普通に削除しようとしたところエラー
# rm -fr /var/lib/php/session/* -bash: /bin/rm: 引数リストが長すぎます
ファイル数が多すぎる場合はxargsを使わないといけないらしい。
cd /var/lib/php/session/ echo * | xargs rm -rf
セッションファイル削除までの時間を調べたところ30日になっていた。以前よりもアクセス数が増えた(ほとんどbotだが・・)のでこれだと長すぎたようだ。
php.ini
#session.gc_maxlifetime = 2592000 //変更前30日 session.gc_maxlifetime = 1440 //変更後(デフォルトの24分に戻す)
削除後のi-node数
# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/vda3 1819680 84090 1735590 5% / tmpfs 127509 1 127508 1% /dev/shm /dev/vda1 64000 44 63956 1% /boot
低予算で始められるおすすめのFX口座はこちら。
http://s2fx.com/ranking/856.html