我无法启动 mysql 服务。它运行了几个月,没有任何变化,然后就停止了。
sudo service mysql start
给我这个Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service
输出:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Tue 2017-08-08 11:39:48 UTC; 23s ago
Process: 29500 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 29492 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 29500 (code=exited, status=1/FAILURE); : 29501 (mysql-systemd-s)
Tasks: 2
Memory: 1.6M
CPU: 232ms
CGroup: /system.slice/mysql.service
└─control
├─29501 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─29554 sleep 1
Aug 08 11:39:48 ip-172-31-21-240 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Aug 08 11:39:48 ip-172-31-21-240 systemd[1]: Stopped MySQL Community Server.
Aug 08 11:39:48 ip-172-31-21-240 systemd[1]: Starting MySQL Community Server...
Aug 08 11:39:48 ip-172-31-21-240 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
journalctl -xe
输出如下
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Aug 08 11:31:14 ip-172-31-21-240 kernel: audit: type=1400 audit(1502191874.172:10246): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28031/status" pid=28031 comm="mysqld
Aug 08 11:31:14 ip-172-31-21-240 kernel: audit: type=1400 audit(1502191874.172:10247): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=28031 comm=
Aug 08 11:31:14 ip-172-31-21-240 kernel: audit: type=1400 audit(1502191874.172:10248): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28031/status" pid=28031 comm="mysqld
Aug 08 11:31:14 ip-172-31-21-240 audit[28031]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28031/status" pid=28031 comm="mysqld" requested_mask="r" denied_mask="r"
Aug 08 11:31:14 ip-172-31-21-240 audit[28031]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=28031 comm="mysqld" requested_mask="r" denied_m
Aug 08 11:31:14 ip-172-31-21-240 audit[28031]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28031/status" pid=28031 comm="mysqld" requested_mask="r" denied_mask="r"
Aug 08 11:31:14 ip-172-31-21-240 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Aug 08 11:31:44 ip-172-31-21-240 systemd[1]: Failed to start MySQL Community Server.
error.log 的最后一条记录
2017-08-08T11:50:23.690152Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-08-08T11:50:23.690188Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2017-08-08T11:50:23.836308Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-08T11:50:23.837266Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19-0ubuntu0.16.04.1) starting as process 31307 ...
2017-08-08T11:50:23.840500Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-08-08T11:50:23.840521Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-08-08T11:50:23.840525Z 0 [Note] InnoDB: Uses event mutexes
2017-08-08T11:50:23.840529Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-08-08T11:50:23.840532Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-08-08T11:50:23.840537Z 0 [Note] InnoDB: Using Linux native AIO
2017-08-08T11:50:23.840751Z 0 [Note] InnoDB: Number of pools: 1
2017-08-08T11:50:23.840845Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-08-08T11:50:23.842139Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-08-08T11:50:23.842166Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2017-08-08T11:50:23.842171Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2017-08-08T11:50:23.842176Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-08-08T11:50:23.842180Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-08-08T11:50:23.842183Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-08-08T11:50:23.842186Z 0 [ERROR] Failed to initialize plugins.
2017-08-08T11:50:23.842188Z 0 [ERROR] Aborting
2017-08-08T11:50:23.842191Z 0 [Note] Binlog end
2017-08-08T11:50:23.842219Z 0 [Note] Shutting down plugin 'MyISAM'
2017-08-08T11:50:23.842361Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
答案1
2017-08-08T11:50:23.842166Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2017-08-08T11:50:23.842171Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
这通知您有关 RAM 的问题,您没有足够的 RAM 来使用 configure 启动 MySQL innodb_buffer_pool_size
。在配置文件中将其大小更改为较小的值,然后尝试启动 MySQL。
你可以读一下回答。