知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

CentOS 构建本地源YUM服务

发布时间:2014-09-05 17:07:16作者:知识屋

 

想必大家对linux下的YUM服务并不陌生吧,之前有将linux下redhat构建YUM的步骤有写出来,今天主要写一下如何在centos下构建YUM,尽管centos是redhat的克隆版,但也有很多的不同之处;

此链接是讲解如何在redhat上构建YUM,http://www.linuxdiyf.com/bbs/viewthread.php?tid=204212&extra=page%3D2%26amp%3Borderby%3Ddateline

下面是CentOS下构建YUM的步骤

1.首先把镜像盘挂在上:mount /dev/cdrom /media/cdrom/

2.安装http的包,  rpm -ivh /media/cdrom/CentOS/httpd-2.2.3-43.el5.centos.i386.rpm

 3.安装YUM常用的RPM包(有的包是默认已经安装的,但也要查一下是否安装)

  rpm -ivh /media/cdrom/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm

   rpm -ivh /media/cdrom/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

   rpm -ivh /media/cdrom/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

   rpm -ivh /media/cdrom/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm

 4.新建一个自定义的目录,用来放置你的RPM包,也是http访问的目录:/data/CentOS/i386/

将挂在的rpm包的集合复制一份到/data/CentOS/i386/下,(因为你不可能挂在你的镜像盘一辈子)

 /cp -rf /media/cdrom/CentOS/ /data/CentOS/i386/

5.将/media/cdrom下的repodata/ 拷贝到/data/CentOS/i386/CentOS下

 cp -rf /media/cdrom/repodata/ /data/CentOS/i386/CentOS/       (后面会用到的)

6.安装rpm -ivh /media/cdrom/CentOS/createrepo-0.4.11-3.el5.noarch.rpm  (此包是用来安装服务端设置软件仓库及信息文件)

 rpm -ivh /media/cdrom/CentOS/createrepo-0.4.11-3.el5.noarch.rpm

7.先把http服务启动,service httpd start ,如果这个服务不能搞定,其他的一切都是做无用功)

 netstat -anpt | grep 80

tcp        0      0 :::80                       :::*                        LISTEN      8389/httpd

 8.生成客户端所需的信息文件

createrepo  -g /media/cdrom/repodata/comps.xml /data/CentOS/i386/

9.将key文件(用于客户端与服务端的认证)拷入指定目录/data/CentOS/i386 下

cp /media/cdrom/RPM-GPG-KEY-CentOS-5 /data/CentOS/i386/

10.修改http服务的配置文件,如何你是默认安装的httpd,其配置文件路径为:

vi /etc/httpd/conf/httpd.conf

 修改一下两行即可:(显示的是更改后的)

DocumentRoot "/data/CentOS/"

<Directory "/data/CentOS/">

之后保存,退出。。重启httpd服务、、、service httpd restart

 

11.用你的IE浏览器浏览下,看能不能访问http://172.16.17.140/i386/CentOS/ 下面显示的是rpm包算是正却的

 

12.更改yum的配置文件,更改之前要做好备份

、cp CentOS-Base.repo CentOS-Base.repo.bak

 之后清空你的CentOS-Base.repo 文件

方法:> CentOS-Base.repo  即可

vi CentOS-Base.repo

 [base]

name=CentOS5.3-base

baseurl=http://172.16.17.140/i386/

enable=1

gpgcheck=1

gpgkey=http://172.16.17.140/i386/RPM-GPG-KEY-CentOS-5

这样即可了

下面就是测试了。。。

先执行下yum clean all

之后验证下

 

[root@centos yum.repos.d]# yum install gcc

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

base                                                                                    | 1.1 kB     00:00    

base/primary                                                                            | 912 kB     00:00    

base                                                                                                 2599/2599

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package gcc.i386 0:4.1.2-48.el5 set to be updated

--> Processing Dependency: libgomp >= 4.1.2-48.el5 for package: gcc

--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc

--> Running transaction check

---> Package glibc-devel.i386 0:2.5-49 set to be updated

--> Processing Dependency: glibc-headers = 2.5-49 for package: glibc-devel

--> Processing Dependency: glibc-headers for package: glibc-devel

---> Package libgomp.i386 0:4.4.0-6.el5 set to be updated

--> Running transaction check

---> Package glibc-headers.i386 0:2.5-49 set to be updated

--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers

--> Processing Dependency: kernel-headers for package: glibc-headers

--> Running transaction check

---> Package kernel-headers.i386 0:2.6.18-194.el5 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===============================================================================================================

 Package                        Arch                 Version                        Repository            Size

===============================================================================================================

Installing:

 gcc                            i386                 4.1.2-48.el5                   base                 5.2 M

Installing for dependencies:

 glibc-devel                    i386                 2.5-49                         base                 2.0 M

 glibc-headers                  i386                 2.5-49                         base                 601 k

 kernel-headers                 i386                 2.6.18-194.el5                 base                 1.0 M

 libgomp                        i386                 4.4.0-6.el5                    base                  70 k

 

Transaction Summary

===============================================================================================================

Install       5 Package(s)

Upgrade       0 Package(s)

 

Total download size: 8.9 M

Is this ok [y/N]: y

Downloading Packages:

(1/5): libgomp-4.4.0-6.el5.i386.rpm                                                     |  70 kB     00:00    

(2/5): glibc-headers-2.5-49.i386.rpm                                                    | 601 kB     00:00    

(3/5): kernel-headers-2.6.18-194.el5.i386.rpm                                           | 1.0 MB     00:00    

(4/5): glibc-devel-2.5-49.i386.rpm                                                      | 2.0 MB     00:00    

(5/5): gcc-4.1.2-48.el5.i386.rpm                                                        | 5.2 MB     00:00    

---------------------------------------------------------------------------------------------------------------

Total                                                                           14 MB/s | 8.9 MB     00:00    

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897

base/gpgkey                                                                             | 1.5 kB     00:00    

Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>" from http://172.16.17.140/i386/RPM-GPG-KEY-CentOS-5

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing     : libgomp                                                                                 1/5

   Installing     : kernel-headers                                                                          2/5

   Installing     : glibc-headers                                                                           3/5

   Installing     : glibc-devel                                                                             4/5

   Installing     : gcc                                                                                     5/5

 

 Installed:

  gcc.i386 0:4.1.2-48.el5                                                                                     

 

Dependency Installed:

  glibc-devel.i386 0:2.5-49        glibc-headers.i386 0:2.5-49       kernel-headers.i386 0:2.6.18-194.el5     

  libgomp.i386 0:4.4.0-6.el5     

 

Complete!

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜