红联Linux门户
Linux帮助

yum源的搭建

发布时间:2008-08-22 15:39:33来源:红联作者:zidscen
先说下原理:随便在机器上建立一个http或是ftp的站点,然后去修改yum的配置文件,关掉它默认搜索的源的地址,改成我们自己建立的。

一、http站点形式的(测试成功过,也比较方便)

1)把rpm文件拷到本机的随便一个目录下(我在根目录下建立了一个/data目录)

2)安装apache(我用的rpm的):1.装完后用/etc/init.d/httpd start 命令启动,然后测试下是否起来了。2.起来就去改配置文件/etc/httpd/conf/httpd.conf:把DocumentRoot改成拷rpm包的目录,DocumentRoot "/data" ,就这两地。3。重起apache

3)改yum的配置文件。1。先到/etc/yum.repos.d下看看是否有个rhel-debuginfo.repo文件,有给他改名字,只要结尾不是repo就行。2. 拷贝rhel-debuginfo.repo 为update.repo,主要是怕手写写错了。3. 默认的里头是这些:

[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-debuginfo]:头部标题,随便写

name=:名字,也随便写了

baseurl=:这个要写你的http的地址

enabled=0 :是否开启,1是开启。0是关闭

gpgcheck=:是否校验key。肯定不了,选0

gpgkey=:这个是你key的地址,都不了,就不用写这个了。

改好后的是:

[base]
name=base RPM Repository for RHEL5
baseurl=http://192.168.254.28
enabled=1
gpgcheck=0

4)yum clean all :清除yum缓存

以后就可以yum装软件了,如果不行,就把目录变成可浏览列表的那样。

二、ftp站点的

yum服务器搭建:
0.安装vsftpd
1.copy 所有rpm到/var/ftp/pub/Server
2.rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
3.createrepo -v /var/ftp/pub/Server/
4.创建一个server1.repo的配置文件供客户端使用,告知客户端服务器在哪里
[Server]
name=Server1 Server Repository
baseurl=ftp://server1.domain.com/pub/Server
gpgcheck=0

1. 安装yum
 
  2. 修改。repo文件
 
  ccd /etc/yum.repos.d/
 
  #vi CentOS-Base.repo
 
  写入一下内容: 
name=CentOS-5 - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&
repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#released updates

name=CentOS-5 - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#packages used/produced in the build but not released

name=CentOS-5 - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons

baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#additional packages that may be useful

name=CentOS-5 - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras

baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#additional packages that extend functionality of existing packages

name=CentOS-5 - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

#contrib - packages by Centos Users

name=CentOS-5 - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

# vi dag.repo

name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jphttp://Linux.chinaitlab.com/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=1
gpgkey=http://ftp.riken.jphttp://Linux.chinaitlab.com/dag/packages/RPM-GPG-KEY.dag.txt
 
  3. 导入key
 
  #rpm ----import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
 
  4. 运行,测试
 
  #yum update

出自http://blog.sina.com.cn/linuxasone
文章评论

共有 3 条评论

  1. ba0zhu 于 2008-08-26 20:48:19发表:

    哈哈,我自己用了一个月时间,,疯狂google。。。终于结合好多前辈的经验自己成功建立本地yum源。。。
    是可以分组的那种哦。。。今天傍晚才与官方同步结束。。

  2. Yayi 于 2008-08-26 06:17:15发表:

    呵呵。。学习了。

  3. zhuoli76 于 2008-08-25 19:49:08发表:

    想用单位的机子建个fedora镜像,只供朋友用,