Total download size: 828 k Installed size: 2.8 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. ** Found 1 pre-existing rpmdb problem(s), "yum check" output follows: gnome-user-share-2.28.2-3.el6.i686 has missing requires of httpd >= ("0", "2.2.0", None) Installing : httpd-2.2.15-29.el6.centos.i686 1/1 Verifying : httpd-2.2.15-29.el6.centos.i686 1/1
Installed: httpd.i686 0:2.2.15-29.el6.centos Complete! 重新安装: yum reinstall package_name 8、升级 yum check-update: 检查可用的升级包 yum update package_name 升级,当不指定版本时,默认升级到最新版本 yum downgrade package_name 降价到指定版本 9、卸载(卸载时为解决该包安装的依赖关系而安装的包也会一同卸载) yum remove|erase package_name {-y} -y:自动回答为yes,执行过程中无需等待用户再次输入 10、查询某文件是由哪个包安装生成的 yum whatprovides|provides /path/to/somefile [root@CentOS6 yum.repos.d]# yum provides /usr/bin/zip #查询出zip文件是由那个包安装生成; Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile zip-3.0-1.el6.i686 : A file compression and packaging utility compatible with PKZIP Repo : c6-cd Matched from: Filename : /usr/bin/zip zip-3.0-1.el6.i686 : A file compression and packaging utility compatible with PKZIP Repo : installed Matched from: Other : Provides-match: /usr/bin/zip 11、安装包组 yum groupinstall "GROUP NAME" 12、卸载包组 yum groupremove "GROUP NAME" 【自建yum仓库】 下面通过自建一个http服务器的yum仓库为例说明: 第一步:安装httpd程序并启动服务; yum -y install httpd service httpd start chkconfig httpd on 12345678910111213141516171819202122232425262728293031323334353637 [root@CentOS6 yum.repos.d]# yum -y install httpd Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.i686 0:2.2.15-29.el6.centos will be installed --> Finished Dependency Resolution
Dependencies Resolved
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd i686 2.2.15-29.el6.centos c6-cd 828 k
Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 828 k Installed size: 2.8 M Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : httpd-2.2.15-29.el6.centos.i686 1/1 Verifying : httpd-2.2.15-29.el6.centos.i686 1/1 Installed: httpd.i686 0:2.2.15-29.el6.centos Complete! [root@CentOS6 yum.repos.d]# service httpd start Starting httpd: [ OK ] [root@CentOS6 yum.repos.d]# chkconfig httpd on [root@CentOS6 yum.repos.d]# chkconfig |grep httpd httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off 第二步:创建子目录,存放某相关的所有rpm包,httpd的文档根目录为/var/www/html;为仓库生成元数据文件(使用createrepo),以使能够作为仓库使用。 [root@CentOS6 html]# cd /var/www/html [root@CentOS6 html]# mkdir test #创建test目录用来测试; [root@CentOS6 html]# cp /mnt/cd/Packages/zsh-4.3.10-7.el6.i686.rpm ./test #复制zsh这个安装包到test目录; [root@CentOS6 Packages]# yum install createrepo #安装createrepo,如提前已安装则不用再装; Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-18.el6 will be installed --> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-18.el6.noarch --> Running transaction check ---> Package python-deltarpm.i686 0:3.5-0.5.20090913git.el6 will be installed --> Processing Dependency: deltarpm = 3.5-0.5.20090913git.el6 for package: python-deltarpm-3.5-0.5.20090913git.el6.i686 --> Running transaction check ---> Package deltarpm.i686 0:3.5-0.5.20090913git.el6 will be installed --> Finished Dependency Resolution
Dependencies Resolved
====================================================================== Package Arch Version Repository Size ====================================================================== Installing: createrepo noarch 0.9.9-18.el6 c6-cd 94 k Installing for dependencies: deltarpm i686 3.5-0.5.20090913git.el6 c6-cd 73 k python-deltarpm i686 3.5-0.5.20090913git.el6 c6-cd 27 k Transaction Summary ========================================================================== Install 3 Package(s)
Total download size: 195 k Installed size: 522 k Is this ok [y/N]: y Downloading Packages: ----------------------------------------------------------------------------------------- Total 3.3 MB/s | 195 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : deltarpm-3.5-0.5.20090913git.el6.i686 1/3 Installing : python-deltarpm-3.5-0.5.20090913git.el6.i686 2/3 Installing : createrepo-0.9.9-18.el6.noarch 3/3 Verifying : createrepo-0.9.9-18.el6.noarch 1/3 Verifying : python-deltarpm-3.5-0.5.20090913git.el6.i686 2/3 Verifying : deltarpm-3.5-0.5.20090913git.el6.i686 3/3 Installed: createrepo.noarch 0:0.9.9-18.el6 Dependency Installed: deltarpm.i686 0:3.5-0.5.20090913git.el6 python-deltarpm.i686 0:3.5-0.5.20090913git.el6 Complete! #createrepo安装完成 [root@CentOS6 Packages]# createrepo /var/www/html/test/ #创建元数据文件; Spawning worker 0 with 1 pkgs Workers Finished Gathering worker results
Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@CentOS6 Packages]# ls /var/www/html/test/ repodata zsh-4.3.10-7.el6.i686.rpm #repodata即为刚刚创建出来存放元数据文件的目录; [root@CentOS6 test]# ls /var/www/html/test/repodata/ #查看repodata下的元数据文件; 105b962a2624ebddd589ec03c1e4fdcd7a3511ea1e47fd80eeda364b41d48cdd-primary.sqlite.bz2 7762e79a7341d1b6a929e893fd732302dd27499742abf4549130601465760426-filelists.xml.gz 78f72a947bd046641a5ea0574872212cfe829f1525ff74f1d13f4da3c4d73cde-filelists.sqlite.bz2 7e8d7b7938dbd28a823ebe27420f3c2d088f9a1933f37319e925295e24417009-other.sqlite.bz2 885867e505b55bc3f09fb4eec3bc7cf8a5352cce29c307e7b37afaa38e3d33cc-primary.xml.gz e0eb2191ed5de3b3975bbb005a00e07a044d5724b87373d4a6cdf399ff99bf3f-other.xml.gz #通过以上几步一个简单的yum仓库就搭建好了! 第三步:配置yum客户端使用此仓库即可; [root@CentOS6 yum.repos.d]# vim test.repo #编辑指向yum库的repo文件 [c6-test] name=CentOS-$releasever - test baseurl=file:///var/www/html/test gpgcheck=0 #此处只为实验,没有复制密钥,到yum库中,所以不启用校验; enabled=1 #启用 [root@CentOS6 yum.repos.d]# yum clean all #清除缓存; Loaded plugins: fastestmirror, refresh-packagekit, security Cleaning repos: c6-test Cleaning up Everything Cleaning up list of fastest mirrors [root@CentOS6 yum.repos.d]# yum repolist #显示可用的repo; Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors c6-test | 2.9 kB 00:00 ... c6-test/primary_db | 3.2 kB 00:00 ... repo id repo name status c6-test CentOS-6 - test 1 repolist: 1 [root@CentOS6 yum.repos.d]# yum -y install zsh #安装zsh; Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package zsh.i686 0:4.3.10-7.el6 will be installed --> Finished Dependency Resolution
Dependencies Resolved
========================================================================== Package Arch Version Repository Size ========================================================================== Installing: zsh i686 4.3.10-7.el6 c6-test 2.1 M