建立本地RPM源之更新系統舊版軟件mysql

事情原由

系統版本爲Centos6.6 ,由於以前同事沒有采用最小化選擇性安裝,因此係統安裝好後自帶有mysql5.1的三個安裝包:mysql

[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更新操做來將其更替:nginx

[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-commonsql

[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源來更新軟件。vim

安裝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包的文件信息)post

[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並將舊版移除。url

總結

1) 在使用createrepo命令建立本地rpm源信息時,要使用絕對路徑而非相對路徑;spa

2) 若是有新的軟件包須要放在本地yum源中,須要再次執行createrepo更新本地rpm源信息;code

3) 本地yum源能很好解決舊版軟件間的依賴關係,再也不須要手動一步步解決。server

相關文章
相關標籤/搜索