一. 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源自动检测安装。