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!