Назад | Перейти на главную страницу

MariaDB не запускается после перезагрузки - можно запустить вручную

У меня есть VPS под управлением Centos7 с MariaDB. У меня возникают проблемы с запуском MariaDB при загрузке, я привязываю MariaDB к частному адресу моего VPS, так как хочу, чтобы он только прослушивал соединения на этом интерфейсе. Это не удается в журналах:

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

Однако я могу запустить службу вручную, запустив sudo systemctl start mariadb который производит:

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.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

я временно отключил SELinux, чтобы проверить, не в этом ли проблема, но, похоже, это не помогло. Он отлично работает, когда я привязываюсь к 0.0.0.0, но я не особо хочу этого делать. Заранее спасибо.

В итоге я исправил это, добавив network-online.target в /usr/lib/systemd/system/mariadb.service файл под директивой unit:

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

Первоначально он был установлен на network.target. По сути, интерфейс eth1 не получал IP-адрес достаточно быстро, из-за чего MariaDB жаловалась при загрузке.

Спасибо @nickm