ECS安装MySQL

话说

各位读者盆友,下午好啊。今天来吐槽一下MySQL官方文档的安装文档。
寡人域名已经搞定,而且已经绑定了服务器,现在当然要安装MySQL。开始自作主张安装,没有成功,然后就参考MySQL官网yum方式安装,遇到一堆坑,苦不堪言,即使现在也没搞定。所以这篇博客不是提供解决方案的,只是记录很狼狈的一个过程。解决不了你的问题,在下深表遗憾。

难度系数:★★★☆☆
建议用时:1H

目录


1、硬件环境
2、安装过程
3、安装问题
4、总结
5、追加


结果:该问题未解决。如果你是来寻找答案的,请直接跳过。But,最终我还是搞定了!如果你有耐心看到最后的话。我就不结论先行了。

还是结论先行吧,你的报错信息可能有如下几方面:

1、Can't find messagefile '/usr/local/mysql/share/errmsg.sys'



如何处理?
cp /usr/share/mysql/english/errmsg.sys   /usr/local/mysql/data
搞定!错误消息没了



2、mmap(137428992 bytes) failed; errno 12

swap不够
从网上查资料,有人说修改innodb_buffer_pool_size,经过测试无效。 
有人说是swap分区为0导致的此错误,使用free -m命令查看系统内存,发现swap确实为0。使用如下命令建立一个临时的swap分区:
dd if=/dev/zero of=/swap bs=1M count=512  //创建一个swap文件,大小为512M
mkswap /swap                              //将swap文件变为swap分区文件
swapon /swap                              //将其映射为swap分区

此时使用free -m命令即可看到swap分区已存在了,然后启动mysql服务即可。 
为了保证下次系统启动后,此swap分区被自动加载,需要修改系统的fstab文件,操作如下:
vi /etc/fstab
//在其中添加如下一行
/swap swap swap defaults 0 0

保存文件即可。

3、InnoDB: Cannot allocate memory for the buffer pool


服务器内存不够
   innodb_buffer_pool_size =128M  
  key_buffer_size =120M 



4、 InnoDB: Plugin initialization aborted with error Generic error.
5、Failed to initialize DD Storage Engine
6、Data Dictionary initialization failed.
其实,在下还没处理到第2步的时候,MySQL就启动啦!看来是errmsg.sys 在捣鬼!但是我的日志没有输出到/var/log/mysqld.log里面,里面全部都是空的。没有日志,意味着拿不到临时密码?

1、硬件环境

这里写图片描述

我的系统是CentOS 7 所以,启动命令是:systemctl start

2、安装过程

开始我的思路是:官网下载.tar.gz包==》解压/usr/local/mysql ==》启动。这个思路是不对的,因为根本没有初始化,密码用户都没有。

后面按照官网yum方式安装,官方文档写得很详细,不赘述。遗憾的是,官方文档并没有阐述安装可能遇到的问题,而且寡人的MySQL日志也没有准时出现在/var/log/mysqld.log这个位置…….

https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html

安装什么还是看官方文档,心里踏实。

3、安装问题
初始化了,但是没法启动,启动报错,查看信息也不明白怎么做;而且日志文件在哪里产生也找不到。我们来看看?

1)查看状态

[root@izuf6i3jkmikgmou78pwvfz mysql]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 日 2018-06-24 17:47:31 CST; 32min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 4479 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 4462 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 4479 (code=exited, status=1/FAILURE)
   Status: "SERVER_BOOTING"

624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.272212Z 1 [ERROR] [MY-012956] [InnoDB] InnoDB: ... pool
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.272239Z 1 [ERROR] [MY-012930] [InnoDB] InnoDB: ...rror.
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.275956Z 1 [ERROR] [MY-010334] [Server] Failed t...ngine
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.276478Z 0 [ERROR] [MY-010020] [Server] Data Dic...iled.
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.276493Z 0 [ERROR] [MY-010119] [Server] Aborting
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.368819Z 0 [System] [MY-010910] [Server] /usr/sb... GPL.
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: Failed to start MySQL Server.
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: Unit mysqld.service entered failed state.
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@izuf6i3jkmikgmou78pwvfz mysql]# 

很明显信息展示不全,展示全部看一下:

[root@izuf6i3jkmikgmou78pwvfz mysql]# systemctl status mysqld -l
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 日 2018-06-24 17:47:31 CST; 32min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 4479 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)
  Process: 4462 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 4479 (code=exited, status=1/FAILURE)
   Status: "SERVER_BOOTING"

624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.272212Z 1 [ERROR] [MY-012956] [InnoDB] InnoDB: Cannot allocate memory for the buffer pool
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.272239Z 1 [ERROR] [MY-012930] [InnoDB] InnoDB: Plugin initialization aborted with error Generic error.
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.275956Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.276478Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.276493Z 0 [ERROR] [MY-010119] [Server] Aborting
624 17:47:31 izuf6i3jkmikgmou78pwvfz mysqld[4479]: 2018-06-24T09:47:31.368819Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.11)  MySQL Community Server - GPL.
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: Failed to start MySQL Server.
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: Unit mysqld.service entered failed state.
624 17:47:31 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service failed.
[root@izuf6i3jkmikgmou78pwvfz mysql]# 

这里的问题:
a、Cannot allocate memory for the buffer pool
b、Plugin initialization aborted with error Generic error.
寡人真的搞不定……
根据经验,这上面的提示不一定准确,需要看日志,问题是日志一片空白…..

来,不要慌,我们来启动一下:

[root@izuf6i3jkmikgmou78pwvfz mysql]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@izuf6i3jkmikgmou78pwvfz mysql]# 

那我们就按照指示细细查看下原因喽:

[root@izuf6i3jkmikgmou78pwvfz mysql]# journalctl  -ex
-- Subject: Unit mysqld.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysqld.service has failed. -- -- The result is failed. 6月 24 18:22:55 izuf6i3jkmikgmou78pwvfz polkitd[454]: Unregistered Authentication Agent for unix-process:4535:218298452 (system bu
6月 24 18:22:55 izuf6i3jkmikgmou78pwvfz systemd[1]: Unit mysqld.service entered failed state.
6月 24 18:22:55 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service failed.
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz polkitd[454]: Registered Authentication Agent for unix-process:4568:218306833 (system bus 
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz systemd[1]: Starting MySQL Server...
-- Subject: Unit mysqld.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysqld.service has begun starting up. 6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.763930Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.764012Z 0 [Warning] [MY-010339] [Server] Using pre 5.5 s
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.764027Z 0 [ERROR] [MY-010342] [Server] Can't read from m
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.972156Z 0 [ERROR] [MY-012681] [InnoDB] InnoDB: mmap(1374
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.972500Z 1 [ERROR] [MY-012956] [InnoDB] InnoDB: Cannot al
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.972529Z 1 [ERROR] [MY-012930] [InnoDB] InnoDB: Plugin in
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.972560Z 1 [ERROR] [MY-010334] [Server] Failed to initial
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.972696Z 0 [ERROR] [MY-010020] [Server] Data Dictionary i
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.972705Z 0 [ERROR] [MY-010119] [Server] Aborting
6月 24 18:24:18 izuf6i3jkmikgmou78pwvfz mysqld[4591]: 2018-06-24T10:24:18.973627Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld
6月 24 18:24:19 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
6月 24 18:24:19 izuf6i3jkmikgmou78pwvfz polkitd[454]: Unregistered Authentication Agent for unix-process:4568:218306833 (system bu
6月 24 18:24:19 izuf6i3jkmikgmou78pwvfz systemd[1]: Failed to start MySQL Server.
-- Subject: Unit mysqld.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysqld.service has failed. -- -- The result is failed. 6月 24 18:24:19 izuf6i3jkmikgmou78pwvfz systemd[1]: Unit mysqld.service entered failed state.
6月 24 18:24:19 izuf6i3jkmikgmou78pwvfz systemd[1]: mysqld.service failed.

当然,上面显示不全,左右键可以看清楚。

[ERROR] [MY-010342] [Server] Can't read from messagefile '/usr/local/mysql/data/errmsg.sys'
10:24:18.972156Z 0 [ERROR] [MY-012681] [InnoDB] InnoDB: mmap(137428992 bytes) failed; errno 12
10:24:18.972500Z 1 [ERROR] [MY-012956] [InnoDB] InnoDB: Cannot allocate memory for the buffer pool
10:24:18.972529Z 1 [ERROR] [MY-012930] [InnoDB] InnoDB: Plugin initialization aborted with error Generic error.
10:24:18.972560Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
10:24:18.972696Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
10:24:18.972705Z 0 [ERROR] [MY-010119] [Server] Aborting

这个错误文件是我自己建的,说没法读取。errmsg.sys权限已经是777了。
卡壳了……

4、总结


蛮郁闷的,前面都走得蛮顺利,这里卡住,怎么也过不去。希望读者盆友留言交流。


不记录这个Bug,实在难受。记录了有没有解决方案,实在惭愧。下一篇对Yum安装方式做点补充,有了新的理解,欢迎查看。

2018/06/24 21:26
5、追加

功夫不负有心人。可能上苍看我在这么小的问题上纠结,太痛苦了,我灵感一来,搞定啦。
回头重新看了下报错信息,重点处理以下几个问题:

1、Can't find messagefile '/usr/local/mysql/share/errmsg.sys'

如何处理?
cp /usr/share/mysql/english/errmsg.sys /usr/local/mysql/data
搞定!错误消息没了

2、mmap(137428992 bytes) failed; errno 12

swap不够
从网上查资料,有人说修改innodb_buffer_pool_size,经过测试无效。
有人说是swap分区为0导致的此错误,使用free -m命令查看系统内存,发现swap确实为0。使用如下命令建立一个临时的swap分区:
dd if=/dev/zero of=/swap bs=1M count=512 //创建一个swap文件,大小为512M
mkswap /swap //将swap文件变为swap分区文件
swapon /swap //将其映射为swap分区

此时使用free -m命令即可看到swap分区已存在了,然后启动mysql服务即可。
为了保证下次系统启动后,此swap分区被自动加载,需要修改系统的fstab文件,操作如下:
vi /etc/fstab
//在其中添加如下一行
/swap swap swap defaults 0 0

保存文件即可。

3、InnoDB: Cannot allocate memory for the buffer pool

服务器内存不够
innodb_buffer_pool_size =128M
key_buffer_size =120M

4、 InnoDB: Plugin initialization aborted with error Generic error.
5、Failed to initialize DD Storage Engine
6、Data Dictionary initialization failed.

其实,在下还没处理到第2步的时候,MySQL就启动啦!看来是errmsg.sys 在捣鬼!但是我的日志没有输出到/var/log/mysqld.log里面,里面全部都是空的。没有日志,意味着拿不到临时密码?

历史性时刻,值得纪念一下:

[root@izuf6i3jkmikgmou78pwvfz data]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2018-06-24 21:19:32 CST; 11min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 5332 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 5349 (mysqld)
   Status: "SERVER_OPERATING"
   CGroup: /system.slice/mysqld.service
           └─5349 /usr/sbin/mysqld

624 21:19:31 izuf6i3jkmikgmou78pwvfz systemd[1]: Starting MySQL Server...
624 21:19:31 izuf6i3jkmikgmou78pwvfz mysqld[5349]: 2018-06-24T13:19:31.890062Z 0 [System] [MY-010116] [Server] /usr/sb... 5349
624 21:19:31 izuf6i3jkmikgmou78pwvfz mysqld[5349]: 2018-06-24T13:19:31.890146Z 0 [Warning] [MY-010339] [Server] Using ...ters.
624 21:19:32 izuf6i3jkmikgmou78pwvfz mysqld[5349]: 2018-06-24T13:19:32.478465Z 0 [Warning] [MY-010068] [Server] CA cer...gned.
624 21:19:32 izuf6i3jkmikgmou78pwvfz mysqld[5349]: 2018-06-24T13:19:32.480825Z 0 [Warning] [MY-011810] [Server] Insecu...tory.
624 21:19:32 izuf6i3jkmikgmou78pwvfz mysqld[5349]: 2018-06-24T13:19:32.484357Z 0 [ERROR] [MY-013129] [Server] A message int...
624 21:19:32 izuf6i3jkmikgmou78pwvfz mysqld[5349]: 2018-06-24T13:19:32.495331Z 0 [System] [MY-010931] [Server] /usr/sb... GPL.
624 21:19:32 izuf6i3jkmikgmou78pwvfz systemd[1]: Started MySQL Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@izuf6i3jkmikgmou78pwvfz data]# 
[root@izuf6i3jkmikgmou78pwvfz data]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases; +--------------------+
| Database | +--------------------+
| information_schema | | mysql | | performance_schema |
| sys | +--------------------+
4 rows in set (0.01 sec)

要知道,这可是在仅仅500M内存的ECS上安装的MySQL呢!还是那句话,打不死的小强!永不言弃!

相关文章
相关标签/搜索