Build a yum server inside your enterprise

Source: Internet
Author: User
Tags percona rsync rpmbuild

If you use your own Yum server, you can increase your daily productivity by not only consuming less bandwidth, faster, but also having a more flexible and convenient custom configuration.

First, the basic concept

1. RPM

Full name is the RPM package Manager. Used to install/uninstall software in the CentOS system.

2. Yum

The full name is yellow Dog Updater Modified. for managing RPM packages to complete installation/uninstallation/upgrade, it is important to be able to handle dependencies between packages.

Ii. synchronizing external yum sources

The first step, of course, is to establish the Yum source of the intranet, basically the Yum source is a static HTTP service, yum client reads the remote data according to the configuration of the repo file, and downloads the RPM package to install locally. Specific installation steps no longer repeat, fully refer to "3" can be.

Of course I use different sources, mainly including the following sources:

CentOS 6 Base:rsync://mirrors.ustc.edu.cn/centos/6/os/centos 6 update:rsync://mirrors.ustc.edu.cn/centos/6/updates /centos 6 epel:rsync://mirrors.ustc.edu.cn/epel/6/percona:rsync://rsync.percona.com/rsync/centos/6/os/x86_64/

Ii.. Custom Yum Source

Above is the synchronization outside of the Yum source to the intranet, then how to define their own yum source? This is actually very simple.

1. Create a new directory under the above Data folder, similar to the

My_yum/├──centos-5│└──repodata└──centos-6├──packages└──repodata

2. Place the frequently used RPM files in the Packages folder to perform

Createrepo-p-d-o Centos-6 Centos-6

3. Create a My_yum.repo file, where

baseurl=http://yum-server.xxx.com/my_yum/centos-$releasever/

Iii.. Custom RPM files

In practical applications, there are many programs that do not have RPM installation packages and must be compiled and installed and custom configured, which is relatively complex. The following is an example of the Tengine 2.1.0 packaging process.

1. RPM Packaging

1) Install RPM Packaging tool

Yum-y Install Rpm-build

2) Set a directory structure according to the Rpmbuild specification.

Rpmbuild/├──build├──buildroot├──rpms├──sources├──specs└──srpms

3) Place the source code and the accompanying file in the appropriate location in the directory.

Download tengine-2.1.0.tar.gz to sources directory

4) Create spec file.

#This  is the spec file for tengineName:           tengineVersion:     2.1.0Release:      1Summary:    Tengine from Taobao Inc.Group:           applications/productivitylicense:     bsdurl:           http://tengine.taobao.org/Source0:      tengine-2.1.0.tar.gzbuildroot:     % (mktemp -ud %{_ TMPPATH}/%{NAME}-%{VERSION}-%{RELEASE}-XXXXXX) buildrequires:      libeventbuildrequires:     libevent-develbuildrequires:      Gcc%descriptiontengine from taobao inc.%prep%setup -q%build./configure --with-http_ Ssl_module --with-http_stub_status_modulemake%installrm -rf %{buildroot}make install destdir=%{buildroot}install -m 755 -d  %{buildroot}/%{_bindir}ln -s /usr/local/nginx/sbin/nginx %{buildroot}/%{_bindir}/nginx% Clean#rm -rf %{buildroot}%files%defattr (-,root,root,-)/usr/local/nginx/%{_bindir}/*%doc%changelog

4) Compile RPM.

Rpmbuild-v-BB--clean Specs/tengine-2.1.0.spec

When the compilation is completed successfully, the generated RPM files are placed in the RPMs directory and can be synchronized to their own Yum source for management.


2. Add a custom configuration

As can be seen from the spec file, RPM packaging process is to execute the Configure->make->make install through the script, and finally consolidate the compiled files into a rpm file. Then, if you want to customize the configuration, you only need to overwrite the original configuration with your own configuration file after make install.

1) Writing the configuration file

In accordance with normal syntax to write tengine configuration files, I modified the structure of the entire conf file, placed in the Sources/tengine_conf folder.

2) Spec file Source1

Add a line below SOURCE0

Source1:tengine_conf

So in the spec file will go to the Sources folder to find tengine_conf

3) Spec File install

In the%install section, add

RM-RF%{buildroot}/usr/local/nginx/confcp-r%{source1}%{buildroot}/usr/local/nginx/conf

Delete make install generated conf, replace with tengine_conf

This makes it possible to generate a customized RPM file, which can be easily upgraded/changed by modifying the version number and release number. Mainly to understand the principle of RPM packaging, pay attention to the use of some internal macro variables, attention to the relative path and absolute path problems. It is recommended to read "5" repeatedly.


"1" RPM-Official website

"2" Yum-official website

"3" Enterprise practical application of synchronous remote Yum source to local-yin-technology exchange-51CTO Technical Blog

"4" Brother's Blog | RPM Package with Yum Warehouse

"5" Using RPM packaging software, part 1th: Building and distributing packages

"6" How to create an RPM package/zh-cn-fedoraproject


This article from "My Journey is the Star Sea" blog, please be sure to keep this source http://mickhan.blog.51cto.com/2517040/1598991

Build a yum server inside your enterprise

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.