簡體   English   中英

Mysql 服務器未在從 AMI 創建的 EC2 實例上運行

[英]Mysql server not running on EC2 instance created from AMI

我有一個 EC2 實例,其中 Mysql 服務器工作正常。 我從中創建了一個 AMI 並從此 AMI 啟動了一個新實例。 現在 Mysql 服務器根本無法在這個新的 AMI 上啟動。

以下是o/p:

ubuntu@ip-172-31-66-160:~$ sudo service mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Sun 2019-07-21 20:59:25 IST; 28s ago
  Process: 1870 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 1862 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1870 (code=exited, status=1/FAILURE);         : 1871 (mysql-systemd-s)
    Tasks: 2
   Memory: 3.2M
      CPU: 247ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─1871 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─2529 sleep 1

Jul 21 20:59:25 ip-172-31-66-160 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jul 21 20:59:25 ip-172-31-66-160 systemd[1]: Stopped MySQL Community Server.
Jul 21 20:59:25 ip-172-31-66-160 systemd[1]: Starting MySQL Community Server...
Jul 21 20:59:26 ip-172-31-66-160 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
ubuntu@ip-172-31-66-160:~$ sudo service mysql restart
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

我嘗試了一切,但無法開始。

我遇到並遵循的最接近的線程沒有任何運氣:

  1. https://askubuntu.com/questions/916009/mysql-wont-start-because-of-apparmor
  2. https://support.plesk.com/hc/en-us/articles/360004185293-Unable-to-start-MySQL-on-Ubuntu-AVC-apparmor-DENIED-operation-open-

請幫忙,我對此一無所知。

最后,我能夠讓服務器在我的新實例上運行。 我缺少的是 mysql 也有許多配置選項,這些選項會隨着時間的推移而更改,並且它們還取決於 EC2 實例配置。

就我而言,我的新實例的 RAM 非常有限,並且 mysql.cnf 文件試圖分配比機器更多的 RAM,因此它失敗了。 不知何故,

journalctl -xe

給出了一個不同的錯誤,這迫使我朝着錯誤的方向思考。 我應該查看 mysql 日志文件,它很快就指出了正確的問題。

我在下面的錯誤日志文件中找到了幫助我隔離/解決問題的方法:

2019-07-21T16:00:55.658985Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12 2019-07-21T16:00:55.658993Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 
2019-07-21T16:00:55.658998Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 
2019-07-21T16:00:55.659003Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 
2019-07-21T16:00:55.659620Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2019-07-21T16:00:55.659628Z 0 [ERROR] Failed to initialize builtin plugins.
2019-07-21T16:00:55.659632Z 0 [ERROR] Aborting

因此 mysql 無法啟動,因為系統中不存在請求的內存量。 我評論了 my.cnf 文件中的所有內存分配行(依賴於默認設置),然后它就起作用了。

innodb_buffer_pool_size = 16G
key_buffer_size         = 2G
max_allowed_packet      = 128M
group_concat_max_len = 50000
query_cache_size = 2147483648
query_cache_limit =67108864

希望有人會發現這些信息有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM