LoginSignup
2
1

More than 5 years have passed since last update.

vmware上に構築したMantisで出ていたmysql起動エラー(スワップ領域不足)

Last updated at Posted at 2018-01-05

ある日、vmware上に構築したMantisを再起動すると起動しなくなっていた。

mysqlを再起動してみたら

# service mysqld restart
Stopping mysqld:                                           [  OK  ]
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

ログを確認する

/var/log/mysqld.log
# cat /var/log/mysqld.log
2015-12-04 11:55:03 3022 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2015-12-04 11:55:03 3022 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2015-12-04 11:55:03 3022 [ERROR] Plugin 'InnoDB' init function returned error.
2015-12-04 11:55:03 3022 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-12-04 11:55:03 3022 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-12-04 11:55:03 3022 [ERROR] Aborting

InnoDB: Initializing buffer pool, sizeが足りんらしいという事で増やしてみる。

innodb_buffer_pool_size を増やしてみる

/etc/my.cnf
# vi /etc/my.cnf
innodb_buffer_pool_size = 256M

そして、再起動

# service mysqld restart
Stopping mysqld:                                           [  OK  ]
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

ぬぁに!?

/var/log/mysqld.log
# cat /var/log/mysqld.log
2015-12-04 11:59:26 3858 [Note] InnoDB: Initializing buffer pool, size = 256.0M
InnoDB: mmap(274726912 bytes) failed; errno 12
2015-12-04 11:59:26 3858 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2015-12-04 11:59:26 3858 [ERROR] Plugin 'InnoDB' init function returned error.
2015-12-04 11:59:26 3858 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-12-04 11:59:26 3858 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-12-04 11:59:26 3858 [ERROR] Aborting

何も解決してない・・・

メモリを確認!

# free
             total       used       free     shared    buffers     cached
Mem:        604484     597196       7288          0       3792      20392
-/+ buffers/cache:     573012      31472
Swap:      0     0     0

microインスタンス600Mちょいぐらいしかない上に
スワップ0バイト

ならばと、スワップ領域作る

# dd if=/dev/zero of=/swapfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 31.6782 s, 33.9 MB/s

# mkswap /swapfile
mkswap: /swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=06fe53b6-a901-4b5b-80ba-ffecf7063fc2

# swapon /swapfile

# free
             total       used       free     shared    buffers     cached
Mem:        604484     597820       6664          0       2316     408160
-/+ buffers/cache:     187344     417140
Swap:      1048568          0    1048568

mysqlを再起動!!!

# service mysqld restart
Stopping mysqld:                                   
        [  OK  ]
Starting mysqld:                                           [  OK  ]
/var/log/mysqld.log
# cat /var/log/mysqld.log
151204 12:02:45 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2015-12-04 12:02:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-04 12:02:47 4162 [Note] Plugin 'FEDERATED' is disabled.
2015-12-04 12:02:47 4162 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-12-04 12:02:47 4162 [Note] InnoDB: The InnoDB memory heap is disabled
2015-12-04 12:02:47 4162 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-12-04 12:02:47 4162 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-12-04 12:02:47 4162 [Note] InnoDB: Using Linux native AIO
2015-12-04 12:02:47 4162 [Note] InnoDB: Using CPU crc32 instructions
2015-12-04 12:02:48 4162 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-12-04 12:02:48 4162 [Note] InnoDB: Completed initialization of buffer pool
2015-12-04 12:02:49 4162 [Note] InnoDB: Highest supported file format is Barracuda.
2015-12-04 12:02:51 4162 [Note] InnoDB: 128 rollback segment(s) are active.
2015-12-04 12:02:51 4162 [Note] InnoDB: Waiting for purge to start
2015-12-04 12:02:51 4162 [Note] InnoDB: 5.6.19 started; log sequence number 17533870729
2015-12-04 12:02:52 4162 [Note] Server hostname (bind-address): '*'; port: 3306
2015-12-04 12:02:52 4162 [Note] IPv6 is available.
2015-12-04 12:02:52 4162 [Note]   - '::' resolves to '::';
2015-12-04 12:02:52 4162 [Note] Server socket created on IP: '::'.
2015-12-04 12:02:52 4162 [Note] Event Scheduler: Loaded 0 events
2015-12-04 12:02:52 4162 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.19'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

こいつ動くぞ!

追伸

fstabに入れておかないと、インスタンスを再起動したらスワップ領域は残っていますが、割り当て解除されます。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1