First, preface
The configuration of Yum was described earlier (please visit http://windchasereric.blog.51cto.com/5419433/1676777 for details). But there is no problem, although we have the warehouse point to an available warehouse server, but with the continuous upgrade and revision of Linux, we still need to constantly modify the warehouse configuration files, if only one is OK, if we have more than a Linux system, then the change in the workload will be very large, So how do we make sure our warehouses always point to the newest warehouses? This is the charm of the Yum function.
Second, the Yum function introduction
In RPM introduction (detailed please visit http://windchasereric.blog.51cto.com/5419433/1676324) We introduce 2 domestic more famous RPM package download path (mirrors.163.com and mirrors.sohu.com), which will have a special folder path, which is important to understand the Yum function, the following with mirrors.163.com, CentOS6 system as an example to introduce
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150723/1437639702118675.png "title= "1437639702118675.png" alt= "Warehouse 6.png" width= "576" height= "338" style= "WIDTH:576PX;HEIGHT:338PX;"/>650) this.width =650, "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437713386178294.png "title=" 1437713386178294.png "alt=" 4.png "width=" 780 "height=" 336 "style=" width:780px;height:336px; "/>
Let's look at the files in "Centos-base.repo" in the Yum Repository
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437713011368304.png "title= "1437713011368304.png" alt= "5.png"/>
Where the red frame is the Yum function.
$releaserver: Represents the version of the system, for Yum refers to the Redhat-releaser version, which points to the major version number of the release, and replaces the primary version number, such as Redhat 6.5, with 6
$basearch: The basic architecture of the system, if it is i686,i586 and other basic architecture is i386
$arch: System Architecture
#比如我现在的系统是CentOS6.5, the system architecture is x86_64, then #baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/will be automatically replaced with BaseURL =http://mirrors.163.com/centos/6/os/x86_64/
Third, how to build the Yum Warehouse
3.1. Introduction:
Although the system comes with a warehouse already very common, as long as connected to the Internet, we can easily have access to the Internet, the Yum warehouse. But if it is in the enterprise intranet, the enterprise does not allow access to the Internet, or if the enterprise server is numerous, if you want to get the Yum warehouse from the Internet, it will be very bandwidth-intensive. Based on this situation, we need to create a Yum repository ourselves within the enterprise.
3.2, self-built warehouse need to use command introduction
Createrepo (Create Repo): the creation of warehouses, in the self-built warehouse, using the command Createrepo will automatically help us generate repodata files as the repository of software, There are four necessary documents in its catalogue: filelists.xml.gz,other.xml.gz,primary.xml.gz and Repomd.xml, the most important of which is the Repomd.xml file. There are usually three reasons for errors that cannot be found for Repodata directories or files: One is the path problem, the other is the Repodate directory is not generated, and the third is the *.repo configuration file conflict (this needs to be deliberately noted).
Tip The Createrepo command is not installed by default, so we need to install it in advance, Createrepo's installation package is "createrepo-0.9.9-17.el6.noarch.rpm", and you can use RPM or yum to install the package first.
#安装方法: #yum-y install Createrepo or RPM-IVH createrepo-0.9.9-17.el6.noarch.rpm (the path must be written to)
3.3, self-built Yum warehouse there are 2 ways
1). Create a Yum repository based on the off-disk image
2), according to the service self-built server (FTP, HTTP, NFS) to provide the Yum warehouse
3.4. Create a Yum repository based on the off-disk image
3.4.1, mount the disc to the/MNT directory first
Mount/dev/cdrom/mnt
3.4.2, configure the Yum warehouse file (detailed method please visit http://windchasereric.blog.51cto.com/5419433/1676777)
[[email protected] yum.repos.d]# vim /etc/ yum.repos.d/local-media.repo #如果local-media.repo does not exist, please create [meida-repo]name=this is local media repobaseurl= # Point to Disc mirroring path enabled=1 #是否启动该仓库gpgcheck =0 #是否检查包完整性 [[email protected] yum.repos.d]# yum clean all #清除所有的包缓存和元数据 [[email protected] yum.repos.d]# yum list #列出所有的仓库和程序包
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150723/1437661055115715.png "title= "1437661055115715.png" alt= "Warehouse 1.png"/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150723/1437661349486571.png "title= "1437661349486571.png" alt= "Warehouse 2.png"/>
3.5, according to the service self-built to provide the server Yum warehouse (here, for example, HTTP service)
3.5.1, first install the HTTP service
Yum-y install httpd or RPM-IVH httpd
3.5.2, shutting down the Linux firewall and SELinux
#防火墙和Selinux可能会影响用户访问HTTP, so you need to disable it here [[Email protected] yum.repos.d]# service iptables stop #关闭防火墙服务 [[email protected] ~]# chkconfig iptables off #关闭防火墙自动启动 [[email protected] yum.repos.d]# getenforce # View SELinux status enforcing means enable permissive to not enable enforcing[[email protected] yum.repos.d]# setenforce 0 #关闭Selinux 0 indicates that closing the 1 means opening [[email protected] yum.repos.d]# getenforce Permissive [[email protected] ~]# vim /etc/selinux/config # Turn off SELinux boot, edit the confg file, and change the SELinux field to the following settings selinux=disabled
3.5.3, start httpd service and power on auto Service
[[Email protected] yum.repos.d]# service httpd start #开启httpd服务 [[email protected] yum.repos.d]# chkconfig on #设 Reset httpd service start automatically [[email protected] ~]# NETSTAT-TUNLP | grep http #查看http服务是否已启用tcp 0 0::: +:::* LISTEN 1532/http D
3.5.4, edit httpd's document directory
#httpd默认的目录文档路径为/var/www/html
[Email protected] html]# Mkdir/var/www/html/rpm-repo #创建仓库路径
[Email protected] rpm-repo]# cp-a/mnt/packages/xcb*/var/www/html/rpm-repo/#拷贝RPM程序包为测试使用
3.5.5, configuring the Yum repository with Createrepo
[Email protected] rpm-repo]# createrepo/var/www/html/rpm-repo/
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437704768355392.png "title= "1437704768355392.png" alt= "Create.png"/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437704843205873.png "title= "1437704843205873.png" alt= "1.png"/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437704954354255.png "title= "1437704954354255.png" alt= "Blob.png"/>
3.5.6, verifying, and viewing the files of the HTTP repository
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437705434389666.png "title= "1437705434389666.png" alt= "2.png"/>
3.5.7, configure, and verify the Yum repository
[Email protected] yum.repos.d]# Vim/etc/yum.repos.d/local.repo #编辑yum仓库文件, let the warehouse path point to the Yum repository for HTTP [http-repo]name=http Yum Repobaseurl=http://192.168.80.150/rpm-repoenabled=1gpgcheck=0[[email protected] ~]# Yum list
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20150724/1437709710341863.png "title= "1437709710341863.png" alt= "3.png"/>
Experiment Done!
Tip: Prior to introducing Yum functions, it is interesting to try to use the Yum function to call the warehouse in this experiment, and the familiar use of the Yum repository will be very helpful for future work.
This article is from the "Crab Learn Linux" blog, please be sure to keep this source http://windchasereric.blog.51cto.com/5419433/1677964
Yum function introduction and self-built Yum repository