一、配置网络YUM源( 仅以163源为例 )
1.1 卸载RHEL原有YUM套件;
[root@instructor Desktop]# rpm -qa | grep yum ##记录下YUM套件的各个构成部分 [root@instructor Desktop]# rpm -qa | grep yum | xargs rpm -e --nodeps
1.2 下载对应RHEL发行版的CENT的yum套件(可借助浏览器完成);
[root@instructor Desktop]# wget mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm [root@instructor Desktop]# wget mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm [root@instructor Desktop]# wget mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm [root@instructor Desktop]# wget mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-utils-1.1.30-14.el6.noarch.rpm
1.3 安装CENT的yum套件;
[root@instructor Desktop]# ls yum-3.2.29-40.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm yum-utils-1.1.30-14.el6.noarch.rpm [root@instructor Desktop]# rpm -ivh * ##使用文件名匹配,省去安装依赖性的烦恼
1.4 移除原有YUM源,下载新的YUM源(可借助浏览器完成);
[root@instructor Desktop]# cd /etc/yum.repos.d/ [root@instructor yum.repos.d]# ls rhel-source.repo [root@instructor yum.repos.d]# rm -rf rhel-source.repo [root@instructor yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O RHEL6-163.repo
1.5 编辑YUM源,修正$releasever为REHL当前版本;
[root@instructor yum.repos.d]# vim RHEL6-163.repo ##替换$releasever为具体版本 # 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=RHEL6-Base-163.com baseurl=http://mirrors.163.com/centos/6.5/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=RHEL6-Updates-163.com baseurl=http://mirrors.163.com/centos/6.5/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=RHEL6-Plus-163.com baseurl=http://mirrors.163.com/centos/6.5/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=RHEL6-Contrib-163.com baseurl=http://mirrors.163.com/centos/6.5/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
二、配置本地YUM源( 仅以原厂DVD为例 )
2.1 挂载原厂DVD到RHEL系统某一目录下;
[root@instructor ~]# mkdir -p /opt/iso/rh6.5 [root@instructor ~]# mount -o loop -t iso9660 /srv/iso/rhel-server-6.5-x86_64.iso /opt/iso/rh6.5/ [root@instructor ~]# vim /etc/fstab UUID=490e8615-713a-464f-bbc2-6d2386b5ced1 / ext4 defaults 1 1 UUID=7156655d-32ce-4fbd-8f67-ef6a30554940 /boot ext4 defaults 1 2 UUID=28c93127-a669-4345-950c-953683da6b71 swap swap defaults 0 0 ##将光盘设置为开机自动挂载 /srv/iso/rhel-server-6.5-x86_64.iso /opt/iso/rh6.5 iso9660 defaults,loop 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0
2.2 手动编写YUM源;
[root@instructor ~]# cd /etc/yum.repos.d/ [root@instructor yum.repos.d]# vim RHEL6-LOCAL.repo # [RHEL6-LOCAL.repo] [base-local] name=RHEL6-CDROM baseurl=file:///opt/iso/rh6.5 gpgcheck=0 ##信任本地光盘,取消gpg校验
三、更新YUM源
3.1 清除旧的YUM源缓存,缓存新的软件安装信息;
[root@instructor ~]# yum clean all ##清除以往旧的缓存 [root@instructor ~]# yum makecache ##下载源软件包信息,增强软件搜索速度
四、使用YUM源安装软件(仅以gcc/g++为例)
[root@instructor ~]# yum -y install gcc [root@instructor ~]# yum -y install gcc-c++
五、实验中出现的问题及解决方法
5.1 出现问题:更新YUM源数据库失败;
解决方法:手动下载数据库(可借助浏览器完成),放置到YUM缓存路径;手动下载数据库时,尽量对比网络YUM源及本地YUM缓存数据库(/var/cache/yum)的异同进行选择性下载;
[root@instructor ~]# wget http://mirrors.163.com/centos/6.5/updates/x86_64/repodata/852ea3ace1b06f27b1f081dea8ef4ea911653dd24dd02621d0b5afafc17f5d59-other.sqlite.bz2 [root@instructor ~]# mv 852ea3ace1b06f27b1f081dea8ef4ea911653dd24dd02621d0b5afafc17f5d59-other.sqlite.bz2 /var/cache/yum/x86_64/$releasever/updates-163/