最近忙于项目和驾照,许久没有关注技术和博客了,想来作为基层程序员也是泪累颣。在以前和现在我都遇到了下面的错误,这是启动mysql
时遇到的错误提示,也就是执行/etc/init.d/mysqld start
或 service mysqld start
时抛出的错误提示,相信大家也不陌生。
Starting MySQL..The server quit without updating PID file ([失败]data/3306/xxxxxxx.pid).
对于以上这个错误信息,网上通常看到解决办法有7种,这里我就不一一列举的,有兴趣的可以参考文末的链接。正常来说,遇到错误最好的办法就是查看错误日志,综合来讲,无非就是权限不足、硬盘不足、内存不足等原因。mysql
错误日志的配置方法就是log-error="/var/log/mysqld.log"
,最近遇到的mysql
启动问题就是内存不足,错误如下: 然后我就修改innodb_buffer_pool_size=64MB
以为能解决,结果是还是同样的错误,接着我修改innodb_buffer_pool_size=32MB
问题还是一样的存在,甚至连错误日志都没有产生,当时还尝试使用/etc/init.d/mysqld status
来排除错误,具是无果。这个时候我都开始怀疑人生了,无赖之下,使用free -m
查看了一下,整个服务器的总内存只有996M
,我惊呆了,以为自己弄错误了,又使用top
再确认了一次,还是只有996M
,不足1G
呀 ,当时领导和我说这是正式服务器的时候,我是无论如何也没有想到一台正式的WEB服务器只有1核1G,少见这种服务器吧!接下来赶紧汇报领导,升级了服务器,问题彻底解决。
解决mysql
问题基本上只要关注: 配置文件my.cnf
、启动脚本/etc/init.d/mysqld
、错误日志/var/log/mysqld.log
这三个文件就够了。
- 配置文件
cp /usr/local/mysql/etc/my.cnf /etc/my.cnf
- 启动脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
- 错误日志
log-error="/var/log/mysqld.log"
2017-12-04 13:56:51 7591 [Warning] option 'innodb-autoextend-increment': unsigned value 134217728 adjusted to 10002017-12-04 13:56:51 7591 [Note] Plugin 'FEDERATED' is disabled.2017-12-04 13:56:51 7591 [Note] InnoDB: Using atomics to ref count buffer pool pages2017-12-04 13:56:51 7591 [Note] InnoDB: The InnoDB memory heap is disabled2017-12-04 13:56:51 7591 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2017-12-04 13:56:51 7591 [Note] InnoDB: Memory barrier is not used2017-12-04 13:56:51 7591 [Note] InnoDB: Compressed tables use zlib 1.2.32017-12-04 13:56:51 7591 [Note] InnoDB: Using Linux native AIO2017-12-04 13:56:51 7591 [Note] InnoDB: Using CPU crc32 instructions2017-12-04 13:56:51 7591 [Note] InnoDB: Initializing buffer pool, size = 128.0MInnoDB: mmap(137363456 bytes) failed; errno 122017-12-04 13:56:51 7591 [ERROR] InnoDB: Cannot allocate memory for the buffer pool2017-12-04 13:56:51 7591 [ERROR] Plugin 'InnoDB' init function returned error.2017-12-04 13:56:51 7591 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.2017-12-04 13:56:51 7591 [ERROR] Unknown/unsupported storage engine: InnoDB2017-12-04 13:56:51 7591 [ERROR] Aborting2017-12-04 13:56:51 7591 [Note] Binlog end2017-12-04 13:56:51 7591 [Note] Shutting down plugin 'partition'2017-12-04 13:56:51 7591 [Note] Shutting down plugin 'ARCHIVE'
又是某久之前的一次,在客户的机器上安装mysql
时,在datadir
目录下没有产生mysql
数据库,错误日志就不贴了,当时想的解决办法就是执行mysql_install_db
脚本来重新生成,如下,
./mysql_install_db –user=mysql datadir=/data/mysql/3306 --basedir=/usr/local/mysqlcd Installing MySQL system tables...2017-10-17 14:06:52 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.2017-10-17 14:06:52 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.35-log) starting as process 28664 ...
但是天不如人算,还是报错了,具体错误因为时间太久不记得了,解决办法是通过history
回忆的,故记录一下。执行如下命令后,再次执行mysql_install_db
即可。
rpm -ivh /mnt/Packages/perl-Data-Dumper-2.145-3.el7.x86_64.rpm yum install perl-Data-Dumper -y
另外,我发现某些人喜欢将日志路径配置为 /var/run
目录,这是不可取的。因为/var/run
是/run
链接,也就是说/var/run
和/run
是一个东西。这个目录是存在内存里的,意外重启时,可能被删除,达不到查询日志排除错误的效果。
https://yq.aliyun.com/articles/46001
http://www.jb51.net/article/48625.htm
http://blog.rekfan.com/articles/186.html
注:本文内容来自互联网,旨在为开发者提供分享、交流的平台。如有涉及文章版权等事宜,请你联系站长进行处理。