yum

yum常用命令及yum仓库搭建

List of Commands:
check          Check for problems in the rpmdb
check-update   Check for available package updates 检查可更新包 
clean          Remove cached data
deplist        List a package's dependencies  列出包的依赖包
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package  降级安装
erase/remove          Remove a package or packages from your system  卸载,依赖包也被卸载
groupinfo      Display details about a package group  查看包组信息,有哪些包
groupinstall   Install the packages in a group on your system  安装指定包组
grouplist      List available package groups  列出可用包组
groupremove    Remove the packages in a group from your system
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages  查看包信息
install/local install       Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package  重新覆盖安装
repolist  [[all|enabled|disabled]]       Display the configured software repositories  显示yum源,默认显示可用的
resolvedep     Determine which package provides the given dependency
search         Search package details for the given string  以字符串形式匹配搜索rpm包名及summary信息
shell          Run an interactive yum shell
update         Update a package or packages on your system  不加参数更新所有
update-minimal Works like update, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account  同update
version        Display a version for the machine and/or available repos. 查看yum事务历史 


yumdownloader 只下载包,不进行安装
yum命令选项
--nogpgcheck 禁止进行gpg check -y 自动yes -q 静默 --disablerepo= 禁用指定repo --enablerepo= 临时启用指定repo --noplugins 禁用所有插件

yum repo配置文件可用变量
$realease    当前os发行主版本号
$arch        平台
$basearch    基础平台
$YUM0-$YUM9

 

搭建yum仓库

创建yum仓库目录
  [root@node85 ~]# mkdir -p /app/yum/centos6.7/x86_64
  [root@node85 ~]# cd /app/yum/centos6.7/x86_64

安装createrepo软件
  [root@node85 x86_64]# yum install   createrrepo -y


初始化repodata索引文件
  [root@node85 ~]# createrepo -pdo /app/yum/centos6.7/x86_64/ /app/yum/centos6.7/x86_64/ 
  Saving Primary metadata
  Saving file lists metadata
  Saving other metadata
  Generating sqlite DBs
  Sqlite DBs complete

  [root@node85 ~]# tree /app/yum/centos6.7/x86_64/
  /app/yum/centos6.7/x86_64/
`-- repodata
    |-- 401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
    |-- 6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
    |-- 77a287c136f4ff47df506229b9ba67d57273aa525f06ddf41a3fef39908d61a7-other.sqlite.bz2
    |-- 8596812757300b1d87f2682aff7d323fdeb5dd8ee28c11009e5980cb5cd4be14-primary.sqlite.bz2
    |-- dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
    |-- f8606d9f21d61a8bf405af7144e16f6d7cb1202becb78ba5fea7d0f1cd06a0b2-filelists.sqlite.bz2
    `-- repomd.xml
1 directory, 7 files

使用python的http模块启http server(也可以通过nginx,apache,NFS等方式)
  [root@node85 x86_64]# python -m SimpleHTTPServer 80 & >/dev/null &

添加rpm包
  root@node85 x86_64]# yumdownloader lrzsz pcre-devel php
  [root@node85 x86_64]# ls
  lrzsz-0.12.20-27.1.el6.x86_64.rpm  pcre-devel-7.8-7.el6.x86_64.rpm  repodata
  pcre-devel-7.8-7.el6.i686.rpm      php-5.3.3-49.el6.x86_64.rpm
更新yum仓库   [root@node85 x86_64]# createrepo
--update /app/yum/centos6.7/x86_64/   Spawning worker 0 with 4 pkgs   ........
客户端配置 [root@node86 ~]# cat /etc/yum.repos.d/gtms.repo [gtms] name=gtms repo baseurl=http://192.168.0.85 enable=1 gpgcheck=0 查看可用yum源   [root@node86 ~]# yum repolist enabled     Loaded plugins: fastestmirror, security | 766 kB 00:00   repo id repo name status   base CentOS-6 - Base 6,706   extras CentOS-6 - Extras 64   gtms gtms repo 4   updates CentOS-6 - Updates 218 [root@node86 ~]# yum --enablerepo=gtms list all | grep lrzsz lrzsz.x86_64 0.12.20-27.1.el6 base [root@node86 ~]# yum --enablerepo=gtms --disablerepo=base,extras,updates list all | grep lrzsz lrzsz.x86_64 0.12.20-27.1.el6 [root@node86 ~]# yum --enablerepo=gtms --disablerepo=base,extras,updates install lrzsz [root@node86 ~]# yum --enablerepo=gtms list all | grep lrzsz lrzsz.x86_64 0.12.20-27.1.el6 @gtms 配置文件的主要内容有: [Repository_ID] ——仓库的ID,可以取任意名字,只要不和其他的ID冲突即可 name=... ——仓库的描述信息,长短不限,可以有空格,但是必不可少 baseurl=url ——告诉yum客户端,通过哪种路径可以访问到 enabled={1|0} ——是否启用这个仓库,0表示不启用,1表示启用,默认是启用的 gpgcheck=1{1|0} ——是否进行签名合法性检测,0表示不启用,1表示启用,默认启用。 如果选择启用gpg检查,则需要告知其key是什么。 gpgkey=url ——如果启用gpg检测,则需要指定gpgkey的路径,即使导入过gpgkey,这里仍然需要手动为其指定路径,这个路径可以是远程服务器上的,也可以是本地的,只要让本地客户端访问到即可。 cost=1000 ——访问的代价,定义了cost的,且数字较小的,会被优先访问。

 

转载于:https://www.cnblogs.com/gtms/p/6741594.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值