赞
踩
这里使用red hat 6.4 x86 minimal
mkdir /localsource //创建yum本地源仓库
mount /dev/cdrom /mnt
cp -r /mnt/Packages/* /localsource //复制光盘中所有安装包到本地
cd /etc/yum.repos.d/
mv rhel-source.repo rhel-source.repo.bak //备份原来的yum源文件
vi localsource.repo //下面红色字体为文件内容
[localsource]
name=localsource
baseurl=file:///localsource/ //仓库地址
enabled=1 // 1 为开启仓库
gpgcheck=0
rpm -ivh /localsource/createrepo-0.9.9-17.el6.noarch.rpm //有依赖关系
以下为安装过程
createrepo -d /localsource/
yum clean all //清除原有缓存
yum makecache //生成缓存
yum -y install vim OK! yum 本地源配置完成。
wget http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
下载完成后安装 rpm -ivh python-*
wget http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
wget http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
安装:rpm -ivh yum-* --nodeps –force
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
vi CentOS6-Base-163.repo (:%s/$releasever/6/g)替换字段为系统版本号
ß------------------------以下为文件原内容-------------------------------à
[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
ß--------------------------以上为文件内容-------------------------------à
yum -y install vim OK ! yum 网络源配置完成。
在后来工作中发现,本yum源中没有个别安装包,所以我们要添加另外的yum源。
rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
导入key
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
之后就可以使用yum了,例如:yum -y install htop
安装插件: yum -y install yum-priorities
在各yum源文件中添加优先级字段 priority=N // N的值为1-99 数字越小、优先级越大
yum check-update
网络推荐设置参数如下:
[base], [addons], [updates], [extras] … priority=1
[centosplus],[contrib] … priority=2
9、RedHat 换 CentOS yum源的时候,只需要更换 /etc/yum.repo.d/ 下的配置文件,然后清除原有缓存,在生成新缓存就可以了!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。