阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

创建本地RPM源之更新系统旧版软件MySQL

171次阅读
没有评论

共计 3667 个字符,预计需要花费 10 分钟才能阅读完成。

事情起因

系统版本为 CentOS6.6,因为之前同事没有采用最小化选择性安装,所以系统安装好后自带有 MySQL5.1 的三个安装包:

[root@test ~]# rpm -qa | grep mysql
mysql-5.1.73-3.el6_6.x86_64
mysql-devel-5.1.73-3.el6_6.x86_64
mysql-lib-5.1.73-3.el6_6.x86_64

在安装新版本 mysql 前卸载旧版本

卸载 掉了 mysql 和 mysql-devel,但 没能成功卸载 mysql-libs,因为存在着依赖关系,所以打算采用 rpm 更新操作来将其更替:

[root@test ~/Downloads/V137788-01]# rpm -Uvh mysql-commercial-libs-5.7.12-1.1.el6.x86_64.rpm 
warning: mysql-commercial-client-5.7.12-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
    mysql-commercial-common(x86-64) = 5.7.12-1.1.el6 is needed by mysql-commercial-libs-5.7.12-1.1.el6.x86_64
    libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
    libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64

看来还需要添加上:mysql-commercial-common

[root@test ~/Downloads/V137788-01]# rpm -U mysql-commercial-libs-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-common-5.7.12-1.1.el6.x86_64.rpm 
warning: mysql-commercial-libs-5.7.12-1.1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
    libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
    libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64

但是这样还是没能解决,而且卸载 postfix 会引发更多的 rpm 包卸载,这样的实施成本就提高了,不是愿意看到的,所以又想到创建本地 yum 源来更新软件。

安装 createrepo 包

[root@test ~/Downloads/V137788-01]# yum install -y createrepo

[root@test ~/Downloads/V137788-01]# mkdir /opt/soft; cd /opt/soft/
将 mysql 的 rpm 包文件移动到这个目录下 
[root@test
/opt/soft]# mv ~/Downloads/V137788-01/mysql* ./
=================================================================================
查看 [root@test
/opt/soft]# ls libmcrypt-2.5.8-4.3.x86_64.rpm libmcrypt-devel-2.5.8-4.3.x86_64.rpm mysql-commercial-client-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-common-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-devel-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-embedded-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-embedded-devel-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-libs-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-libs-compat-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-server-5.7.12-1.1.el6.x86_64.rpm mysql-commercial-test-5.7.12-1.1.el6.x86_64.rpm nginx-1.9.15-1.el6.icefox.x86_64.rpm

使用 createrepo 创建本地 yum 源

这时会在本地 yum 源目录中多出一个repodata 目录(存放有本地 yum 源的 rpm 包的文件信息)

[root@test /]# createrepo -v /opt/soft/

[root@test /opt/soft]# ls
libmcrypt-2.5.8-4.3.x86_64.rpm
libmcrypt-devel-2.5.8-4.3.x86_64.rpm
mysql-commercial-client-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-common-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-devel-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-embedded-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-embedded-devel-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-libs-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-libs-compat-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-server-5.7.12-1.1.el6.x86_64.rpm
mysql-commercial-test-5.7.12-1.1.el6.x86_64.rpm
nginx-1.9.15-1.el6.icefox.x86_64.rpm
repodata

编辑 repo 文件
[root@test /]# vim /etc/yum.repos.d/local.repo
[LC]
name=local-rpm
baseurl=file:///opt/soft
enabled=1
gpgcheck=0

安装新版 mysql

[root@test /]# yum install mysql-commercial-libs mysql-commercial-server mysql-commercial-client mysql-commercial-devel
...
Installed:
  mysql-commercial-client.x86_64 0:5.7.12-1.1.el6                               
  mysql-commercial-devel.x86_64 0:5.7.12-1.1.el6                                
  mysql-commercial-libs.x86_64 0:5.7.12-1.1.el6                                 
  mysql-commercial-libs-compat.x86_64 0:5.7.12-1.1.el6                          
  mysql-commercial-server.x86_64 0:5.7.12-1.1.el6                               

Dependency Installed:
  mysql-commercial-common.x86_64 0:5.7.12-1.1.el6                               

Replaced:
  mysql-libs.x86_64 0:5.1.73-3.el6_5                                            

Complete!

这里问题算是解决了,安装新版 mysql 并将旧版移除。

总结

1) 在使用 createrepo 命令创建本地 rpm 源信息时,要使用绝对路径而非相对路径;

2) 如果有新的软件包需要放在本地 yum 源中,需要再次执行 createrepo 更新本地 rpm 源信息;

3) 本地 yum 源能很好解决旧版软件间的依赖关系,不再需要手动一步步解决。

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-05/143693.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计3667字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中