mariadb service is not starting after boot, CentOS 7
Do not use mysqld_safe
.
You have all sorts of problems, all down to building a contender for a place in the systemd House of Horror by running a Poor Man's Dæmon Supervisor (written badly in shell script) underneath service management. You could laboriously go through and tweak things so that they interoperate better, dealing with readiness protocol mismatches and with conflicts where you have ended up setting things two different ways in two different places, but that would really be pointless. Instead, learn from the daemontools world, which has wanted mysqld_safe
gone since the turn of the century.
All these years later, you can get rid of it in the systemd world, too. The MariaDB world has the distinction, in stark contrast to Oracle and the MySQL world, of actually providing good doco on how to run MariaDB in the way that daemontools/runit/s6 users have wanted all of these years, without mysqld_safe
and instead using the service management toolset for service management.
MariaDB comes with a mariadb.service
service unit for systemd, and a mariadb-service-convert
tool that migrates the settings from my.cnf
into systemd service unit settings. It even comes with a [email protected]
service unit template, that allows one to run multiple servers as distinct services. Use those.
Further reading
- Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.
- Jonathan de Boyne Pollard (2016). MariaDB and MySQL with nosh. Softwares.
- "systemd". Starting and Stopping MariaDB. KnowledgeBase. MariaDB. 2016.
- "Starting and Stopping MariaDB Automatically". Starting and Stopping MariaDB. KnowledgeBase. MariaDB. 2016.
Related videos on Youtube
Berto Rico
Updated on September 18, 2022Comments
-
Berto Rico over 1 year
I defined the service for mariadb on: /etc/systemd/system/mariadb.service
[Unit] Description=start and stop MySQL(MariaDB) Server After=syslog.target After=network.target [Service] Type=simple User=Umariadb Group=Gmariadb # Restart=always # PermissionsStartOnly=true ExecStart=/usr/local/ServerWeb/mariadb/bin/mysqld_safe --user=mysql --ledir=/usr/local/ServerWeb/mariadb/bin --datadir=/usr/local/ServerWeb/mariadb/data # ExecStop=/usr/bin/vgaoff stop TimeoutSec=300 PrivateTmp=true [Install] WantedBy=multi-user.target
Later I activated it:
systemctl enable mariadb.service
Now, after reboot, the Service is not starting.
Then I need to disable the service again.
When trying to execute manually again it works perfectly...
sudo /usr/local/ServerWeb/mariadb/bin/mysqld_safe --user=mysql --ledir=/usr/local/ServerWeb/mariadb/bin --datadir=/usr/local/ServerWeb/mariadb/data
Is my script for service defined well?
I would like to know what is the problem is. How to solve it?
EDIT:
$ sudo /usr/local/ServerWeb/mariadb/bin/mysqld_safe --user=mysql --ledir=/usr/local/ServerWeb/mariadb/bin --datadir=/usr/local/ServerWeb/mariadb/data [sudo] password for joseluisbz: 170308 19:54:07 mysqld_safe Logging to '/usr/local/ServerWeb/mariadb/data/server.err'.
Inside the File
170308 19:54:07 mysqld_safe Starting mysqld daemon with databases from /usr/local/ServerWeb/mariadb/data 2017-03-08 19:54:07 140588539000704 [Note] /usr/local/ServerWeb/mariadb/bin/mysqld (mysqld 10.1.20-MariaDB) starting as process 4411 ... 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Using mutexes to ref count buffer pool pages 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: The InnoDB memory heap is disabled 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Compressed tables use zlib 1.2.3 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Using Linux native AIO 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Using SSE crc32 instructions 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Completed initialization of buffer pool 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Highest supported file format is Barracuda. 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: 128 rollback segment(s) are active. 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Waiting for purge to start 2017-03-08 19:54:07 140588539000704 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.34-79.1 started; log sequence number 1622938 2017-03-08 19:54:07 140588539000704 [Note] Plugin 'FEEDBACK' is disabled. 2017-03-08 19:54:07 140587999135488 [Note] InnoDB: Dumping buffer pool(s) not yet started 2017-03-08 19:54:07 140588539000704 [Note] Server socket created on IP: '::'. 2017-03-08 19:54:08 140588539000704 [Note] /usr/local/ServerWeb/mariadb/bin/mysqld: ready for connections. Version: '10.1.20-MariaDB' socket: '/tmp/mysql.sock' port: 3306 MariaDB Server
Testing Availability...
[joseluisbz@Vxbox-Lnx ~]$ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 10.1.20-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
Shutdown the Linux...
2017-03-08 19:59:29 140588538443520 [Note] /usr/local/ServerWeb/mariadb/bin/mysqld: Normal shutdown 2017-03-08 19:59:29 140588538443520 [Note] Event Scheduler: Purging the queue. 0 events 2017-03-08 19:59:29 140587982350080 [Note] InnoDB: FTS optimize thread exiting. 2017-03-08 19:59:29 140588538443520 [Note] InnoDB: Starting shutdown... 2017-03-08 19:59:31 140588538443520 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool 2017-03-08 19:59:32 140588538443520 [Note] InnoDB: Shutdown completed; log sequence number 1622948 2017-03-08 19:59:32 140588538443520 [Note] /usr/local/ServerWeb/mariadb/bin/mysqld: Shutdown complete 170308 19:59:32 mysqld_safe mysqld from pid file /usr/local/ServerWeb/mariadb/data/Vxbox-Lnx.pid ended
Now with service...
$ sudo systemctl enable mariadb.service [sudo] password for joseluisbz: Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /etc/systemd/system/mariadb.service. [joseluisbz@Vxbox-Lnx ~]$
Checking...
[joseluisbz@Vxbox-Lnx ~]$ sudo service mariadb start [sudo] password for joseluisbz: Redirecting to /bin/systemctl start mariadb.service [joseluisbz@Vxbox-Lnx ~]$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [joseluisbz@Vxbox-Lnx ~]$
STATUS
$ sudo systemctl status mariadb.service [sudo] password for joseluisbz: ● mariadb.service - start and stop MySQL(MariaDB) Server Loaded: loaded (/etc/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2017-03-08 20:09:47 COT; 5min ago Process: 4556 ExecStart=/usr/local/ServerWeb/mariadb/bin/mysqld_safe --user=mysql --ledir=/usr/local/ServerWeb/mariadb/bin --datadir=/usr/local/ServerWeb/mariadb/data (code=exited, status=1/FAILURE) Main PID: 4556 (code=exited, status=1/FAILURE) Mar 08 20:09:47 Vxbox-Lnx systemd[1]: Started start and stop MySQL(MariaDB) Server. Mar 08 20:09:47 Vxbox-Lnx systemd[1]: Starting start and stop MySQL(MariaDB) Server... Mar 08 20:09:47 Vxbox-Lnx mysqld_safe[4556]: 170308 20:09:47 mysqld_safe Logging to '/usr/local/ServerWeb/mariadb/data/server.err'. Mar 08 20:09:47 Vxbox-Lnx systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE Mar 08 20:09:47 Vxbox-Lnx systemd[1]: Unit mariadb.service entered failed state. Mar 08 20:09:47 Vxbox-Lnx systemd[1]: mariadb.service failed. [joseluisbz@Vxbox-Lnx ~]$
Another Check
$ sudo systemctl --failed [sudo] password for joseluisbz: UNIT LOAD ACTIVE SUB DESCRIPTION ● kdump.service loaded failed failed Crash recovery kernel arming ● mariadb.service loaded failed failed start and stop MySQL(MariaDB) Server LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 2 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'. [joseluisbz@Vxbox-Lnx ~]$
-
Berto Rico about 7 yearsThank you... I was reading your article... have you a step by step?