centos6.6程序包管理
二进制应用程序的组成部分:
二进制文件,库文件,配置文件和帮助文件
程序包管理器:rpm rpm包管理器的前端工具:yum 程序包之间存在依赖关系
rpm的命名方式:
name_VERSION_release.arch.rpm VERSION: major.minor.release 对应主版本号.次版本号.修订号 release.arch: release: 包的发行号和对应的操作系统 arch表示适用的平台 X86: i386 i486 i586 i686 X86_64: x86 x86_64 amd64 noarch:表示此包可以安装到所有的平台上
例如:zsh-5.0.2-7.el7.x86_64.rpm
zsh:软件名称 5.0.2:软件版本 7.el7:软件包发行商版本,7表示发行号,el7表示RHEL7 x86_64:适用的平台
两个命令:ldd 和 ldconfig
程序包管理器rpm:
安装、升级、查询、卸载和校验
安装 -i :
rpm {-i|--install} [install-options] PACKAGE_FILE ... -v或-vv:显示安装过程详情,-vv显示更详细的安装信息 -h:以#显示程序包安装的进度,每个#表示2%的进度
安装和升级选项【INSTALL AND UPGRADE OPTIONS】:
--test Do not install the package, simply check for and report potential conflicts.测试安装,但不真正的执行安装 --nodeps Don’t do a dependency check before installing or upgrading a package.忽略依赖关系,直接进行安装 --replacepkgs Install the packages even if some of them are already installed on this system.替换安装,重新安装 --ignoreos Allow installation or upgrading even if the operating systems of the binary package and host don’t match. 忽略操作系统是否匹配 --nosignature Don’t verify package or header signatures when reading.不检查包签名(即不检查来源) --oldpackage Allow an upgrade to replace a newer package with an older one.降级 --noscripts 不执行程序包脚本 --nopre 不执行安装前脚本 --nopost不执行安装后脚本 --nopreun 不执行卸载前脚本 --nopostun不执行卸载后脚本
升级-U -F:
rpm {-U|--upgrade} [install-options] PACKAGE_FILE ... 如果已安装旧版程序包则升级,不存在则直接安装 rpm {-F|--freshen} [install-options] PACKAGE_FILE ... 如果已存在旧版程序包则升级,不存在则不安装
实例:
没有依赖的应用可以直接安装成功:
[root@scm-dzm Packages]# pwd /media/CentOS_6.6_Final/Packages 虚拟机光盘下Packages [root@scm-dzm Packages]# rpm -ivh tree-1.5.3-2.el6.i686.rpm Preparing... ########################################### [100%] 1:tree ########################################### [100%]
有依赖的包需要先安装依赖的包:
[root@scm-dzm Packages]# rpm -ivh tomcat6-6.0.24-80.el6.i686.rpm error: Failed dependencies: jakarta-commons-collections is needed by tomcat6-0:6.0.24-80.el6.i686 jakarta-commons-daemon is needed by tomcat6-0:6.0.24-80.el6.i686 jakarta-commons-dbcp is needed by tomcat6-0:6.0.24-80.el6.i686 jakarta-commons-logging is needed by tomcat6-0:6.0.24-80.el6.i686 jakarta-commons-pool is needed by tomcat6-0:6.0.24-80.el6.i686 log4j is needed by tomcat6-0:6.0.24-80.el6.i686 mx4j is needed by tomcat6-0:6.0.24-80.el6.i686 tomcat6-lib = 0:6.0.24-80.el6 is needed by tomcat6-0:6.0.24-80.el6.i686
查询-q:
rpm {-q|–query} [select-options] [query-options]
查询选项[select-options]:
-a, –all
Query all installed packages. 查询所有已安装的包
-p, –package PACKAGE_FILE
Query an (uninstalled) package PACKAGE_FILE. 查询未安装包的信息,与{i|l|c|d|R}结合使用
-f, –file FILE
Query package owning FILE.
–whatprovides CAPABILITY
Query all packages that provide the CAPABILITY capability.查询CAPABILITY由哪个包提供或生成
–whatrequires CAPABILITY
Query all packages that require CAPABILITY for proper functioning.查询CAPABILITY被谁所依赖
[query-options]
–changelog
Display change information for the package.查询rpm包的修改记录
-c, –configfiles
List only configuration files (implies -l).查询包的配置文件
-l, –list
List files in package.
-c, –configfiles
List only configuration files (implies -l).
-d, –docfiles
List only documentation files (implies -l).
–scripts
List the package specific scriptlet(s) that are used as part of the installation and unin-
stallation processes.
-R, –requires
List capabilities on which this package depends.
–provides
List capabilities this package provides.
常用方式:
安装
rpm -ivh PACKAGE_FILE
升级
rpm -Fvh PACKAGE_FILE
rpm -Uvh PACKAGE_FILE
查询
rpm -qa 查询所有已安装的包
rpm -qa |grep tree 查询某一个已安装的包,其结果为tree-1.5.3-2.el6.i686
rpm -ql vim-common-7.2.411-1.8.el6.i686
rpm -qc vim-common-7.2.411-1.8.el6.i686
rpm -qd vim-common-7.2.411-1.8.el6.i686
rpm -q –scripts vim-common-7.2.411-1.8.el6.i686
rpm -qR tree-1.5.3-2.el6.i686
rpm -qpi tomcat6-6.0.24-80.el6.i686.rpm
例子:
[root@scm-dzm Packages]# rpm -qc vim-minimal
/etc/virc
卸载:
rpm {-e|–erase} [–allmatches] [–nodeps] [–noscripts] [–notriggers] [–test] PACKAGE_NAME …
rpm -evv --test tree 测试卸载 rpm -evv tree 卸载tree rpm -evv --nodeps tree 忽略依赖卸载tree
检验:
rpm {-V|–verify} [select-options] [verify-options]
rpm --import RPM-GPG-KEY-CentOS-7 如果rpm的数据库文件损坏,就需要做如下操作: rpm --initdb初始化 rpm --rebuilddb重建
程序包管理之前端工具yum
yum是c/s架构的
配置yum:
/etc/yum.conf 各个yum仓库的公共配置 /etc/yum.repos.d/*.repo 为仓库的指向提供配置
先安装工具:yum install createrepo -y
创建一个本地yum仓库,我是拷贝iso下的packages文件夹到本地yumrepo下:
1、目录yumrepo下Packages,所有包都放于Packages下: [root@scm-dzm yumrepo]# ls Packages [root@scm-dzm yumrepo]# createrepo Packages/ 在Packages下生成元数据repodata 2、 配置 vi /etc/yum.repos.d/localyum.repo [mybase] name=local repo baseurl=file:///home/yumrepo/Packages/ gpgcheck=0 3、 查看 yum repolist Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn mybase | 2.9 kB 00:00 ... mybase/primary_db | 2.8 MB 00:00 ... repo id repo name status base CentOS-6 - Base 5,062 extras CentOS-6 - Extras 39 mybase local repo 3,271 updates CentOS-6 - Updates 102 repolist: 8,474
yum命令的使用:
显示仓库列表
yum repolist
显示程序包
yum list [all] 默认是all yum list installed yun list update yum list extras 已安装但不在yum仓库的软件包
安装程序包,yum可以自动解决依赖关系
yum install PACKAGES [PACKAGES1] [PACKAGES2] [...] 例如:yum install tree
升级程序包
yum update PACKAGES [PACKAGES1] [PACKAGES2] [...] 例如:yum update firefox -y
检查升级
yum check-update
卸载程序包
yum remove | erase [PACKAGES1] [PACKAGES2] […]
检查程序包的信息
yum info [PACKAGES1]
[root@scm-dzm ~]# yum info firefox Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn Installed Packages Name : firefox Arch : i686 Version : 31.1.0 Release : 5.el6.centos Size : 108 M Repo : installed From repo : anaconda-CentOS-201410241409.i386 Summary : Mozilla Firefox Web browser URL : http://www.mozilla.org/projects/firefox/ License : MPLv1.1 or GPLv2+ or LGPLv2+ Description : Mozilla Firefox is an open-source web browser, designed for standards : compliance, performance and portability. Available Packages Name : firefox Arch : i686 Version : 45.2.0 Release : 1.el6.centos Size : 75 M Repo : updates Summary : Mozilla Firefox Web browser URL : http://www.mozilla.org/projects/firefox/ License : MPLv1.1 or GPLv2+ or LGPLv2+ Description : Mozilla Firefox is an open-source web browser, designed for standards : compliance, performance and portability.
查看指定特性由哪个程序包提供
yum provides tree 或者yum provides /usr/bin/tree Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn tree-1.5.3-3.el6.i686 : File system tree viewer Repo : base Matched from: Filename : /usr/bin/tree tree-1.5.3-2.el6.i686 : File system tree viewer Repo : mybase Matched from: Filename : /usr/bin/tree tree-1.5.3-2.el6.i686 : File system tree viewer Repo : installed Matched from: Other : Provides-match: /usr/bin/tree
清理本地缓存
yum clear [packages|matedate|expire-cache|rpmdb|plugins]
例如:
[root@scm-dzm ~]# yum clean all Loaded plugins: fastestmirror, refresh-packagekit, security Cleaning repos: base extras mybase updates Cleaning up Everything Cleaning up list of fastest mirrors
创建缓存|构建缓存
yum makecache
例如:
[root@scm-dzm ~]# yum makecache Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors * base: mirrors.neusoft.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn base | 3.7 kB 00:00 base/group_gz | 220 kB 00:00 base/filelists_db | 5.3 MB 00:08 base/primary_db | 3.7 MB 00:06 base/other_db | 1.5 MB 00:01 ETA base/other_db | 2.1 MB 00:07 extras | 3.3 kB 00:00 extras/filelists_db | 35 kB 00:00 extras/prestodelta | 78 B 00:00 extras/primary_db | 30 kB 00:00 extras/other_db | 46 kB 00:00 mybase | 2.9 kB 00:00 ... mybase/filelists_db | 3.7 MB 00:01 ... mybase/primary_db | 2.8 MB 00:01 ... mybase/other_db | 1.5 MB 00:00 ... updates | 3.4 kB 00:00 updates/filelists_db | 507 kB 00:00 updates/prestodelta | 36 kB 00:00 updates/primary_db | 707 kB 00:00 updates/other_db | 7.5 MB 00:15 Metadata Cache Created
搜索:指定关键字搜索包名以及summary
yum search string
例如
[root@scm-dzm ~]# yum search fire Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.neusoft.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn ================================================ N/S Matched: fire ================================================ firefox.i686 : Mozilla Firefox Web browser system-config-firewall.noarch : A graphical interface for basic firewall setup system-config-firewall-base.noarch : system-config-firewall base components and command line tool system-config-firewall-tui.noarch : A text interface for basic firewall setup Name and summary matches only, use "search all" for everything.
重新安装
yum reinstall [PACKAGES1] [PACKAGES2] […]
降级安装
yum downgrade [PACKAGES1] [PACKAGES2] […]
查看yum事务历史
yum history
例如:
[root@scm-dzm ~]# yum history info Loaded plugins: fastestmirror, refresh-packagekit, security Transaction ID : 7 Begin time : Fri Jun 24 23:03:25 2016 Begin rpmdb : 1117:bdc4d0fbd9dce392894d7015690d4043356bb307 End time : 23:03:37 2016 (12 seconds) End rpmdb : 1117:bdc4d0fbd9dce392894d7015690d4043356bb307 User : root <root> Return-Code : Success Command Line : reinstall samba Transaction performed with: Installed rpm-4.8.0-37.el6.i686 @anaconda-CentOS-201410241409.i386/6.6 Installed yum-3.2.29-60.el6.centos.noarch @anaconda-CentOS-201410241409.i386/6.6 Installed yum-plugin-fastestmirror-1.1.30-30.el6.noarch @anaconda-CentOS-201410241409.i386/6.6 Packages Altered: Reinstall samba-3.6.23-35.el6_8.i686 @updates history info
本地安装
yum localinstall rpmfile
包组管理
yum groupinstall group1 [group2] […]
yum groupupdate group1 [group2] […]
yum grouplist [hidden] [groupwildcard] […]
yum groupremove group1 [group2] […]
yum groupinfo group1 […]
yum的选项:
常用的-y,自动选择yes --nogpgcheck禁止进行gpgcheck -q:静默模式--quiet --disablerepo=repoidglob 临时禁用仓库 --enablerepo=repoidglob 临时启用仓库 --noplugins禁用所有插件
手动安装软件包:
1)configure 检测编译环境 2)make 进行编译 3)make install 编译安装
实例:
下载httpd源码地址 http://httpd.apache.org/download.cgi tar -zxf httpd-2.2.31.tar.gz cd httpd-2.2.31/ ./configure --help ./configure --prefix=/usr/local/apache2 make make install
原创文章,作者:Net20_天意,如若转载,请注明出处:http://www.178linux.com/22789