7.12 yum 命令使用指南及问题排查方法 =================================== |image0| 安装 ---- 加个 ``-y`` 可以在安装包时代替用户自动响应 yes .. code:: shell $ yum install -y xxx 加个 ``--installroot=/usr/local/`` 指定将软件安装在 /usr/local 目录下,而不安装在默认路径下 .. code:: shell $ yum install --installroot=/usr/local/ -y xxx 重新安装 == 卸载再安装 .. code:: shell $ yum reinstall -y xxx 下载 ---- 只下载安装包 .. code:: shell yumdownloader --destdir /home/wangbm/ perl-Sys-Virt.x86_64 下载安装包及其依赖包 .. code:: shell yumdownloader --resolve --destdir /home/wangbm/ perl-Sys-Virt.x86_64 yumdownloader --resolve --destdir /home/test/ systemd-devel-219-62.el7_6.2.x86_64 查看 ---- 查看具体包的信息 .. code:: shell $ yum info zabbix-agent 查看配置并启用的仓库中有哪些包,包括已安装和未安装的 .. code:: shell $ yum list 查看有哪些包可以升级的 .. code:: shell $ yum list updates 查询一个命令是由哪个包提供的 .. code:: shell $ yum provides xxx 查询一个模块/共享库/文件是哪个包提供的 .. code:: shell $ yum whatprovides xxx 列出所有的容器 .. code:: shell $ yum repolist all 查询某个仓库下的所有包 .. code:: shell $ yum repo-pkgs list 查看一个包的所有依赖项 .. code:: shell $ yum deplist httpd 搜索 ---- 在配置并启用的仓库中搜索包 .. code:: shell $ yum search zabbix-agent 升级 ---- .. code:: shell $ yum update xxx 删除 ---- .. code:: shell $ yum remove -y xxx 清理 ---- 清理已下载的软件文件 .. code:: shell $ yum clean packages 清理已下载的软件文件头 .. code:: shell $ yum clean headers 清理下载过的容器相关数据 .. code:: shell $ yum clean all 分组 ---- 查看分组 .. code:: shell $ yum grouplist 查看分组信息 .. code:: shell $ yum groupinfo 安装一整组软件 .. code:: shell $ yum groupinstall 删除某个组 .. code:: shell $ yum groupremove 历史 ---- .. code:: shell $ yum history 语言 ---- 列出已安装的语言 .. code:: shell $ yum langlist 为语言安装适当的语言包 .. code:: shell $ yum langinstall 删除语言的已安装语言包 .. code:: shell $ yum langremove 其他 ---- 执行事务 .. code:: shell $ yum load-transaction /tmp/yum_save_tx.xxx.n0EVjx.yumtx 生成元数据缓存 .. code:: shell $ yum makecache 进入交互式模式 .. code:: shell $ yum shell 选项 ---- .. code:: shell -h, - help显示此帮助消息并退出 -t, - 容忍错误 -C,--cacheonly完全从系统缓存运行,不更新缓存 -q, - 安静的操作 -v, - verbose详细操作 -y, - assumeyes对所有问题都回答是 --assumeno对所有问题都回答否 --version显示Yum版本并退出 --installroot = [path]设置安装root --obsoletes在更新期间启用过时处理 --noplugins禁用Yum插件 --nogpgcheck禁用gpg签名检查 -skip-broken 跳过没有解决问题的包 --color = COLOR控制是否使用颜色 --downloadonly不更新,只需下载 --downloaddir = DLDIR指定存储包的备用目录 --setopt = SETOPTS设置任意配置和repo选项 --bugfix在更新中包含bugfix相关包 --security在更新中包含安全相关的包 --advisory = ADVS, - advisories = ADVS 更新包括修复给定建议所需的包 --bzs = BZS 更新包括修复给定BZ所需的包 --cves = CVES 更新包括修复给定CVE所需的包 --sec-severity = SEVS, - secseverity = SEVS 配置文件位置 .. code:: shell -c [config file], - config = [config file] 最大命令等待时间 .. code:: shell -R [minute], - randomwait = [minute] 调试输出级别 .. code:: shell -d [debug level], - debug level = [debug level] 在repos中,在list / search命令中显示重复项 .. code:: shell --showduplicates 错误输出级别 .. code:: shell -e [error level], - errorlevel = [error level] 调试rpm的输出级别 .. code:: shell --rpmverbosity = [debug level name] 启用/禁用仓库(允许使用通配符) .. code:: shell --enablerepo = [repo] --disablerepo = [repo] 按名称或glob排除包 .. code:: shell -x [package], - exclude = [package] 禁用从main,repo或所有内容的排除 .. code:: shell --disableexcludes = [plugin] 禁用包含repo或所有内容的includepkgs .. code:: shell --disableincludes = [plugin] 按名称禁用插件 .. code:: shell --disableplugin = [plugin] 按名称启用插件 .. code:: shell --enableplugin = [plugin] 在yum config和repo文件中设置$ releasever的值 .. code:: shell --releasever = RELEASEVER yum-utils 使用 .. code:: shell $ yum install yum-utils # 清理未完成的yum事务 $ yum-complete-transaction --cleanup-only # 清除可能存在的重复包 $ package-cleanup --dupes # 清除可能存在的损坏包 $ package-cleanup --problems glibc-common-2.17-196.el7_4.2.x86_64 has missing requires of glibc = ('0', '2.17', '196.el7_4.2') # 将上面列出的包卸载 $ rpm -e glibc-common-2.17-196.el7_4.2.x86_64 问题排查记录 ------------ 查找一个 so 文件是属于哪个 rpm 包 经常在安装一个包的时候,会报如下的错误,找不到某 so 文件 |image1| 如果是缺一个包,那我们安装它就行了,缺 so 文件,那咋弄? 首先我们要找到有这个 so 文件的机器,然后可以用 yum 提供的工具来获取其所属的 rpm 包 ,然后安装这个包即可。 .. code:: shell $ yum whatprovides /usr/lib64/libpcap.so.1 ... 14:libpcap-1.5.3-8.el7.x86_64 : A system-independent interface for user-level packet capture Repo : @anaconda Matched from: Filename : /usr/lib64/libpcap.so.1.5.3 $ yum install libpcap 查看某个包的安装历史 .. code:: bash # 查该包所有的安装历史 $ yum history list python-nova-tests # 只能查已安装的包的安装日期。截图中,之所以存在两个包,是因为该机器上存在两个版本的包 $ rpm -qa --last | grep python-nova-tests |image2| 查看安装某个包是如何安装的,从哪安装 .. code:: bash $ yumdb info python-nova-tests |image3| |image4| .. |image0| image:: http://image.iswbm.com/20200602135014.png .. |image1| image:: http://image.iswbm.com/20191219152328.png .. |image2| image:: http://image.iswbm.com/20191225173340.png .. |image3| image:: http://image.iswbm.com/20191225175350.png .. |image4| image:: http://image.iswbm.com/20200607174235.png