四、Yum服务器安装createrepo并创建仓库
createrepo是Linux下的创建仓库的软件包,这个软件包在系统镜像CentOS-5.8-i386-bin-DVD-1of2里是有的。这里已经拷贝到/var/www/html/yum/CentOS目录下了。
[root@ ~]# rpm -ivh /var/www/html/yum/CentOS /createrepo-0.4.11-3.el5.noarch.rpm
Preparing... ########################################### [100%]
1:createrepo ########################################### [100%]
(注:在CentOS 5.7下安装会有如下警告,但不影响后续操作:
warning: /var/www/html/yum/CentOS/createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897)
安装完成之后,在/usr/bin/目录下会有一个createrepo命令。使用createrepo 生成XML metadata,在/var/www/html/yum/CentOS目录下生成repodata 文件夹(具体有何作用,还没弄明白)
[root@ ~]# createrepo /var/www/html/yum/CentOS/
2669/2669 - compat-gcc-34-g77-3.4.6-4.1.i386.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
五、
客户端修改Centos-Base.repo,建议先备份一个副本,以后若要从外网更新的话,可以再使用。
[root@ ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[root@ ~]# vi /etc/yum.repos.d/CentOS-Base.repo
##############Centos-Base.repo内容修改后,以下#######################
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=http://192.168.56.123/yum/CentOS
enabled=1
gpgcheck=0
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://192.168.56.123/yum/CentOS
gpgcheck=1
enabled=1
gpgcheck=0
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://192.168.56.123/yum/CentOS
enabled=1
gpgcheck=0
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://192.168.56.123/yum/CentOS
enabled=1
gpgcheck=0
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
##############Centos-Base.repo内容修改后,以上#######################
注:[centosplus]和[contrib]的内容不需要修改,它们的enabled值默认值是0,即模块不启用。
操作基本完成了,运气好的话,可以直接从Yum服务器拿软件、升级包。
不过,并不排除意外发生。比如有报错,提示找不着路由。
以安装mc为例:
[root@ ~]# yum install mc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
: [Errno 4] IOError: <urlopen error (113, 'No route to host')>
Trying other mirror.
: [Errno 4] IOError: <urlopen error (113, 'No route to host')>
Trying other mirror.
: [Errno 4] IOError: <urlopen error (113, 'No route to host')>
Trying other mirror.
: [Errno 4] IOError: <urlopen error (113, 'No route to host')>
Trying other mirror.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mc.i386 1:4.6.1a-35.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mc i386 1:4.6.1a-35.el5 addons 2.1 M
Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 2.1 M
Is this ok [y/N]: y
Downloading Packages:
: [Errno 4] IOError: <urlopen error (113, 'No route to host')>
Trying other mirror.
Error Downloading Packages:
1:mc-4.6.1a-35.el5.i386: failure: mc-4.6.1a-35.el5.i386.rpm from addons: [Errno 256] No more mirrors to try.
搭建局域网CentOS Yum服务器(3)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/75ef71cb05f60318bbf917cac07c2883.html