Using nginx-to build a yum warehouse

Source: Internet
Author: User
Tags rsync

Using nginx-to build a yum warehouse

Introduction:


Yum is primarily used to automatically install and upgrade RPM packages, which automatically find and resolve dependencies between RPM packets. To successfully install the Update software or system using the Yum tool, you need to have a repository (software repository) with a variety of RPM packages, which we are used to as a Yum source. There are a lot of Yum sources on the network, but due to the network environment, the software installation takes too long or even fails. The slow progress bar is unbearable, especially when there are a large number of server packages that need to be installed. Therefore, when we optimize the system, we will replace the domestic source.



In comparison, the biggest advantage of the local Yum source server is the fast network connectivity and stability of the LAN. With the Yum source server in the LAN, even if the Internet connection is interrupted, it will not affect the software installation and upgrade of other Yum clients, the most important thing is to put the company's well-established binary package into its own private warehouse,


1. Create a Yum repository directory

Mkdir-p/application/yum/centos6.6/x86_64/cd/application/yum/centos6.6/x86_64/rz # Upload RPM package to this directory (/application/yum/ centos6.6/x86_64/), you can also include folders under this directory

2. Installing the Createrepo Software

Yum-y Install Createrepo

3. Initializing the Repodata index file

For the first time initialization, you must specify the index location createrepo-pdo/application/yum/centos6.6/x86_64//application/yum/centos6.6/x86_64/

4. Provision of Yum Services


# Web services can be provided with Apache or nginx, but Python HTTP modules are easier to use for intranet environments

cd/application/yum/centos6.6/x86_64/

Python-m simplehttpserver &>/dev/null &

You can enter a native IP view via your browser.


I am personally accustomed to using Nginx:

Repo.conf #repo confserver {Listen 8080;server_name xx.xx.xxx.x;access_log/var/log/nginx/repo.log;error_log/var/log        /nginx/repoerr.log;location/{Root/application/yum/centos6.6/x86_64/;autoindex on; }}


5. Add a new RPM package (using your own RPM package)


# only download software does not install

RZ smm-tengine-2.1.2-1.x86_64.rpm

Createrepo--update/application/yum/centos6.6/x86_64/

# every RPM package will be updated.

Usually yum does not remove the installation package when installing the software


# cat/etc/yum.conf

Keepcache=1 Open Cache

# Install package storage Directory

cachedir=/var/cache/yum/$basearch/$releasever

#/var/cache/yum/x86_64/6/base/packages


6. Client Configuration

# Cd/etc/yum.repos.d[[email protected] yum.repos.d]# VI oldboy.repo[oldboy]name=serverbaseurl=http:// 10.0.0.5:8080enable=1gpgcheck=0
[email protected] ~]# Yum--enablerepo=oldboy--disablerepo=base,extras,updates,epel list


# Specify to use the Oldboy library

Above is the temporary use of the intranet Yum source, want to permanently and simply use the Yum-y install LRZSZ command, you need to modify the configuration file will be the default repo file closed.

[[email protected] ~]# cd/etc/yum.repos.d/[[email protected] yum.repos.d]# vim centos-base.repo# at each starting source plus # Enabled=0 #改为1就启用, it is also enabled without this parameter. [Base]............enabled=0[updates]............enabled=0[extras]............enabled=0

# There are other open warehouses to use this method to close.


or temporary processing methods:

We can control whether the configuration file takes effect through the enable value of the repo file, but this method is troublesome if the package in the private Yum repository conflicts with the base package, and if you want to access the public Yum source, you also need to modify the configuration file, rebuild the cache, and so on. We can do it another way, is to specify the enabled source and the closed source when using Yum:

Yum--enablerepo=oldboy--disablerepo=base,extras,updates,epel List


This can also be the case at installation:

Yum--enablerepo=oldbot--disablerepo=base,extras,updates,epel Install nginx_erma.x86_64


#使用时, we'd better change the private source to enable=0 and the other source to 1 so that the direct Yum doesn't have a problem.


7. Image Yum Source (out of the question)


The above is just the RPM package you made, put into the Yum source. But there is a kind of business needs, said more specific, usually students in class Yum installation software is downloaded from the public network, occupy the bandwidth, so in the school to build an intranet Yum server, but also consider the students go home also to use yum install software, if the Yum software database file Repodata is not the same, There will be problems. So the solution I think of is to use the repodata of the public network Yum source directly.


Image synchronization public network Yum source

The upstream Yum source must support the Rsync protocol or it cannot be synchronized using rsync.

http://mirrors.ustc.edu.cn/status/

Official CentOS Standard Source: rsync://mirrors.ustc.edu.cn/centos/

Epel Source: rsync://mirrors.ustc.edu.cn/epel/

Synchronization command:

# using Rsync to synchronize the Yum source, in order to save bandwidth, disk and download time, I only synchronized the CentOS6 RPM package, so that all RPM packages only occupy 21G, all synchronization needs about 300G.

# sync the base source, tips, we install the system's disc image contains some RPM packages, about 3G, these do not have to re-download.

/usr/bin/rsync-av rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64//data/yum_data/centos/6/os/x86_64/

/usr/bin/rsync-av rsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64//data/yum_data/centos/6/extras/x86_64/

/usr/bin/rsync-av rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64//data/yum_data/centos/6/updates/x86_64/

# Epel Source

/usr/bin/rsync-av--exclude=debug rsync://mirrors.ustc.edu.cn/epel/6/x86_64//data/yum_data/epel/6/x86_64/

Students ' use of the intranet Yum source method

# can build a self-intranet DNS, if not, you can use the hosts to resolve.

Echo ' 192.168.0.200 mirrors.aliyun.com ' >>/etc/hosts

Results show

[Email protected] data]# Du-sh yum_data

21G Yum_data

[Email protected] data]# tree-l 3 yum_data/

yum_data/

├──centos

│├──6

││├──extras

││├──os

││└──updates

│└──rpm-gpg-key-centos-6

├──epel

│└──6

│└──x86_64


This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1878592

Using nginx-to build a yum warehouse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.