1、前言
外包工作三年连服务器数据库这种的写权限都要请求开放,没有自己尝试的环境,也没有尝试的勇气。猛然换了份工作,看着身边的大牛们缺啥自己造啥,啥东西都能搞出来的样子相当向往。在羡慕大牛的路上也慢慢开始了自己的尝试。
2、简介
今天就说下yum源安装遇到的各种坑坑洼洼,还有最终自己尝试走出来的一条血路。希望自己铭记成功那一刻的快乐,也分享给大家一点小小的知识。
3、yum安装
3.1 检查环境信息
[root@node1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)
可以根据上图看到我用的环境是红帽7.5,7系列的可以跟我一起走下去,其他版本的可能会有一些小的变动。
3.2 查询是否有yum源
第一步:检测原来是否安装yum包
[root@localhost ~]# rpm -qa |grep yum
有的话需要先卸载
第二步:卸载原来安装的yum包
[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
检查是否卸载干净了:
[root@localhost ~]#rpm -qa |grep yum
因为我安装了好几遍才成功,所以此处将卸载的方式一并附上。
3.3下载yum源
第一步:进入yum.repos.d 文件夹下,下载centos依赖源
cd /etc/yum.repos.d/
[root@mater1 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
第二步:修改配置:
cd /etc/yum.repos.d/
vi CentOS-Base.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-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
第三步:下载yum其他依赖源
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.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-utils-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-54.el7_8.noarch.rpm
如果是cenos8的需要去http://mirrors.163.com/centos目录下找8下面对应的rpm文件
第四步:安装并测试
安装yum源:rpm -ivh yum-*
清除并构建
yum clean all
yum install gcc
最后执行:
yum makecache
如果出现下图,则yum源安装成功。
4、可能出现的问题
1、下载依赖源后,用yum命令执行报错:
[root@SOP-Application02 yum.repos.d]# yum clean all
bash: yum: 未找到命令…
原因没有安装yum依赖,只做了下载。执行下面命令安装即可
rpm -ivh yum-*
5、安装的目的
安装yum之后,就可以一键安装docker、jenkins、mysql、oracle等工具 ,非常方便