MySQL 常见启动故障
so依赖缺失
[root@wxl bin]# ldd /usr/local/mysql/bin/mysql linux-vdso.so.1 => (0x00007ffebfdb4000) libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003f09000000) librt.so.1 => /lib64/librt.so.1 (0x0000003f09400000) libdl.so.2 => /lib64/libdl.so.2 (0x0000003f08800000) libncurses.so.5 => /lib64/libncurses.so.5 (0x0000003f14400000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003f13800000) libm.so.6 => /lib64/libm.so.6 (0x0000003f09800000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003f14000000) libc.so.6 => /lib64/libc.so.6 (0x0000003f08c00000) libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003f10000000) /lib64/ld-linux-x86-64.so.2 (0x0000003f08400000) 依赖都可以找到
selinux没有关闭
[root@wxl bin]# getenforce //检查selinux 状态
Disabled
如果开启请参考《mysql基础》文章修改
权限问题
[root@wxl bin]# ll /data/mysql/mysql3306/ total 8 drwxr-xr-x 5 mysql mysql 4096 Sep 7 09:55 data drwxr-xr-x 2 mysql mysql 4096 Sep 7 09:55 logs drwxr-xr-x 2 mysql mysql 6 Sep 7 09:55 tmp [root@wxl bin]#
datadir非空
初始化时候检查datadir 是否为空
磁盘空间不足
df -hP检查空间大小
参数错误
代码错误解析
[root@wxl bin]# /usr/local/mysql/bin/perror 23 //错误代码 OS error code 23: Too many open files in system
启动故障
之前启动了一次MySQL [root@wxl bin]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf & root@wxl bin]# tailf /data/mysql/mysql3306/data/error.log 2017-09-07T02:15:27.126994Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2017-09-07T02:15:27.127036Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2017-09-07T02:15:28.128035Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 2017-09-07T02:15:28.128085Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 2017-09-07T02:15:29.129078Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11 [root@wxl bin]# /usr/local/mysql/bin/perror 11 OS error code 11: Resource temporarily unavailable 日志会频繁打印
解决方法
检查mysql的pid
[root@wxl bin]# cat /data/mysql/mysql3306/data/mysql.pid
8345
然后kill 除8345的pid进程号
分析故障方法
查看error log
[root@wxl ~]# tailf /data/mysql/mysql3306/data/error.log 2017-09-07T22:45:17.076778Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2017-09-07T22:45:17.076864Z 0 [Note] IPv6 is available. 2017-09-07T22:45:17.077054Z 0 [Note] - '::' resolves to '::'; 2017-09-07T22:45:17.077119Z 0 [Note] Server socket created on IP: '::'. 2017-09-07T22:45:17.204792Z 0 [Note] Event Scheduler: Loaded 0 events 2017-09-07T22:45:17.205723Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: '5.7.19-log' socket: '/tmp/mysql3306.sock' port: 3306 MySQL Community Server (GPL) 2017-09-07T22:45:17.205773Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2017-09-07T22:45:17.205777Z 0 [Note] Beginning of list of non-natively partitioned tables 2017-09-07T22:45:17.379869Z 0 [Note] End of list of non-natively partitioned tables
把日志打开
利用mysqld 手工启动
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf &
端口占用冲突

利用strace分析一下启动过程
[root@wxl opt]# strace /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf 2>&1 |tee tarce_start.log
闲杂人等

浙公网安备 33010602011771号