yum介绍 yum 具有如下特点:
yum使用流程 CentOS 先将释出的软件放置到 YUM 服务器内,然后分析这些软件的相依属性问题,将软件内的记录资讯写下来 (header)。 然后再将这些资讯分析后记录成软件相关性的清单列表。这些列表数据与软件所在的位置可以称呼为容器 (repository)。 当用户端有软件安装的需求时,用户端主机会主动的向网络上面的 yum 服务器的容器网址下载清单列表, 然后透过清单列表的数据与本机 RPM 数据库已存在的软件数据相比较,就能够一口气安装所有需要的具有相依属性的软件了。 整个流程可以简单的如下图说明:
当用户端有升级、安装的需求时, yum 会向容器要求清单的升级,等到清单升级到本机的 /var/cache/yum 里面后, 等一下升级时就会用这个本机清单与本机的 RPM 数据库进行比较,这样就知道该下载什么软件。接下来 yum 会跑到容器服务器 (yum server) 下载所需要的软件,然后再透过 RPM 的机制开始安装软件啦!这就是整个流程.
[root@yum]# pwd /apps/yum [root@yum]# tree -L 3 . . └── centos └── 6.2_64 ├── addons ├── base ├── centosplus ├── contrib ├── extras └── updates 8 directories, 0 files
创建仓库 CentOS提供了createrepo工具,可以从rpm包来创建yum仓库。 拷贝CentOS ISO镜像,创建仓库 [root@yum]# createrepo centos/6.2_64/base 2762/6295 - gthumb-2.10.11-8.el6.x86_64.rpm 当需要增加RPM包时,拷贝到相应的路径,并使用createrepo更新仓库即可 [root@yum]# pwd /apps/yum/centos/6.2_64/extras [root@server extras]# ll total 92 -rw-r--r-- 1 root root 92328 Dec 13 11:02 rlwrap-0.37-1.el6.x86_64.rpm [root@yum]# createrepo --update . 1/1 - rlwrap-0.37-1.el6.x86_64.rpm Saving Primary metadata Saving file lists metadata Saving other metadata [root@yum]# ll total 96 drwxr-xr-x 2 root root 4096 Apr 1 18:09 repodata -rw-r--r-- 1 root root 92328 Dec 13 11:02 rlwrap-0.37-1.el6.x86_64.rpm 配置http 这里以Apache HTTP作为http服务器,其他Web服务器配置可以自行查询参考手册。 创建连接文件,指向/apps/yum [root@server html]# grep DocumentRoot /etc/httpd/conf/httpd.conf # DocumentRoot: The directory out of which you will serve your DocumentRoot "/var/www/html" # This should be changed to whatever you set DocumentRoot to. # DocumentRoot /www/docs/dummy-host.example.com [root@server html]# pwd /var/www/html [root@server html]# ln -s /apps/yum/ yum [root@server html]# ll total 0 lrwxrwxrwx 1 root root 10 Apr 1 17:39 yum -> /apps/yum/ 开启http服务 [root@yum]# service httpd start Starting httpd:
yum测试 [root@client]# ping yum.egolife.com PING yum.egolife.com (192.168.1.111) 56(84) bytes of data. 64 bytes from yum.egolife.com (192.168.1.111): icmp_seq=1 ttl=64 time=0.041 ms 64 bytes from yum.egolife.com (192.168.1.111): icmp_seq=2 ttl=64 time=0.039 ms 64 bytes from yum.egolife.com (192.168.1.111): icmp_seq=3 ttl=64 time=0.038 ms ^C --- yum.egolife.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2879ms rtt min/avg/max/mdev = 0.038/0.039/0.041/0.005 ms
[root@yum]# vim /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://yum.egolife.com/yum/centos/6.2_64/base gpgcheck=0 enabled=1 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://yum.egolife.com/yum/centos/6.2_64/updates gpgcheck=0 enabled=0 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://yum.egolife.com/yum/centos/6.2_64/extras gpgcheck=0 enabled=1 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=http://yum.egolife.com/yum/centos/6.2_64/centosplus gpgcheck=0 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ baseurl=http://yum.egolife.com/yum/centos/6.2_64/contrib gpgcheck=0 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
在本例中,baseurl为http://yum.egolife.com/yum/centos/6.2_64/repositoryid。
注: [root@server etc]# head /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 [root@server etc]# ll /var/cache/yum/x86_64/6/ total 12 drwxr-xr-x. 3 root root 4096 Apr 1 17:15 base drwxr-xr-x. 3 root root 4096 Apr 1 17:15 extras -rw-r--r-- 1 root root 0 Apr 1 17:15 timedhosts.txt drwxr-xr-x. 3 root root 4096 Jan 7 00:03 updates
3.yum测试 [root@server conf]# yum info yum Loaded plugins: downloadonly, fastestmirror, refresh-packagekit, security Determining fastest mirrors base | 1.3 kB 00:00 extras | 1.3 kB 00:00 Installed Packages Name : yum Arch : noarch Version : 3.2.29 Release : 22.el6.centos Size : 4.5 M Repo : installed From repo : anaconda-CentOS-201112091719.x86_64 Summary : RPM package installer/updater/manager URL : http://yum.baseurl.org/ License : GPLv2+ Description : Yum is a utility that can check for and automatically download and : install updated RPM packages. Dependencies are obtained and downloaded : automatically, prompting the user for permission as necessary.
root@oabak ~]# yum install -y lrzsz Loaded plugins: fastestmirror, refresh-packagekit Loading mirror speeds from cached hostfile Setting up Install Process Resolving Dependencies There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them. The program yum-complete-transaction is found in the yum-utils package. --> Running transaction check ---> Package lrzsz.x86_64 0:0.12.20-27.1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================ Package Arch Version Repository Size ============================================================================================ Installing: lrzsz x86_64 0.12.20-27.1.el6 base 71 k Transaction Summary ============================================================================================ Install 1 Package(s) Total download size: 71 k Installed size: 159 k Downloading Packages: lrzsz-0.12.20-27.1.el6.x86_64.rpm | 71 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : lrzsz-0.12.20-27.1.el6.x86_64 1/1 Installed: lrzsz.x86_64 0:0.12.20-27.1.el6 Complete!转自:http://www.dylanninin.com/blog/2013/04/configure-yum-in-intranet.html 转载请保留固定链接: https://linuxeye.com/Linux/1805.html |