需求
centos可以联外网,但yum不可用,我要用yum安装工具,(看清自己的系统哦!)
安装
- 清楚以前配置
rpm -aq|grep yum|xargs rpm -e --nodeps
- 进入rpm网站下载rpm包 http://mirrors.163.com/centos/7/os/x86_64/Packages/,注意centos/7/中的6和7根据自己的系统选择,然后下载对应rpm:
1. yum-.rpm
2. yum-metadata-parser-.rpm
3. yum-plugin-fastestmirror-.rpm
4. python-iniparse-.rpm
"*"表示选择你自己的版本,如我选择
image.png
-
安装YUM
- 先安装 python-iniparse-*.rpm
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm - 安装其他包
rpm -ivh yum-*.rpm
- 先安装 python-iniparse-*.rpm
-
安装完成后更新镜像文件
- cd /etc/yum.repos.d
- 下载镜像 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
- 将文件中的$releasever替换成7 (7是指LINUX版本号)
vi CentOS7-Base-163.repo
#可以用命令:%s/$releasever/7/g替换
结果:
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-
重命名文件
mv CentOS7-Base-163.repo CentOS7-Base.repo -
运行yum makecache 生成缓存
-
运行yum clean all(等同于 yum cleanheaders ; yum cleanpackages)
-
yum update 更新yum,此时要等待一段时间,更新所有文件
-
完成
Linux操作集目录 https://www.jianshu.com/p/7839d27c62f8
网友评论