RHEL有時候使用自定義的YUM源是很方便的事情。
yum install createrepo
createrepo /your/repo/directory/
不過由於粗心,本人在使用時遇到很郁悶的坑,錯誤如下:
[root@localhost rpms]# yum install openssl
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_64 0:1.0.1e-15.el6 will be updated
---> Package openssl.x86_64 0:1.0.1e-16.el6_5.7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================================================================
Updating:
openssl x86_64 1.0.1e-16.el6_5.7 rhel-gmtadj-source 1.5 M
Transaction Summary
=====================================================================================================================================================================================================
Upgrade 1 Package(s)
Total download size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
Error Downloading Packages:
openssl-1.0.1e-16.el6_5.7.x86_64: failed to retrieve openssl-1.0.1e-16.el6_5.7.x86_64.rpm from rhel-gmtadj-source
error was [Errno 2] Local file does not exist: /var/www/html/rpms/-o/openssl-1.0.1e-16.el6_5.7.x86_64.rpm
其它都正常就是下載不了文件。
經過很長時間的郁悶排查后,發現其實原來,創建repo的時候,RPM包一定要放在REPO目錄下面的子目錄中
下面的REPO是錯誤的
[root@localhost rpms]# ll total 1548 -rw-r--r-- 1 root root 1578640 Nov 10 18:42 openssl-1.0.1e-16.el6_5.7.x86_64.rpm drwxr-xr-x 2 root root 4096 Nov 11 12:21 repodata [root@localhost rpms]# pwd /var/www/html/rpms
正確的是
[root@nfsserver local-yum]# ll total 8 drwxr-xr-x. 2 root root 4096 Nov 11 19:26 repodata drwxr-xr-x. 2 root root 4096 Nov 11 19:25 x86_64 [root@nfsserver local-yum]#
X86_64中才是你要安裝的RPM包。
==========
yum grouplist
一般情況下在執行yum grouplist時會報錯Setting up Group Process Error: No group data available for configured repositories,這是因為源里缺少comps****.xpm文件造成的,這個文件可以在/home/unixer0 /Local_yum_source/Workstation/repodata(根據你的源位置)找到,不過名字並不是comps***而是一些數字字母組合,后面會跟着comps****.xpm例如6107d2dc7436b6e577ca7c20a552c687b224aa60b04bde96a862141bcdecbb36-comps-rhel6-Workstation.xml
復制這個文件到/home/unixer0/Local_yum_source目錄下,並重新命名為comps-rhel6-Workstation.xml這樣就可以了。重新執行上面的命令,好了,本地源就建立完成了。
5.可以打開add/remove software看下了,當然,要在它的設置部分system>software sources里勾選你剛建立的源,例如my_local_source.