本文是按部就班学运维-基础篇系列的第42篇文章前端
上篇文章中,咱们聊到了rpm包的管理,其中有rpm包的平常使用方法及rpm包的安全校验, 在使用rpm包的时候,相信你们也常常感受到安装依赖包的痛苦。那么这篇文章,咱们一块儿来聊聊yum的使用。python
yum最大的优点就是可以解决rpm包的依赖问题,自动解决安装时候的依赖。
不过yum也有缺陷,最大的缺陷就是若是有未完成的安装在强行终止的状况下,下次再次安装容易出现没法解决的依赖问题。vim
为了处理yum自己的缺陷,引入了dnf命令,dnf的使用方法和yum同样。 dnf彻底是用python写的,更新了依赖关系解析器的后端,比yum效率更高。后端
这里引入百度出来的yum的概念:centos
yum是yellowdog update manager的简称,它可以实现rpm管理的全部操做,并可以自动解决各rpm包之间的依赖关系。yum是rpm的前端工具,是基于rpm来实现软件的管理的一个工具。缓存
其实不懂yum的概念,一点也不妨碍你使用yum去工做,真的。安全
1) 先确保镜像已经挂载服务器
2) 配置yum源文件进行挂载网络
[root@xinsz08-1 ~]# cd /etc/yum.repos.d/redhat6.repovim redhat.repo[rhel-source]name=Redhat baseurl=file:///mnt enabled=1 gpgcheck=0
备注:运维
内容 | 释义 |
---|---|
[rhel-source] | yum源名称,在本服务器上惟一,用来区分不一样的yum源 |
name=Redhat | 对yum源的描述 |
baseurl=file:///mnt | yum的挂载路径,file,http,ftp三种形式的路径 |
enabled=1 | 为1表示开启yum源,0表示禁用 |
gpgcheck=0 | 为1 表示使用公钥检验rpm包正确性,0位不校验 |
3) 在命令行挂载镜像到/mnt
如今配置网络yum源愈来愈简单了,不用重复造轮子,直接使用阿里云的镜像站便可
2) 我用的是centos6的系统,因此直接选择 centos6.repo便可
怎么知道本身的操做系统?
[root@xinsz08-15 yum.repos.d]# cat /etc/centos-release CentOS release 6.9 (Final)
根据本身的系统型号,选择6仍是7或者8的repo包,我这里选择6的
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
3) 运行 yum makecache 生成缓存
[root@xinsz08-15 yum.repos.d]# cat /etc/centos-release
能够愉快的使用yum了
[root@xinsz08-15 ~]# yum install vsftpd
[root@xinsz08-15 ~]# yum install httpd -y
[root@xinsz08-15 ~]# yum update -y
[root@xinsz08-15 ~]# yum -y upgrade
[root@xinsz08-15 ~]# yum info httpd
[root@xinsz08-15 ~]# yum provides /usr/bin/ab # 查看ab命令是哪一个包安装的已加载插件:fastestmirror, refresh-packagekit, security Repository epel is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.bfsu.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com httpd-tools-2.2.15-69.el6.centos.x86_64 : Tools for use with the Apache HTTP Server Repo : base 匹配来自于: Filename : /usr/bin/ab httpd-tools-2.2.15-69.el6.centos.x86_64 : Tools for use with the Apache HTTP Server Repo : installed 匹配来自于: Other : 提供依赖知足:/usr/bin/ab
[root@xinsz08-15 ~]# yum remove httpd
yum grouplist 查看有哪些安装组
yum groupinstall “开发工具”
我这里安装的是开发工具,因此是中文的开发工具四个字。
总结: 本文主要对yum的网络配置和本地配置作了一些介绍,对yum的使用方法作了一些讲解,最主要的仍是要学会配置本地yum源,以及会使用网络yum源。
在公司里咱们通常会配置本地yum仓库,使用ftp或者http来共享公司内部使用的yum源仓库,确保版本统一,下载速度快。
我是高胜寒,一个在教培行业不忘初心的人, 关注我,一块儿学习,欢迎点赞收藏,咱们下篇文章再见!