CentOS 7 MariaDB错误“无法启动mariadb.service:未find单元。”

我对Linux有点新,在Windows上的Virtualbox上testing各种LAMP设置。 目前我有一个CentOS 7虚拟机,我正在尝试安装MariaDB。 我在这里按照说明: http : //www.tecmint.com/install-lamp-in-centos-7

我跑了

# yum install mariadb-server mariadb 

根据terminal输出安装成功,但运行时:

  # systemctl start mariadb 

我明白了

 Failed to start mariadb.service: Unit not found. 

我花了几个小时使用谷歌search这个,但似乎没有解决我的问题,包括( mariadb服务器安装后没有mysqld或mysql.server )和许多其他职位。

任何帮助是极大的赞赏。

更新01

我卸载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! 

跑了yum clean allyum update

重新安装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! 

还是没有去,是什么给?

 # systemctl start mariadb.service Failed to start mariadb.service: Unit not found. 

更新02

可能有一些软件包版本和大小写,我使用mariaDB回购,而不是centos安装,所以它拿起版本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. 

我想我会检查mariadb服务器安装正确 – 它似乎包含服务定义:

 rpm -qvla mariadb-server | grep service -rw-r--r-- 1 root root 1697 Nov 14 16:44 /usr/lib/systemd/system/mariadb.service 

你也可以用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 

你正在寻找上面的最后一行说installed ,而不是base/7/x86_64

我只是尝试了一个新的centos7镜像(官方的centosdocker集装箱)上的安装命令,并不能复制你的问题。

你可能想尝试重新安装mariadb-server。

更新 :我认为你的问题是由于你的MariaDB软件包来自webmin回购,而不是基地回购。 禁用临时(或更永久)可能会有所帮助: sudo yum install --disablerepo=Webmin mariadb-server应该解决您的直接问题(和/或得到您需要的文件)。

所有其他的失败,服务的定义是非常简单的:

 # 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 

进一步的研究表明,在MariaDB回购(v 10.0.30)服务被称为mysql而不是centos回购(v5.5)它被称为mariadb ,所以这是一个混淆/问题。

参考问题: 在CentOS7上的MariaDB服务仍然称为MySql

运行# service mysql start返回ERROR

错误检查

 grep: journalctl -xe|grep 'mysqld.*errno' 

结果显示:

 /usr/bin/mysqld_safe_helper: Cannot change uid/gid (errno: 1) 

以下这篇文章似乎已经解决了与MariaDB 10.0.XX版本和SELinux有关的问题:

https://www.penguinprompt.com/mariadb-10-0-29-update-failure-selinux/

我能够启动mysql服务并使用mysql_secure_installationconfiguration

我有同样的麻烦。 我的解决方法是: sudo systemctl start mysql.servicesudo chkconfig mysql on

也许你应该暂时禁用SeLinux: sudo setenforce 0

问候