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.www58058.com/22789