yum服務器的搭建與配置
YUM的基本工作流程如下:
服務器端:在服務器上面存放了所有的RPM軟件包,然後以相關的功能去分析每個RPM文件的依賴性關系,將這些數據記錄成文件存放在服務器的某特定目錄內。
客戶端:如果需要安裝某個軟件時,先下載服務器上面記錄的依賴性關系文件(可通過WWW或FTP方式),通過對服務器端下載的紀錄數據進行分析,然後取得所有相關的軟件,一次全部下載下來進行安裝。
我的環境:
CentOS release 5.5 (Final)
1.安裝yum包
我的系統是默認安裝好了,如果沒安裝的話要找相對應的安裝文件了。
[root@localhost yum.repos.d]# rpm -q yum
yum-3.2.22-26.el5.centos
2.復制RPM包
[root@localhost repodata]# pwd
/media/CentOS_5.5_Final/repodata
[root@localhost repodata]# ll
total 17107
-rw-r--r-- 1 root root 941644 May 6 2010 comps.xml
-rw-r--r-- 1 root root 3605890 May 6 2010 filelists.xml.gz
-rw-r--r-- 1 root root 11743815 May 6 2010 other.xml.gz
-rw-r--r-- 1 root root 1221980 May 6 2010 primary.xml.gz
-rw-r--r-- 1 root root 1296 May 6 2010 repomd.xml
-r--r--r-- 1 root root 1121 May 6 2010 TRANS.TBL
[root@localhost media]# cp -rf CentOS_5.5_Final/ /var/ftp/pub/
3.安裝createrepo包並重建包的依賴關系
[root@centos Server]# rpm -q createrepo
package createrepo is not installed
[root@centos Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm
warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:createrepo ########################################### [100%]
[root@localhost yum.repos.d]# rpm -q createrepo
createrepo-0.4.11-3.el5
[root@localhost ftp]# createrepo /var/ftp/pub/CentOS_5.5_Final/
500/3392 - CentOS/tomcat5-servlet-2.4-api-javadoc-5.5.23-0jpp.7.el5_3.2.x86_64.r
706/3392 - CentOS/jakarta-commons-collections-testframework-3.2-2jpp.3.x86_64.rp
2792/3392 - CentOS/yum-NetworkManager-dispatcher-1.1.16-14.el5.centos.1.noarch.r
2851/3392 - CentOS/jakarta-commons-collections-testframework-javadoc-3.2-2jpp.3.
3392/3392 - CentOS/xsane-0.991-5.el5.x86_64.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[root@localhost repodata]# pwd
/var/ftp/pub/CentOS_5.5_Final/repodata
[root@localhost repodata]# ll
total 16408
-rw-r--r-- 1 root root 941644 Jun 13 19:33 comps.xml
-rw-r--r-- 1 root root 3561694 Jun 13 19:43 filelists.xml.gz
-rw-r--r-- 1 root root 11045736 Jun 13 19:43 other.xml.gz
-rw-r--r-- 1 root root 1209861 Jun 13 19:43 primary.xml.gz
-rw-r--r-- 1 root root 951 Jun 13 19:43 repomd.xml
-r--r--r-- 1 root root 1121 Jun 13 19:33 TRANS.TBL
發現這裡的部分文件已更新了。
4.搭建ftp或者apach環境(如果服務器和客戶端是同一台機器,此步驟可以忽略)
[root@centos Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm
warning: vsftpd-2.0.5-16.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]
[root@centos Server]# chkconfig vsftpd on
[root@centos Server]# chkconfig vsftpd --list
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@centos Server]# service vsftpd restart
Shutting down vsftpd: [FAILED]
Starting vsftpd for vsftpd: [ OK ]
[root@centos Server]#
5.客戶端修改YUM配置文件
在每個客戶端使用YUM時,必須需要修改配置文件。
我們先看文件: /etc/yum.repos.d/*.repo。 這個文件名稱可以隨便定義,但是擴展名必須是repo.
[root@localhost yum.repos.d]# cat CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=file:///var/ftp/pub/CentOS_5.5_Final
gpgcheck=0
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
相關參數說明:
[ ]:內的是倉庫的名字,不重復即可。
name:倉庫的描述.
baseurl: YUM源地址, 這裡配置的是FTP,還可以是HTTP,FILE等。
enabled :是否啟用這個倉庫,1為起用,0為禁用
gpgcheck :是否檢查GPG簽名(驗證要安裝的包是不是REDHAT官方的)。
[root@localhost yum.repos.d]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-39.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================
Updating:
telnet x86_64 1:0.17-39.el5 base 59 k
Transaction Summary
=================================================================================================================================
Install 0 Package(s)
Upgrade 1 Package(s)
Total download size: 59 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Check Error:
file /usr/share/man/man1/telnet.1.gz from install of telnet-0.17-39.el5.x86_64 conflicts with file from package telnet-0.17-31.EL4.3.i386
Error Summary
-------------
執行yum update時 telnet包出錯,是由於之前我強制降級了telnet服務所導致的,這裡忽略掉。
試著安裝一個新的包gd-devel,包gd-devel和所有依賴的包都成功安裝了!
[root@localhost yum.repos.d]# yum install -y gd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gd-devel.i386 0:2.0.33-9.4.el5_4.2 set to be updated
--> Processing Dependency: freetype-devel for package: gd-devel
--> Processing Dependency: libpng-devel for package: gd-devel
--> Processing Dependency: libXpm-devel for package: gd-devel
--> Processing Dependency: libX11-devel for package: gd-devel
--> Processing Dependency: libjpeg-devel for package: gd-devel
--> Processing Dependency: libgd.so.2 for package: gd-devel
--> Processing Dependency: fontconfig-devel for package: gd-devel
---> Package gd-devel.x86_64 0:2.0.33-9.4.el5_4.2 set to be updated
--> Running transaction check
---> Package fontconfig-devel.x86_64 0:2.4.1-7.el5 set to be updated
---> Package freetype-devel.x86_64 0:2.2.1-21.el5_3 set to be updated
---> Package gd.i386 0:2.0.33-9.4.el5_4.2 set to be updated
--> Processing Dependency: libXpm.so.4 for package: gd
---> Package libX11-devel.x86_64 0:1.0.3-11.el5 set to be updated
--> Processing Dependency: xorg-x11-proto-devel >= 7.1-2 for package: libX11-dev el
--> Processing Dependency: libXau-devel for package: libX11-devel
--> Processing Dependency: libXdmcp-devel for package: libX11-devel
---> Package libXpm-devel.x86_64 0:3.5.5-3 set to be updated
---> Package libjpeg-devel.x86_64 0:6b-37 set to be updated
---> Package libpng-devel.x86_64 2:1.2.10-7.1.el5_3.2 set to be updated
--> Running transaction check
---> Package libXau-devel.x86_64 0:1.0.1-3.1 set to be updated
---> Package libXdmcp-devel.x86_64 0:1.0.1-2.1 set to be updated
---> Package libXpm.i386 0:3.5.5-3 set to be updated
---> Package xorg-x11-proto-devel.x86_64 0:7.1-13.el5 set to be updated
--> Processing Dependency: mesa-libGL-devel for package: xorg-x11-proto-devel
--> Running transaction check
---> Package mesa-libGL-devel.x86_64 0:6.5.1-7.8.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
gd-devel i386 2.0.33-9.4.el5_4.2 base 97 k
gd-devel x86_64 2.0.33-9.4.el5_4.2 base 102 k
Installing for dependencies:
fontconfig-devel x86_64 2.4.1-7.el5 base 168 k
freetype-devel x86_64 2.2.1-21.el5_3 base 146 k
gd i386 2.0.33-9.4.el5_4.2 base 154 k
libX11-devel x86_64 1.0.3-11.el5 base 661 k
libXau-devel x86_64 1.0.1-3.1 base 11 k
libXdmcp-devel x86_64 1.0.1-2.1 base 7.5 k
libXpm i386 3.5.5-3 base 45 k
libXpm-devel x86_64 3.5.5-3 base 32 k
libjpeg-devel x86_64 6b-37 base 105 k
libpng-devel x86_64 2:1.2.10-7.1.el5_3.2 base 184 k
mesa-libGL-devel x86_64 6.5.1-7.8.el5 base 461 k
xorg-x11-proto-devel x86_64 7.1-13.el5 base 247 k
Transaction Summary
================================================================================
Install 14 Package(s)
Upgrade 0 Package(s)
Total download size: 2.4 M
Downloading Packages:
--------------------------------------------------------------------------------
Total 43 MB/s | 2.4 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libXpm 1/14
Installing : freetype-devel 2/14
Installing : fontconfig-devel 3/14
Installing : libjpeg-devel 4/14
Installing : libpng-devel 5/14
Installing : libXau-devel 6/14
Installing : gd 7/14
Installing : xorg-x11-proto-devel 8/14
Installing : libX11-devel 9/14
Installing : libXpm-devel 10/14
Installing : libXdmcp-devel 11/14
Installing : gd-devel 12/14
Installing : gd-devel 13/14
Installing : mesa-libGL-devel 14/14
Installed:
gd-devel.i386 0:2.0.33-9.4.el5_4.2 gd-devel.x86_64 0:2.0.33-9.4.el5_4.2
Dependency Installed:
fontconfig-devel.x86_64 0:2.4.1-7.el5 freetype-devel.x86_64 0:2.2.1-21.el5_3
gd.i386 0:2.0.33-9.4.el5_4.2 libX11-devel.x86_64 0:1.0.3-11.el5
libXau-devel.x86_64 0:1.0.1-3.1 libXdmcp-devel.x86_64 0:1.0.1-2.1
libXpm.i386 0:3.5.5-3 libXpm-devel.x86_64 0:3.5.5-3
libjpeg-devel.x86_64 0:6b-37 libpng-devel.x86_64 2:1.2.10-7.1.el5_3.2
mesa-libGL-devel.x86_64 0:6.5.1-7.8.el5 xorg-x11-proto-devel.x86_64 0:7.1-13.el5
Complete!