一. yum簡介:html
1.) Yellow Dog Updater Modified:mysql
是一個基於rpm包管理的軟件包管理器。可以在yum源地址處(服務器)下載安裝rpm包,而且自動解決rpm包依賴關係。很好的解決了管理員手動一個一個的去安裝依賴包。nginx
2.) yum常見倉庫:web
bash庫:一般爲系統發行版所提供的程序包。sql
updates庫:比較新的程序包,或者補丁包。apache
extra庫:非發行商之外的程序包,而且是可靠的。centos
epel庫:Fedora社區提供的程序包。緩存
3.) yum客戶端配置及命令:bash
[bash] # repoid。 name= #標識名。 bashurl= #yum倉庫服務器地址以及倉庫路徑。 enabled={0|1} #yum.repo在客戶端是否可運行,默認是啓用的。 gpgcheck={0|1} #是否檢查密鑰。 cachedir= #yum下載的RPM包的緩存目錄。默認是/var/cache/yum。 plugins={0|1} #是否容許使用插件,默認是不容許的。 特殊$符: $releasever #變量定義了發行版本。 $basearch #變量定義自動識別系統架構。 yum客戶端經常使用命令: # yum repolist #列出全部可用repo。 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile CentOS | 2.9 kB 00:00 repo id repo name status CentOS CentOS6.5 x86_64 yum.repo 3,995 repolist: 3,995 #yum list {all|installed|available} #列出全部rpm包 。 # yum list httpd #顯示httpd包的信息。 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages httpd.x86_64 2.2.15-29.el6.centos @anaconda-CentOS-201311291202.x86_64/6.5 # yum info httpd #包的描述信息。 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages Name : httpd Arch : x86_64 Version : 2.2.15 Release : 29.el6.centos Size : 2.9 M Repo : installed From repo : anaconda-CentOS-201311291202.x86_64 Summary : Apache HTTP Server URL : http://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server. # yum grouplist #列出全部的包組信息。 Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Group Process Loading mirror speeds from cached hostfile CentOS | 2.9 kB 00:00 CentOS6 | 3.2 kB 00:00 CentOS6/primary_db | 3.2 MB 00:00 base | 2.9 kB 00:00 sup | 2.9 kB 00:00 CentOS6/group_gz | 220 kB 00:00 Installed Groups: Additional Development Base Console internet tools Desktop Desktop Platform ... 註釋:跟開發相關的包組:{ Development Tools erver Plaform Development Desktop Plaform Development } 其餘的就再也不一一演示。 yum clean {all|packages} #清理緩存。 yum install package_name #安裝程序包。 yum reinstall package_name #從新安裝。 yum uodate package_name #升級,能夠指定版本號升級。 yum downgrade package_name #降級到某個版本(可指定版本號)。 yum remove|erase package_name #卸載。 yum whatprovides #查詢某文件是由那個包安裝生成的。 yum groupinstall group_name #安裝包組。 yum groupremove group_name #卸載包組。 yum check-uodate #檢查可用的升級包。
二.構建yum服務器。服務器
yum服務器端:
有 nfs, ftp, http 這裏就用http了。
1.)環境CentOS6.5 x86_64
nginx-1.4.7
2.)先使用光盤yum源安裝依賴包:
#yum groupinstall "Development Tools" #yum groupinstall "Server Plaform Development" #yum install pcre
3.安裝nginx,作比較簡單的安裝。
#tar -zxf nginx-1.4.7.tar.gz -C /usr/local/ #cd /usr/local/nginx-1.4.7 #./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf && make && make install
4.)啓動nginx,並檢查進程。瀏覽nginx測試頁面。
#/usr/local/nginx/sbin/nginx #ps -ef | grep nginx
5.)把光盤裏面的軟件拷貝到/usr/local/nginx/html/CentOS6.5_X84_64/ 下。
#yum install createrepo
6.)至此,光盤yum就不會在用了。執行createrpo須要一小段時間。
#createrepo /usr/local/nginx/html/CentOS6.5_X84_64/
7.)好了以後,就能夠修改yum源了。
[CentOS] name=CentOS6.5 x86_64 yum.repo baseurl=http://172.16.249.249/CentOS6.5_x86_64/ gpgcheck=0 enabled=1
8.)這時候在nginx地址裏面輸入172.16.x.x/CentOS6.5_x86_64/是看不到yum索引頁面的。
須要修改下配置文件,開啓索引。
server{ ... ... location /CentOS6.5_x86_64/{ autoindex on; } }
9.)這時候重啓一下nginx就能夠看到了。點擊個軟件包也能夠提供下載。
10.)也能夠使用yum安裝軟件包了。
# yum install mysql Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mysql.x86_64 0:5.1.71-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================== Package Arch Version Repository Size ====================================================================================== Installing: mysql x86_64 5.1.71-1.el6 CentOS 893 k Transaction Summary
總結:
配置客戶端repo文件時,注意單詞的正確性。
軟件包若是是光盤自帶的,能夠不用校驗密鑰。
若是是第三方下載的軟件包,下載到本地校驗後在使用yum安裝。
第三方軟件包,下載到本地後能夠使用yun install /path/package_name安裝,若是須要依賴包,會根據原有的yum源自動檢測安裝。