更新 01

更新 01

我对 Linux 还不熟悉,正在 Windows 上的 Virtualbox 中测试各种 LAMP 设置。目前,我有一台 Centos 7 VM,正在尝试在其上安装 MariaDB。我遵循以下说明:http://www.tecmint.com/install-lamp-in-centos-7

我跑了

# yum install mariadb-server mariadb

根据终端输出,安装成功,但是当我运行时:

 # systemctl start mariadb

我明白了

Failed to start mariadb.service: Unit not found.

我花了几个小时在谷歌上搜索这个问题,但似乎没有什么能解决我的问题,包括这个(mariadb-server 安装后没有 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 repos 而不是 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.

答案1

进一步的研究表明,在 MariaDB repo (v 10.0.30) 中服务被称为,mysql而在 centos repo (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_installation

答案2

我想我应该检查 mariadb-server 是否正确安装 - 它似乎包含服务定义:

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 映像(官方 centos docker 容器)上尝试了您的安装命令,但无法重现您的问题。

您可能需要尝试重新安装 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

答案3

我也遇到了同样的问题。我的解决方案是:sudo systemctl start mysql.servicesudo chkconfig mysql on

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

问候

相关内容