大网数据广告活动
服务器运维问答

MariaDB fails to start after reboot - can start it manually

· 52CE 我爱测

I have a VPS running Centos7 with MariaDB. I am having issues trying to get it to start MariaDB on boot, I am binding MariaDB to my VPS's private address as I only want it to listen to connections on that interface. It fails with…

问题原文

原帖链接 · Aaron Fahey · CC BY-SA 3.0

I have a VPS running Centos7 with MariaDB. I am having issues trying to get it to start MariaDB on boot, I am binding MariaDB to my VPS's private address as I only want it to listen to connections on that interface. It fails with this in the logs:

170204 15:34:03 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
170204 15:34:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170204 15:34:13 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 784 ...
170204 15:34:13 InnoDB: The InnoDB memory heap is disabled
170204 15:34:13 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170204 15:34:13 InnoDB: Compressed tables use zlib 1.2.7
170204 15:34:13 InnoDB: Using Linux native AIO
170204 15:34:13 InnoDB: Initializing buffer pool, size = 128.0M
170204 15:34:13 InnoDB: Completed initialization of buffer pool
170204 15:34:13 InnoDB: highest supported file format is Barracuda.
170204 15:34:13  InnoDB: Waiting for the background threads to start
170204 15:34:14 Percona XtraDB (http://www.percona.com) 5.5.49-MariaDB-38.0 started; log sequence number 1597945
170204 15:34:14 [Note] Plugin 'FEEDBACK' is disabled.
170204 15:34:14 [Note] Server socket created on IP: '10.99.0.14'.
170204 15:34:14 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 99: Cannot assign requested address
170204 15:34:14 [ERROR] Do you already have another mysqld server running on port: 3306 ?
170204 15:34:14 [ERROR] Aborting

170204 15:34:14  InnoDB: Starting shutdown...
170204 15:34:15  InnoDB: Shutdown completed; log sequence number 1597945
170204 15:34:15 [Note] /usr/libexec/mysqld: Shutdown complete

However, I am able to start the service manually by running sudo systemctl start mariadb which produces:

170204 15:34:15 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
170204 15:38:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170204 15:38:52 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process 2609 ...
170204 15:38:52 InnoDB: The InnoDB memory heap is disabled
170204 15:38:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170204 15:38:52 InnoDB: Compressed tables use zlib 1.2.7
170204 15:38:52 InnoDB: Using Linux native AIO
170204 15:38:52 InnoDB: Initializing buffer pool, size = 128.0M
170204 15:38:52 InnoDB: Completed initialization of buffer pool
170204 15:38:52 InnoDB: highest supported file format is Barracuda.
170204 15:38:52  InnoDB: Waiting for the background threads to start
170204 15:38:53 Percona XtraDB (http://www.percona.com) 5.5.49-MariaDB-38.0 started; log sequence number 1597945
170204 15:38:53 [Note] Plugin 'FEEDBACK' is disabled.
170204 15:38:53 [Note] Server socket created on IP: '10.99.0.14'.
170204 15:38:53 [Note] Event Scheduler: Loaded 0 events
170204 15:38:53 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.52-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server

My my.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

bind-address    = 10.99.0.14

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

I temporarily disabled SELinux to see if this was the issue, however it didn't seem to fix the issue. It works fine when I bind to 0.0.0.0 but I don't particularly want to do that. Thanks in advance.

已采纳解答

原帖链接 · Aaron Fahey · CC BY-SA 3.0

I ended up fixing this by adding network-online.target to the /usr/lib/systemd/system/mariadb.service file, under the unit directive:

[Unit]
Description=MariaDB database server
After=syslog.target
After=network-online.target

Originally, it was set to network.target. Basically the eth1 interface wasn't getting an IP address fast enough, causing MariaDB to complain on boot.

Thanks @nickm

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。