CentOS 7 MariaDB Error "Failed to start mariadb.service: Unit not found." [closed]
I am somewhat new to Linux, testing various LAMP setups in Virtualbox on Windows. Currently I have a Centos 7 VM that I am trying to install MariaDB on. I am following instructions here: http://www.tecmint.com/install-lamp-in-centos-7
I ran
# yum install mariadb-server mariadb
Installation was successful according to terminal output, but when I run:
# systemctl start mariadb
I get
Failed to start mariadb.service: Unit not found.
I spent past couple of hours googling this, but nothing seems to solve my issue, inlcuding this (No mysqld or mysql.server after mariadb-server install) and many other posts.
Any help is greatly appreciated.
UPDATE 01
I uninstalled mariadb:
[root@centos7 admin]# yum remove mysql
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.0.30-1.el7.centos will be erased
--> Processing Dependency: MariaDB-client for package: MariaDB-server-10.0.30-1.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-server.x86_64 0:10.0.30-1.el7.centos will be erased
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package Arch Version Repository Size
===================================================================================
Removing:
MariaDB-client x86_64 10.0.30-1.el7.centos @mariadb 49 M
Removing for dependencies:
MariaDB-server x86_64 10.0.30-1.el7.centos @mariadb 237 M
Transaction Summary
===================================================================================
Remove 1 Package (+1 Dependent package)
Installed size: 286 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : MariaDB-server-10.0.30-1.el7.centos.x86_64 1/2
Erasing : MariaDB-client-10.0.30-1.el7.centos.x86_64 2/2
Verifying : MariaDB-client-10.0.30-1.el7.centos.x86_64 1/2
Verifying : MariaDB-server-10.0.30-1.el7.centos.x86_64 2/2
Removed:
MariaDB-client.x86_64 0:10.0.30-1.el7.centos
Dependency Removed:
MariaDB-server.x86_64 0:10.0.30-1.el7.centos
Complete!
ran yum clean all
and yum update
reinstalled mariadb:
# yum install mariadb-server mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Webmin: download.webmin.com
* base: anorien.csc.warwick.ac.uk
* extras: centos.mirrors.nublue.co.uk
* updates: centos.serverspace.co.uk
Package mariadb-server is obsoleted by MariaDB-server, trying to install MariaDB-server-10.0.30-1.el7.centos.x86_64 instead
Package mariadb is obsoleted by MariaDB-client, trying to install MariaDB-client-10.0.30-1.el7.centos.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.0.30-1.el7.centos will be installed
---> Package MariaDB-server.x86_64 0:10.0.30-1.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package Arch Version Repository Size
===================================================================================
Installing:
MariaDB-client x86_64 10.0.30-1.el7.centos mariadb 10 M
MariaDB-server x86_64 10.0.30-1.el7.centos mariadb 55 M
Transaction Summary
===================================================================================
Install 2 Packages
Total download size: 65 M
Installed size: 65 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): MariaDB-10.0.30-centos7-x86_64-client.rpm | 10 MB 00:00:22
(2/2): MariaDB-10.0.30-centos7-x86_64-server.rpm | 55 MB 00:01:15
-----------------------------------------------------------------------------------
Total 876 kB/s | 65 MB 01:15
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : MariaDB-client-10.0.30-1.el7.centos.x86_64 1/2
Installing : MariaDB-server-10.0.30-1.el7.centos.x86_64 2/2
libsemanage.map_file: Unable to open /usr/share/mysql/SELinux/mariadb.pp
(No such file or directory).
libsemanage.semanage_direct_install_file: Unable to read file /usr/share/mysql/SELinux/mariadb.pp
(No such file or directory).
/usr/sbin/semodule: Failed on /usr/share/mysql/SELinux/mariadb.pp!
Verifying : MariaDB-client-10.0.30-1.el7.centos.x86_64 1/2
Verifying : MariaDB-server-10.0.30-1.el7.centos.x86_64 2/2
Installed:
MariaDB-client.x86_64 0:10.0.30-1.el7.centos
MariaDB-server.x86_64 0:10.0.30-1.el7.centos
Complete!
Still no go, what gives?
# systemctl start mariadb.service
Failed to start mariadb.service: Unit not found.
UPDATE 02
There could be something with package versions and capitalization, I used mariaDB repos instead of centos for installation, so it picked up version 10.0.30:
]# yum info mariadb-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Webmin: download.webmin.com
* base: anorien.csc.warwick.ac.uk
* extras: centos.mirrors.nublue.co.uk
* updates: centos.serverspace.co.uk
Installed Packages
Name : MariaDB-server
Arch : x86_64
Version : 10.0.30
Release : 1.el7.centos
Size : 237 M
Repo : installed
From repo : mariadb
Summary : MariaDB: a very fast and robust SQL database server
URL : http://mariadb.org
License : GPLv2
Description : MariaDB: a very fast and robust SQL database server
:
: It is GPL v2 licensed, which means you can use the it free of charge
: under the conditions of the GNU General Public License Version 2
: (http://www.gnu.org/licenses/).
:
: MariaDB documentation can be found at https://mariadb.com/kb
: MariaDB bug reports should be submitted through
: https://jira.mariadb.org
Available Packages
Name : mariadb-server
Arch : x86_64
Epoch : 1
Version : 5.5.52
Release : 1.el7
Size : 11 M
Repo : base/7/x86_64
Summary : The MariaDB server and related files
URL : http://mariadb.org
License : GPLv2 with exceptions and LGPLv2 and BSD
Description : MariaDB is a multi-user, multi-threaded SQL database server. It is a
: client/server implementation consisting of a server daemon (mysqld)
: and many different client programs and libraries. This package
: contains the MariaDB server and some accompanying files and
: directories. MariaDB is a community developed branch of MySQL.
Solution 1:
Further research showed that in MariaDB repo (v 10.0.30) service is called mysql
as opposed to centos repo (v5.5) it is called mariadb
, so that was one confusion / issue.
Reference question: MariaDB on Centos7, service still called MySql
Running # service mysql start
returned ERROR
Error check with
grep: journalctl -xe|grep 'mysqld.*errno'
Showed:
/usr/bin/mysqld_safe_helper: Cannot change uid/gid (errno: 1)
Following this post seems to have fixed the issue, which had to do with MariaDB 10.0.XX version and SELinux:
https://www.penguinprompt.com/mariadb-10-0-29-update-failure-selinux/
I am able to start mysql service and configure it with mysql_secure_installation
Solution 2:
I guess I would check that mariadb-server installed correctly - it seems to contain the service definition:
rpm -qvla mariadb-server | grep service
-rw-r--r-- 1 root root 1697 Nov 14 16:44 /usr/lib/systemd/system/mariadb.service
You can also check using yum:
> yum info mariadb-server
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: centos.mirror.triple-it.nl
* extras: centos.mirror.transip.nl
* updates: centos.ams.host-engine.com
Installed Packages
Name : mariadb-server
Arch : x86_64
Epoch : 1
Version : 5.5.52
Release : 1.el7
Size : 56 M
Repo : installed
You are looking for the last line above to say installed
, instead of base/7/x86_64
.
I just tried your install commands on a fresh centos7 image (the official centos docker container), and could not replicate your issue.
You may want to try and re-install mariadb-server.
Update: I think your issue is due to your MariaDB package coming from the webmin repo, rather than the base repo.
Disabling that temporarily (or more permanently) may help: sudo yum install --disablerepo=Webmin mariadb-server
should solve your immediate issue (and/or get you the files you need).
All else failing, the service definition is simple enough:
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to create a file "/etc/systemd/system/mariadb.service",
# containing
# .include /lib/systemd/system/mariadb.service
# ...make your changes here...
# or create a file "/etc/systemd/system/mariadb.service.d/foo.conf",
# which doesn't need to include ".include" call and which will be parsed
# after the file mariadb.service itself is parsed.
#
# For more info about custom unit files, see systemd.unit(5) or
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
# For example, if you want to increase mariadb's open-files-limit to 10000,
# you need to increase systemd's LimitNOFILE setting, so create a file named
# "/etc/systemd/system/mariadb.service.d/limits.conf" containing:
# [Service]
# LimitNOFILE=10000
# Note: /usr/lib/... is recommended in the .include line though /lib/...
# still works.
# Don't forget to reload systemd daemon after you change unit configuration:
# root> systemctl --system daemon-reload
[Unit]
Description=MariaDB database server
After=syslog.target
After=network.target
[Service]
Type=simple
User=mysql
Group=mysql
ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=/usr/bin/mysqld_safe --basedir=/usr
ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
# Place temp files in a secure directory, not /tmp
PrivateTmp=true
[Install]
WantedBy=multi-user.target