Yum简单配置

Yum 简介

Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

yum命令参数

-e [error level], --errorlevel=[error level] 错误输出级别
-q, --quiet 安静的操作
-t 忽略错误
-R[分钟] 设置等待时间
-y 自动应答yes
--skip-broken 忽略依赖问题
--nogpgcheck 忽略GPG验证

check-update 检查可更新的包
clean all 清除全部
clean packages 清除临时包文件(/var/cache/yum 下文件)
clean headers 清除rpm头文件
clean oldheaders 清除旧的rpm头文件
deplist 列出包的依赖
list 可安装和可更新的RPM包
list installed 已安装的包
list extras 已安装且不在资源库的包
info 可安装和可更新的RPM包 信息
info installed 已安装包的信息(-qa 参数相似)
install[RPM包] 安装包
localinstall 安装本地的 RPM包
update[RPM包] 更新包
upgrade 升级系统
search[关键词] 搜索包
provides[关键词] 搜索特定包文件名
reinstall[RPM包] 重新安装包
repolist 显示资源库的配置
resolvedep 指定依赖
remove[RPM包] 卸载包

例子

安装:

[root@localhost ~]# yum install php53        #安装php5.3及其相关依赖包

[root@localhost ~]# yum groupinstall "MySQL Server"    #安装mysql数据库组

查找和显示:

[root@localhost ~]# yum info php53          #查看php53的安装信息

[root@localhost ~]# yum list                #列出所有可安装的程序包

[root@localhost ~]# yum list php53         #列出所有php53的程序包

[root@localhost ~]# yum groupinfo "MySQL Server"    #查看mysql服务组的,相关安装包

[root@localhost ~]# yum deplist php53      #查看php53依赖情况

卸载:

[root@localhost ~]# yum remove php53          #删除php53

[root@localhost ~]# yum groupremove "MySQL Server"    #删除mysql服务组

清除缓存:

[root@localhost ~]# yum clean packages            #清除缓存目录下的软件包

[root@localhost ~]# yum clean headers             #清除缓存目录下的 headers

[root@localhost ~]# yum clean oldheaders          #清除缓存目录下旧的 headers

[root@localhost ~]# yum clean, yum clean all      #清除所有

 等待补充:

 

配置yum源

配置本地yum源

将系统镜像挂载

[root@node1 ~]# mount /dev/sr0 /media/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@node1 ~]# ll /media/
总用量 694
-rw-rw-r--. 1 root root     14 9月  10 2019 CentOS_BuildTag
drwxr-xr-x. 3 root root   2048 9月   6 2019 EFI
-rw-rw-r--. 1 root root    227 8月  30 2017 EULA
-rw-rw-r--. 1 root root  18009 12月 10 2015 GPL
drwxr-xr-x. 3 root root   2048 9月  10 2019 images
drwxr-xr-x. 2 root root   2048 9月  10 2019 isolinux
drwxr-xr-x. 2 root root   2048 9月   6 2019 LiveOS
drwxrwxr-x. 2 root root 671744 9月  12 2019 Packages
drwxrwxr-x. 2 root root   4096 9月  12 2019 repodata
-rw-rw-r--. 1 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 1 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root   2883 9月  12 2019 TRANS.TBL

配置yum源文件

cd /etc/yum.repos.d/
vi base.repo
[base]#仓库的名字 
name=base#描述 
baseurl=file:///media#服务器软件包所在的绝对路径 (ftp:// or http:// or file:// )
gpgcheck=0#对包是否进行检测(1检测,0不检测) 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #gpgkey的绝对路径
enable=1#是否启用(1启用,0关闭)
[root@node1 ~]# yum repolist 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                  源名称                                                状态
base                                                    base                                                  4,067
repolist: 4,067

 显示有源及源的包的数量即可安装,不同的软件包需要配置不同的源,一般配置网络源

[root@localhost ~]# yum -y install ntpdate
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 ntpdate.x86_64.0.4.2.6p5-29.el7.centos 将被 安装
--> 解决依赖关系完成

依赖关系解决

===================================================================================================================
 Package                 架构                   版本                                    源                    大小
===================================================================================================================
正在安装:
 ntpdate                 x86_64                 4.2.6p5-29.el7.centos                   base                  86 k

事务概要
===================================================================================================================
安装  1 软件包

总下载量:86 k
安装大小:121 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : ntpdate-4.2.6p5-29.el7.centos.x86_64                                                           1/1 
  验证中      : ntpdate-4.2.6p5-29.el7.centos.x86_64                                                           1/1 

已安装:
  ntpdate.x86_64 0:4.2.6p5-29.el7.centos                                                                           

完毕!

配置网络yum源

大致同上,至修改其中的配置文件即可

配置yum源文件

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-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.ustc.edu.cn/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=https://mirrors.ustc.edu.cn/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=https://mirrors.ustc.edu.cn/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=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

posted @ 2022-09-15 20:57  kklinux  阅读(610)  评论(0编辑  收藏  举报