最近公司要做一个内部的软件升级系统。由于现有架上服务器操作系统基本都是RedHat AS4 update2或者RedHat AS4 update4,而使用rhn来升级不太符合公司现状,考虑到CentOS和Redhat的兼容性相当的好,所以打算建立一个yum服务器,为架上服务器提供CentOS 4.7的源(写这篇文章时4.7是版本4里最新的),来升级陈旧的软件。我们选择了当前最新的centos5.2来架设yum服务器。下面是我的步骤,写下来,念想,:)
benxiong
2008-11-04
一、yum服务器
1.环境
OS: CentOS5.2
IP: 192.168.254.128
2.需要安装的软件包
安装完操作系统后,默认已经安装如下的包:
yum-metadata-parser-1.1.2-2.el5
yum-updatesd-0.9-2.el5
yum-3.2.8-9.el5.centos.1
为了搭建服务器,我们还需要安装如下两个包:
createrepo-0.4.11-3.el5 (iso镜象文件里有)
yum-arch-2.2.2-2.el5.noarch.rpm 它的下载地址如下:
使用#rpm -Uvh *.rpm 来安装。
3.配置httpd,并创建目录
安装操作系统时,选择安装http的包。由于我们是内部使用,所以采用默认配置即可,这里只需要启动httpd服务,并配置成开机自启动即可,命令如下:
#service httpd start #chkconfig --level 345 httpd on
|
接下来,我们创建用于存放rpm包的目录,命令如下:
[root@glzc1 html]# mkdir -p yum/centos/4/os/i386 [root@glzc1 html]# mkdir -p yum/centos/4/updates/i386 [root@glzc1 html]# mkdir -p yum/centos/4/extras/i386
|
4.下载最新的CentOS 4.7的包
这里使用wget将mirror.be10.com源上的rpm包抓了下来,大概4.4G,比较耗时,命令如下:
wget -r -c -nH --cut-dirs=5 http://mirror.be10.com/centos/4/extras/i386/RPMS/ /var/www/html/yum/centos/4/extras/i386/ wget -r -c -nH --cut-dirs=6 /var/www/html/yum/centos/4/os/i386/ wget -r -c -nH --cut-dirs=5 http://mirror.be10.com/centos/4/updates/i386/RPMS/ /var/www/html/yum/centos/4/updates/i386/
|
下载完成后,我们可以看到相应的i386目录下都是rpm包,当然还有一些无用的index.html文件,可以到相应目录下删除,命令如下:
#rm -f index.html*
注:细心的朋友可能发现,我们要建立centos4.7的源,怎么下载路径里是4呢? 这是因为目录4总是和版本4里最新的版本目录建立连接,你可以发现此时4和4.7是一样的,^_^
5.下载RPM-GPG-KEY-centos4,并将其放入i386目录下
[root@glzc1 i386]# pwd /var/www/html/yum/centos/4/os/i386 [root@glzc1 i386]# wget http://mirror.be10.com/centos/4/os/i386/RPM-GPG-KEY-centos4 [root@glzc1 i386]# cp RPM-GPG-KEY-centos4 ../../extras/i386/ [root@glzc1 i386]# cp RPM-GPG-KEY-centos4 ../../updates/i386/
|
6.RPM分析,会在目录下产生 heaers 目录
# yum-arch /var/www/html/yum/centos/4/os/i386 # yum-arch /var/www/html/yum/centos/4/updates/i386 # yum-arch /var/www/html/yum/centos/4/extras/i386
|
7.createrepo生成 XML metadata,会在相应目录下创建repodata目录
# createrepo /var/www/html/yum/centos/4/os/i386 # createrepo /var/www/html/yum/centos/4/updates/i386 # createrepo /var/www/html/yum/centos/4/extras/i386
|
ok,我们yum服务器的设置就完成了。
二、yum客户端
1.安装yum包
我们这里的架上服务器都是RadHat AS4 U2或U4的,所以要在其上安装yum。需要的软件包如下:
centos-yumconf-4-4.5.noarch.rpm
python-elementtree-1.2.6-5.el4.centos.i386.rpm
python-sqlite-1.1.7-1.2.1.i386.rpm
python-urlgrabber-2.9.8-2.noarch.rpm
sqlite-3.3.6-2.i386.rpm
yum-2.4.3-4.el4.centos.noarch.rpm
yum-metadata-parser-1.0-8.el4.centos.i386.rpm
centos-yumconf-4-4.5.noarch.rpm的下载地址为:
其它的包都可以到下面找到:
使用#rpm -Uvh *.rpm 安装
2.将原先的centos库去除并添加AS4库
[root@yumclient ~]#rm -rf /etc/yum.repos.d/CentOS-Base.repo
[root@yumclient ~]#vi /etc/yum.repos.d/as4-update.repo #添加如下内容
[base] name=Red Hat Enterprise As release 4 base baseurl=http://192.168.254.128/yum/centos/4/os/i386/ gpgcheck=1 gpgkey=http://192.168.254.128/yum/centos/4/os/i386/RPM-GPG-KEY-centos4 [update] name=Red Hat Enterprise As release 4 updates baseurl=http://192.168.254.128/yum/centos/4/updates/i386/ gpgcheck=1 gpgkey=http://192.168.254.128/yum/centos/4/updates/i386/RPM-GPG-KEY-centos4 [extras] name=Red Hat Enterprise As release 4 extras baseurl=http://192.168.254.128/yum/centos/4/extras/i386/ gpgcheck=1 gpgkey=http://192.168.254.128/yum/centos/4/extras/i386/RPM-GPG-KEY-centos4
|
好了,至此yum已经可以使用了。
3.验证
我们使用yum来安装firefox来验证一下,:)
[root@yumclient yum.repos.d]# yum install firefox
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for firefox to pack into transaction set.
firefox-3.0.2-3.el4.cento 100% |=========================| 75 kB 00:00
---> Package firefox.i386 0:3.0.2-3.el4.centos set to be updated
--> Running transaction check
--> Processing Dependency: evolution28-pango for package: firefox
--> Processing Dependency: evolution28-gtk2 for package: firefox
--> Processing Dependency: nss >= 3.11.99.5 for package: firefox
--> Processing Dependency: nspr >= 4.7.0.99.2 for package: firefox
--> Processing Dependency: libnssutil3.so for package: firefox
--> Processing Dependency: evolution28-cairo for package: firefox
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for evolution28-gtk2 to pack into transaction set.
evolution28-gtk2-2.10.4-2 100% |=========================| 61 kB 00:00
---> Package evolution28-gtk2.i386 0:2.10.4-22.el4 set to be updated
---> Downloading header for evolution28-cairo to pack into transaction set.
evolution28-cairo-1.2.4-6 100% |=========================| 9.0 kB 00:00
---> Package evolution28-cairo.i386 0:1.2.4-6.el4 set to be updated
---> Downloading header for evolution28-pango to pack into transaction set.
evolution28-pango-1.14.9- 100% |=========================| 20 kB 00:00
---> Package evolution28-pango.i386 0:1.14.9-7.el4 set to be updated
---> Downloading header for nss to pack into transaction set.
nss-3.12.1.1-1.el4.centos 100% |=========================| 8.1 kB 00:00
---> Package nss.i386 0:3.12.1.1-1.el4.centos set to be updated
---> Downloading header for nspr to pack into transaction set.
nspr-4.7.1-1.el4.i386.rpm 100% |=========================| 3.1 kB 00:00
---> Package nspr.i386 0:4.7.1-1.el4 set to be updated
--> Running transaction check
--> Processing Dependency: evolution28-atk >= 1.9.0-1 for package: evolution28-gtk2
--> Processing Dependency: evolution28-glib2 >= 2.12.0-1 for package: evolution28-gtk2
--> Processing Dependency: evolution28-glib2 for package: evolution28-pango
--> Processing Dependency: evolution28-glib2 >= 2.12.0-1 for package: evolution28-pango
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for evolution28-atk to pack into transaction set.
evolution28-atk-1.12.2-4. 100% |=========================| 18 kB 00:00
---> Package evolution28-atk.i386 0:1.12.2-4.el4 set to be updated
---> Downloading header for evolution28-glib2 to pack into transaction set.
evolution28-glib2-2.12.3- 100% |=========================| 25 kB 00:00
---> Package evolution28-glib2.i386 0:2.12.3-6.el4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
firefox i386 3.0.2-3.el4.centos update 19 M
Installing for dependencies:
evolution28-atk i386 1.12.2-4.el4 base 217 k
evolution28-cairo i386 1.2.4-6.el4 base 358 k
evolution28-glib2 i386 2.12.3-6.el4 base 631 k
evolution28-gtk2 i386 2.10.4-22.el4 update 6.4 M
evolution28-pango i386 1.14.9-7.el4 base 306 k
nspr i386 4.7.1-1.el4 update 101 k
nss i386 3.12.1.1-1.el4.centos update 974 k
Transaction Summary
=============================================================================
Install 8 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 28 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): evolution28-atk-1. 100% |=========================| 217 kB 00:00
(2/8): evolution28-glib2- 100% |=========================| 631 kB 00:00
(3/8): evolution28-gtk2-2 100% |=========================| 6.4 MB 00:00
(4/8): evolution28-cairo- 100% |=========================| 358 kB 00:00
(5/8): evolution28-pango- 100% |=========================| 306 kB 00:00
(6/8): firefox-3.0.2-3.el 100% |=========================| 19 MB 00:01
(7/8): nss-3.12.1.1-1.el4 100% |=========================| 974 kB 00:00
(8/8): nspr-4.7.1-1.el4.i 100% |=========================| 101 kB 00:00
warning: rpmts_HdrFromFdno: V3 DSA signature: NOKEY, key ID 443e1821
Public key for evolution28-atk-1.12.2-4.el4.i386.rpm is not installed
Retrieving GPG key from
Importing GPG key 0x443E1821 "CentOS-4 key <>"
Is this ok [y/N]: y
Key imported successfully
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: nspr ####################### [ 1/10]
Installing: evolution28-cairo ####################### [ 2/10]
Installing: evolution28-glib2 ####################### [ 3/10]
Installing: evolution28-pango ####################### [ 4/10]
Installing: nss ####################### [ 5/10]
Installing: evolution28-atk ####################### [ 6/10]
Installing: evolution28-gtk2 ####################### [ 7/10]
Installing: firefox ####################### [ 8/10]
Removing : seamonkey-nss ####################### [ 9/10]
Removing : seamonkey-nspr ####################### [10/10]
Installed: firefox.i386 0:3.0.2-3.el4.centos
Dependency Installed: evolution28-atk.i386 0:1.12.2-4.el4 evolution28-cairo.i386 0:1.2.4-6.el4 evolution28-
glib2.i386 0:2.12.3-6.el4 evolution28-gtk2.i386 0:2.10.4-22.el4 evolution28-pango.i386 0:1.14.9-7.el4 nspr.i386
0:4.7.1-1.el4 nss.i386 0:3.12.1.1-1.el4.centos
Complete!
阅读(2049) | 评论(0) | 转发(0) |