搭建 yum 仓库

翻译来自:https://wiki.centos.org/HowTos/CreateLocalRepos

  1. 本地仓库

  2. http 仓库

  3. 测试


________________________________________

1. 本地仓库

# yum localinstall -y createrepo

# mount -o loop CentOS-xx.x86-64.iso tmp/ && cd tmp

# mkdir -P /data/yum_sources/CentOS/6/x64/RPMS

# mv *.rpm /data/yum_sources/CentOS/6/x64/RPMS

# chown -R root.root /data/yum_sources/CentOS/6

①# createrepo -v /data/yum_sources/CentOS/6/x64

②# chmod -R o-w+r /data/yum_source/CentOS/6

* 当添加新包进去时,执行“①②”。


# vi local.repo

[local]

name=CentOS-local

baseurl=file:///data/yum_sources/CentOS/6/x64

enabled=1

gpgcheck=0

protect=0


# wget http://dev.centos.org/centos/5/CentOS-Testing.repo

# cat CentOS-Testing.repo

[c5-testing]

name=CentOS-5 Testing

baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/

enabled=0

gpgcheck=1

gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing


直接复制光盘内容就可以生成yum仓库

mount -o loop CentOS-7.0-1406-x86_64-DVD.iso tmp/ && cd tmp

cp -r repodata /dinglicom/yum_sources/CentOS/7/x86_64/RPMS

cp -rv Packages /dinglicom/yum_sources/CentOS/7/x86_64/RPMS

cat /etc/yum.repos.d/CentOS-7.repo

[local-7]

name=CentOS-7-local

baseurl=file:///dinglicom/yum_sources/CentOS/7/x86_64/RPMS

enabled=1

gpgcheck=0

protect=0


2. http 仓库

* 新建个“http.repo”就可以了。根据上边的例子,适当修改路径即可。


# vi http.repo

[local]

name=CentOS-local

# baseurl=file:///data/yum_sources/CentOS/6/x64

# baseurl=http://mirror.centos.org/centos/6/x64

baseurl=http://10.97.57.2/centos/6/x64

enabled=1

gpgcheck=0

protect=0

* 把 rpm 包放到 http 服务器的对应目录下即可。


启用 CentOS 在亚洲上海交通大学的网站 yum 源。例子如下:

[sjtu-7]

name=sjtu-7

baseurl=http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/

enabled=1

gpgcheck=1

protect=0

gpgkey=http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7


3. 测试


# cat /etc/yum.repos.d/local.repo

[local]

name=CentOS-local

baseurl=file:///data/yum_sources/CentOS/6/x64

enabled=1

gpgcheck=0

protect=0


# yum repolist all

Loaded plugins: fastestmirror, protectbase, refresh-

              : packagekit, security

Loading mirror speeds from cached hostfile

0 packages excluded due to repository protections

repo id          repo name              status

local        CentOS-local    enabled: 4,799

repolist: 4,799

相关文章
相关标签/搜索