Centos7
MariaDB 重啟後無法啟動 - 可以手動啟動
我有一個使用 MariaDB 執行 Centos7 的 VPS。我在嘗試讓它在啟動時啟動 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
我的.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 時它工作正常,但我不想這樣做。提前致謝。
我最終通過
/usr/lib/systemd/system/mariadb.service
在 unit 指令下將 network-online.target 添加到文件中來解決這個問題:[Unit] Description=MariaDB database server After=syslog.target After=network-online.target
最初,它被設置為
network.target
. 基本上 eth1 介面沒有足夠快地獲得 IP 地址,導致 MariaDB 在啟動時抱怨。謝謝@nickm
在我的情況下,從 5.5.68-MariaDB 升級到 10.5.8 後所需要的就是這樣(注意:drupal 在 RHEL7 上與 mariadb 一起執行):
sudo systemctl enable mariadb
我希望這對其他人有幫助