linux6.8 yum 修改配置

1、linux的在线的yum源更新是需要收费的,因此我们需要采用CentOS6的yum源配置方式
2、基本思路:
下载CentOS6软件。
先卸载linux自带的yum软件。
安装CentOS6的软件。

备份及下载软件包
下载软件包
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm

卸载RedHat自带的yum
rpm -qa | grep yum | xargs rpm -e --nodeps (不检查依赖,直接删除rpm包)
rpm -qa |grep yum 查看,无信息显示表示已经卸载完成。
    
安装下载的centos的yum包

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm
最后3个需要一起安装,否则会出现依赖性错误

下载帮助文档
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
将下载的CentOS6-Base-163.repo复制到/etc/yum.repos.d/
     mv CentOS6-Base-163.repo /etc/yum.repos.d/
修改CentOS6-Base-163.repo
    编辑CentOS6-Base-163.repo文件,将其中的$releasever更改为centos的版本号,在vim下将所有的$releasever替换成6.8。可用g/$releasever/s/$releasever/6.8/g命令执行。并配置如下:

[base]
  name=CentOS-6.8 - Base - 163.com
  baseurl=http://mirrors.163.com/centos/6.8/os/$basearch/
      enabled=1          
      #mirrorlist=http://mirrorlist.centos.org/?release=6.8&arch=$basearch&repo=os
      gpgcheck=1
      gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
  注意,enabled=1,是新加上的。

清除原有缓存

yum clean all
获取yum列表
yum makecache
获取yum列表。出现下面提示,表示yum更改完成:
Metadata Cache Created

	# 创建脚本
	mkdir -p download
	cd download
	yum install wget
	wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
	wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
	wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
	wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
	wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
	rpm -qa | grep yum | xargs rpm -e --nodeps
	rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
	rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
	rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm
	wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
	mv CentOS6-Base-163.repo /etc/yum.repos.d/
	sed -i 's/$releasever/6.8/g' /etc/yum.repos.d/CentOS6-Base-163.repo
	sed -i '$a enabled=1' /etc/yum.repos.d/CentOS6-Base-163.repo
	yum clean all
	yum makecache
	echo $?

你可能感兴趣的:(yum)