如何使用 rpm(而不是 yum cmd)在 CentOS 6.4 中安装 MariaDB rpm + 处理 mysql-libs 冲突

如何使用 rpm(而不是 yum cmd)在 CentOS 6.4 中安装 MariaDB rpm + 处理 mysql-libs 冲突

我需要在 CentOS 6.4 中使用 rpm 命令编写 MariaDB 安装脚本。我不能使用 yum,因为它将进行离线安装,因此无法访问存储库。

安装的唯一 MySQL 软件包是 mysql-libs,因为 CentOS 中的其他各种软件包都依赖于它。当我使用 yum 测试安装 MariaDB 时,它正确地考虑了 mysql-libs 并在最后将其卸载,因为 MariaDB 在安装后可以处理依赖项:

[root@new-host-6 ~]# yum install MariaDB-client MariaDB-common MariaDB-compat MariaDB-devel MariaDB-server MariaDB-shared
Loaded plugins: downloadonly, fastestmirror, refresh-packagekit, security, verify
Loading mirror speeds from cached hostfile
 * base: mirrors.kernel.org
 * extras: mirror.keystealth.org
 * updates: mirror.umd.edu
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:5.5.32-1 will be installed
---> Package MariaDB-common.x86_64 0:5.5.32-1 will be installed
---> Package MariaDB-compat.x86_64 0:5.5.32-1 will be obsoleting
---> Package MariaDB-devel.x86_64 0:5.5.32-1 will be installed
---> Package MariaDB-server.x86_64 0:5.5.32-1 will be installed
---> Package MariaDB-shared.x86_64 0:5.5.32-1 will be obsoleting
---> Package mysql-libs.x86_64 0:5.1.66-2.el6_3 will be obsoleted
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================
 Package                                     Arch                                Version                                 Repository                            Size
====================================================================================================================================================================
Installing:
 MariaDB-client                              x86_64                              5.5.32-1                                mariadb                               10 M
 MariaDB-common                              x86_64                              5.5.32-1                                mariadb                               23 k
 MariaDB-compat                              x86_64                              5.5.32-1                                mariadb                              2.7 M
     replacing  mysql-libs.x86_64 5.1.66-2.el6_3
 MariaDB-devel                               x86_64                              5.5.32-1                                mariadb                              5.6 M
 MariaDB-server                              x86_64                              5.5.32-1                                mariadb                               34 M
 MariaDB-shared                              x86_64                              5.5.32-1                                mariadb                              1.1 M
     replacing  mysql-libs.x86_64 5.1.66-2.el6_3

Transaction Summary
====================================================================================================================================================================
Install       6 Package(s)

Total download size: 53 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): MariaDB-5.5.32-centos6-x86_64-client.rpm                                                                                              |  10 MB     00:06     
(2/6): MariaDB-5.5.32-centos6-x86_64-common.rpm                                                                                              |  23 kB     00:00     
(3/6): MariaDB-5.5.32-centos6-x86_64-compat.rpm                                                                                              | 2.7 MB     00:02     
(4/6): MariaDB-5.5.32-centos6-x86_64-devel.rpm                                                                                               | 5.6 MB     00:06     
(5/6): MariaDB-5.5.32-centos6-x86_64-server.rpm                                                                                              |  34 MB     00:23     
(6/6): MariaDB-5.5.32-centos6-x86_64-shared.rpm                                                                                              | 1.1 MB     00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                               1.3 MB/s |  53 MB     00:40     
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid: "Daniel Bartholomew (Monty Program signing key) <[email protected]>"
 From  : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : MariaDB-compat-5.5.32-1.x86_64                                                                                                                   1/7 
  Installing : MariaDB-common-5.5.32-1.x86_64                                                                                                                   2/7 
  Installing : MariaDB-server-5.5.32-1.x86_64                                                                                                                   3/7 
chown: cannot access `/var/lib/mysql': No such file or directory

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h new-host-6 password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://kb.askmonty.org or the
MySQL manual for more instructions.

Please report any problems with the '/usr/bin/mysqlbug' script!

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Support MariaDB development by buying support/new features from
Monty Program Ab. You can contact us about this at [email protected].
Alternatively consider joining our community based development effort:
http://kb.askmonty.org/en/contributing-to-the-mariadb-project/

  Installing : MariaDB-devel-5.5.32-1.x86_64                                                                                                                    4/7 
  Installing : MariaDB-client-5.5.32-1.x86_64                                                                                                                   5/7 
  Installing : MariaDB-shared-5.5.32-1.x86_64                                                                                                                   6/7 
  Erasing    : mysql-libs-5.1.66-2.el6_3.x86_64                                                                                                                 7/7 
  Verifying  : MariaDB-common-5.5.32-1.x86_64                                                                                                                   1/7 
  Verifying  : MariaDB-server-5.5.32-1.x86_64                                                                                                                   2/7 
  Verifying  : MariaDB-devel-5.5.32-1.x86_64                                                                                                                    3/7 
  Verifying  : MariaDB-client-5.5.32-1.x86_64                                                                                                                   4/7 
  Verifying  : MariaDB-compat-5.5.32-1.x86_64                                                                                                                   5/7 
  Verifying  : MariaDB-shared-5.5.32-1.x86_64                                                                                                                   6/7 
  Verifying  : mysql-libs-5.1.66-2.el6_3.x86_64                                                                                                                 7/7 

Installed:
  MariaDB-client.x86_64 0:5.5.32-1         MariaDB-common.x86_64 0:5.5.32-1         MariaDB-compat.x86_64 0:5.5.32-1         MariaDB-devel.x86_64 0:5.5.32-1        
  MariaDB-server.x86_64 0:5.5.32-1         MariaDB-shared.x86_64 0:5.5.32-1        

Replaced:
  mysql-libs.x86_64 0:5.1.66-2.el6_3                                                                                                                                

Complete!

我的问题是,与 yum 相比,使用 rpm 命令安装 MariaDB 包的等效方法是什么?

如果我执行 rpm -ivh MariaDB*.rpm,我会收到大量类似以下与 mysql-libs 冲突的消息:

file /etc/my.cnf from install of MariaDB-common-5.5.32-1.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
file /usr/share/mysql/charsets/Index.xml from install of MariaDB-common-5.5.32-1.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64

然后我使用 --force 选项安装 MariaDB rpm 并卸载 mysql-lib,我没有收到任何奇怪的消息,但我不确定这是处理冲突和执行安装的最干净的方法。

因此,有人可以确认使用以下 rpm 命令安装 MariaDB 与使用 yum 安装软件包和处理 mysql-libs 冲突/删除相同:

rpm -ivh --force MariaDB*.rpm

rpm -e mysql-libs

谢谢您的任何意见!

答案1

你不需要。你可以使用yum它来干净利落地处理这种情况。它可以直接使用 RPM 包离线运行,前提是全部必要的依赖项可用或已经安装。

  1. 将适当的 MariaDB RPM 下载到您的 USB 记忆棒或 DVD-ROM。

    yumdownloader MariaDB-client MariaDB-common MariaDB-compat MariaDB-devel MariaDB-server MariaDB-shared
    
  2. 将您的 USB 记忆棒或 DVD-ROM 带到目标机器并将其复制进去。

  3. 安装它们:

    yum --disablerepo=* -y install MariaDB-*.rpm
    

答案2

您不应该执行“rpm -ivh ...”,而应该执行“rpm -Uvh ...”。

除了内核之外,-Uvh 应该总是使用。

已废弃:使用--install,-i时,标签不会执行。

答案3

我使用以下 repo(作为 /etc/yum.repos.d/mariadb.repo):

# MariaDB 5.5 CentOS repository list - created 2013-09-14 02:06 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

对于应用程序来说,二进制兼容性非常重要,这是通过安装同一 repo 提供的 MariaDB-compat 包来实现的(由于某种原因,我在你的列表中没有看到它):

[root@backup ~]# rpm -qlp mysql-libs-5.1.69-1.el6_4.x86_64.rpm |grep so
/etc/ld.so.conf.d/mysql-x86_64.conf
/usr/lib64/mysql/libmysqlclient.so.16
/usr/lib64/mysql/libmysqlclient.so.16.0.0
/usr/lib64/mysql/libmysqlclient_r.so.16
/usr/lib64/mysql/libmysqlclient_r.so.16.0.0
[root@backup ~]# rpm -qlp MariaDB-5.5.32-centos6-x86_64-compat.rpm
/usr/lib64/libmysqlclient.so.15
/usr/lib64/libmysqlclient.so.15.0.0
/usr/lib64/libmysqlclient.so.16
/usr/lib64/libmysqlclient.so.16.0.0
/usr/lib64/libmysqlclient_r.so.15
/usr/lib64/libmysqlclient_r.so.15.0.0
/usr/lib64/libmysqlclient_r.so.16
/usr/lib64/libmysqlclient_r.so.16.0.0

因此,您可以卸载 mysql-libs,然后安装 MariaDB-server 包,这将安装所有必需的包和 MariaDB-compat 包,这将淘汰 mysql-libs,因此依赖关系不会被破坏:

[root@backup ~]# rpm -qp --obsoletes MariaDB-5.5.32-centos6-x86_64-compat.rpm 
mysql-libs < 5.3.5
[root@backup ~]# 

因此,之后就不会出现任何问题,rpm 不会报告任何不兼容问题,(提供 mysql-libs = 5.3.5):

[root@backup ~]# rpm -qlp --provides MariaDB-5.5.32-centos6-x86_64-compat.rpm 
libmysqlclient.so.15()(64bit)  
libmysqlclient.so.15(libmysqlclient_15)(64bit)  
libmysqlclient.so.16()(64bit)  
libmysqlclient.so.16(libmysqlclient_16)(64bit)  
libmysqlclient_r.so.15()(64bit)  
libmysqlclient_r.so.15(libmysqlclient_15)(64bit)  
libmysqlclient_r.so.16()(64bit)  
libmysqlclient_r.so.16(libmysqlclient_16)(64bit)  
mysql-libs = 5.3.5
MariaDB-compat = 5.5.32-1
MariaDB-compat(x86-64) = 5.5.32-1
/usr/lib64/libmysqlclient.so.15
/usr/lib64/libmysqlclient.so.15.0.0
/usr/lib64/libmysqlclient.so.16
/usr/lib64/libmysqlclient.so.16.0.0
/usr/lib64/libmysqlclient_r.so.15
/usr/lib64/libmysqlclient_r.so.15.0.0
/usr/lib64/libmysqlclient_r.so.16
/usr/lib64/libmysqlclient_r.so.16.0.0
[root@backup ~]#

答案:是的,您可以卸载 mysql-libs 并安装这些包,但从这个 repo 下载。

(yumdownloader MariaDB-client.x86_64 MariaDB-common.x86_64 MariaDB-compat.x86_64 等)

相关内容