Linux更换yum源
1、删除自带yum包
rpm -aq | grep yum | xargs rpm -e --nodeps
2、检查一下
rpm -qa | grep yum
3、下载yum安装相关文件
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
4、安装python
rpm -ivh python*
5、安装yum
rpm -ivh --force --nodeps yum*
6、配置yum源
yum-config-manager --add-repo="http://mirrors.163.com/.help/CentOS6-Base-163.repo"
7、更改yum的repo文件内容
cd /etc/yum.repos.d/
vi CentOS6-Base-163.repo
:%s/$releasever/7/ge
:%s/RPM-GPG-KEY-CentOS-6/RPM-GPG-KEY-CentOS-7/ge
8、清除缓存
yum clean all
9、生成缓存
yum makecache
10、重新加载
yum makecache fast
yum -y update 出现报错处理:
initscripts conflicts with redhat-release-server-7.4-18.el7.x86_64
修改yum配置文件
vim /etc/yum.conf
阻止yum 更新内核与initscripts包
exclude=kernel*
exclude=centos-release*
exclude=initscripts
yum源本地配置
一、上传系统镜像文件至服务器,挂载至本地
mkdir /mnt/redh
mount -o loop /opt/*.iso /mnt/redh
二、创建本地yum源文件,删除其他的
cd /etc/yum.repos.d/
vim local.repo
[local]
name=local
baseurl=file:///mnt/redh
enabled=1
gpgcheck=0
三、清理缓存
yum clean all