1 问题
安装的Linux(Redhat7.6纯净系统),内在工具很少
1.1 如果没有注册的话,就没法使用yum源,也就没办法用yum install来安装软件包
1.2 内置没有wget安装包。无法用rpm -ivh wget 来安装。
2 解决思路
2.1 在镜像网站找到wget包,传到Linux上。通过rpm完成wget的安装。## 问题1.2解决
2.2 在镜像网站找到yum安装包,使用wget下载,再用rpm -ivh安装。
2.3 配置.repo文件
2.4 验证yum是否成功。 ##问题1.1解决
3 实现过程
镜像网站:Index of /centos-vault/7.6.1810/os/x86_64/Packages/ (163.com)
3.1
在镜像网站下载wget包,传至.repo文件下。(这里使用XFTP 7)
切换至 /etc/yum.repos.d/ 文件夹下,通过rpm安装wget。
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# yum.repos.d]# rpm -ivh wget-1.14-18.el7.x86_64.rpm
3.2
查看系统版本及已安装的yum包
[root@localhost yum.repos.d]# cat /etc/redhat-release
[root@localhost yum.repos.d]# rpm -qa|grep yum
删除所有yum包并再次查看
[root@localhost yum.repos.d]# rpm -qa | grep yum | xargs rpm -e --nodeps
[root@localhost yum.repos.d]# rpm -qa|grep yum
通过wget到镜像网站下载所需要的包。
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/python-urllib3-1.10.2-5.el7.noarch.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm
wget http://mirrors.163.com/centos-vault/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
下载后进行强制安装
rpm -ivh --force rpm-4.11.3-35.el7.x86_64.rpm python-urllib3-1.10.2-5.el7.noarch.rpm yum-3.4.3-161.el7.centos.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-rhn-plugin-2.0.1-10.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
安装完成,进行.repo文件的配置
vi redhat.repo 将下面内容粘贴进去,报存并退出。
vi redhat.repo
# 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=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
http://mirrors.aliyuncs.com/centos/7/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
http://mirrors.aliyuncs.com/centos/7/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/7/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/7/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
再将文件名改为CentOS-Base.repo
mv redhat.repo CentOS-Base.repo
3 结果
最后清除缓存并更新
yum clean all
yum makecache
最后进行测试:
yum -y install vim
成功搞定!
参考引用文章网址: