Skills required for automated deployment-deployment of yum warehouses, custom rpm packages, and yumrpm

Source: Internet
Author: User
Tags mcrypt aliyun

Skills required for automated deployment-deployment of yum warehouses, custom rpm packages, and yumrpm
Deploy the yum repository and customize the rpm package directoryChapter 2 extension-yum Cache

  1.1 yum Cache Usage steps... 1

1.1.1 introduction... 1

1.1.2 modify the configuration file... 1

1.1.3 use cache... 1

Chapter 2 essential skills for automated deployment-building a YUM repository... 2

  2.1 warehouse introduction... 2

2.1.1 Introduction... 2

2.1.2 instructions for use:... 2

 2.2 YUM repository construction process... 3

2.2.1 create the yum repository directory... 3

2.2.2 install createrepo software... 3

2.2.3 initialize the repodata index file... 3

2.2.4 yum Service (Python)... 4

2.2.5 Add a new rpm package to the repository... 4

  2.3 client configuration and use... 5

2.3.1 change yum source... 5

2.3.2 clear the previous cache... 5

2.3.3 specify to use the yum library... 5

2.3.4 install yum directly... 5

2.4 mirror yum source... 6

2.4.1 synchronize images with the Internet yum source... 6

2.4.2 students use the Intranet yum source method... 6

2.4.3 result display... 6

Chapter 4 Essential Skills for automated deployment-customized RPM packages... 7

 3.1 install FPM packaging tool... 7

3.1.1 install the dependency package... 7

3.1.2 2. Step 2: Change the warehouse... 8

3.2 FRM parameter:... 8

  3.3 Nginx package instance reference:... 9

3.3.1 Step 1: Create a script... 9

3.3.2 Step 2: Create a fpm package... 9

3.3.3 Step 3: View fpm package (ls). 9 in the current path

 3.4 install the rpm package:... 9

3.5 Note:... 10

 

Chapter 2 extension-yum cache 1st yum Cache Usage steps 1.1.1 Introduction

By default, the current version of yum deletes the downloaded file after the software package is successfully downloaded and installed. This reduces the disk space occupied by yum. You can open the cache (set the keepcache option in/etc/yum. conf to 1: keepcache = 1) so that yum will keep the downloaded files in the cache directory.

1.1.2 modify the configuration file

Set the keepcache option in/etc/yum. conf to 1: keepcache = 1

The downloaded installation package will be cached to packages in the/var/cache/yum/x86_64/directory.

1.1.3 use Cache

L download and Cache

[Root @ CeShi 6] # yum install gd-devel libcurl-devel

2 local cache download

[Root @ CeShi 6] # yum-C install gd-devel libcurl-devel

3 Note:

All file packages under the/var/cache/yum/directory are copied to the same directory under another machine. Execute.

Chapter 2 essential skills for automated deployment-building a YUM warehouse 2nd warehouse introduction 2.1.1 Introduction

YUM is mainly used to automatically install and upgrade the rpm software package. It can automatically find and solve the dependency between rpm packages. To successfully use the YUM tool to install and update the software or system, you need a repository (software warehouse) that contains various rpm software packages. This software warehouse is often called the yum source. There are a large number of yum sources on the network. However, due to network environment restrictions, software installation may take too long or even fail. Especially when a large number of software packages on the server need to be installed, the slow progress bar is unbearable. Therefore, we will change the domestic source when optimizing the system.

In comparison, the biggest advantage of local YUM source server is the fast network connection and Stability of LAN. With the YUM source server in the LAN, even if the Internet connection is interrupted, the software installation and upgrade of other YUM clients will not be affected.

Http://www.zyops.com/autodeploy-yum

2.1.2 usage instructions:

Prerequisites for using an intranet Repository

1. Client: Change yum Source

[Root @ B yum. repos. d] # vi xzy. repo

[Xzy]

Name = Server

Baseurl = http: // 10.0.0.5

Enable = 1

Gpgcheck = 0

2. SERVER: Corresponding rpm packages (including dependent packages) must be included in the repository)

L Intranet repository + custom rpm package

Push the customized rpm package to the yum repository, and update the repository.

L use an intranet Repository

First, use the online yum source on the repository HOST: yum cache to the local machine-> copy to the repository-> Update the Repository

2.2 YUM repository Construction Process

Deployment command package

Mkdir-p/application/yum/centos6.6/x86_64/

Cd/application/yum/centos6.6/x86_64/

Yum-y install createrepo

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

Python-m SimpleHTTPServer 80 &>/dev/null &

2.2.1 create a yum repository directory

Mkdir-p/application/yum/centos6.6/x86_64/

Cd/application/yum/centos6.6/x86_64/

Rz # upload rpm packages to this directory, which can also contain folders

2.2.2 install createrepo Software
yum -y install createrepo
2.2.3 initialize the repodata index file

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

The drwxr-xr-x 2 root 4096 Nov 4 repodata file is generated in this directory.

-P -- pretty outputs xml files in a neat format.

-D -- database this option specifies that SQLite is used to store generated metadata. The default item is used.

-O -- outputdir <url> specifies the output location of the metadata.

2.2.4 yum Service (Python)

# Web services can be provided using Apache or nginx, but http modules using Python are simpler and suitable for intranet environments.

cd /application/yum/centos6.6/x86_64/python -m SimpleHTTPServer 80 &>/dev/null &

Note:

Must be in the repository directory (equivalent to setting the site directory)

The port number can be changed (the default value of Python is 8000)

You can enter the IP address of the local machine in the browser.

#

Python-m SimpleHTTPServer 80 &>/dev/null &

Run this command to access this directory in the browser.

[Root @ CeShi ~] # Python-m SimpleHTTPServer 80 &>/dev/null &

[1] 15294

2.2.5 Add a new rpm package to the repository

The local machine uses the online yum Source: yum cache to the local machine-> copy to warehouse-> Update warehouse

1. Modify: vim cat/etc/yum. conf keepcache = 1 # cache to Local Machine

2. Copy: [root @ CeShi x86_64] # find/var/cache/yum/x86_64/6/-name "*. rpm "| xargs cp-t/application/yum/centos6.6/x86_64/# The rpm package under this directory can be in the directory.

3. update: createrepo -- update/application/yum/centos6.6/x86_64/# Important

 

 

2.3 configure the client and use 2.3.1 to change the yum Source

Cd/etc/yum. repos. d

[Root @ B yum. repos. d] # vi oldboy. repo

[XZY]

Name = xzy

Baseurl = http: // 10.0.0.5: 80

Enable = 1

Gpgcheck = 0

2.3.2 clear the previous Cache
yum clean all

 

2.3.3 specify to use the yum Library
yum --enablerepo=XZY --disablerepo=base,extras,updates,epel list 
2.3.4 install yum directly

[Root @ backup yum. repos. d] # yum install mhash mcrypt

Loaded plugins: fastestmirror, security

* Epel: mirrors.aliyun.com

Epel/primary_db | 6.0 MB

XZY | 2.9 kB: 00

XZY/primary_db | 35 kB: 00

Resolving Dependencies

--> Running transaction check

---> Package mcrypt. x86_64 2. 6.8-10. el6 will be installed

 

2.4 mirror yum source (not important)

 

The above is just to put your own rpm package into the yum source. However, there is another enterprise requirement. To be more specific, the yum Installation Software for students is downloaded from the public network and occupies the bandwidth. Therefore, an Intranet yum server is set up in the school, however, considering that students also need to use yum to install software when they go home, if the database file repodata of the yum software is different, there will be problems. Therefore, the solution I came up with is to directly use the repodata from the Internet yum source.

 

2.4.1 synchronize images with the Internet yum Source

Description

The upstream yum source must support the rsync protocol; otherwise, rsync cannot be used for synchronization.

The image size is large, and the size of all images is about GB.

 

# Tips for synchronizing the base source. The CD image we installed on the system contains part of the rpm package, which is about 3 GB. You do not need to download it again.

/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/

 

 

2.4.2 students use the Intranet yum Source Method

# You can build an intranet dns. If not, you can use hosts for resolution.

Echo '1970. 168.0.200 mirrors.aliyun.com '>/etc/hosts

 

2.4.3 Result Display

[Root @ KVM data] #Du-sh yum_data

21G yum_data

[Root @ KVM data] # tree-L 3 yum_data/

Yum_data/

├ ── Centos

│ ── 6

│ ── Extras

│ ── OS

│ ── Updates

│ ── RPM-GPG-KEY-CentOS-6.

── Epel

│ ── 6

│ ── X86_64

 

 

Chapter 4 Essential Skills for automated deployment-customized RPM package 3rd FPM package tool installation 3.1.1 install dependency package
yum -y install ruby rubygems ruby-devel

 

3.1.2 Step 2: Change the warehouse

View the current repository source command

Gem sources list

Change ruby warehouse

Gem source-a http://mirrors.aliyun.com/rubygems/-r http://rubygems.org/

 

3.1.3 Step 2: Install fpm and json

Gem install json-v 1.8.3

Gem install fpm-v 1.3.3

 

3.2 FRM parameters:

-S specifies the source type

-T specifies the target type, that is, why the package is to be created?

-N indicates the package name.

-V indicates the version number of the package.

-C: Change directory to here before searching forfiles

-D specifies which packages are dependent on

-F if an installation package with the same name exists in the directory during the second packaging, overwrite it

-P: directory of the installation package output. You must specify the directory if you do not want to put it in the current directory.

-- Post-install

-- Pre-install: the script to be run before the package is installed. It is the same as -- before-install.

-- Post-uninstall

-- Pre-uninstall: the script to be run before the package is uninstalled; same as -- before-remove

 

3.3 Nginx package instance reference: 3.3.1 Step 1: Create a script:

#! /Bin/bash

Useradd www-M-s/bin/nologin

Ln-s/application/nginx-1.10.2 // application/nginx

 

3.3.2 Step 2: Create a fpm package
 fpm -s dir -t rpm -n nginx -v 1.10.2 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/nginx_rpm.sh -f /application/nginx-1.10.2/

 

Note: You can specify multiple directories after-f.

3.3.3 Step 3: view the fpm package (ls) in the current path)

 

3.4 install the rpm package:

1. Recommended usage: yum localinstall package name (the package is in the current directory)

Yum-y localinstall nginx-1.10.2-1.x86_64.rpm

[Root @ m01 application] # ll

Total 4

Lrwxrwxrwx 1 root 26 Nov 1 nginx->/application/nginx-1.10.2/

Drwxr-xr-x 11 root 4096 Nov 1 nginx-1.10.2

2. Upload the customized rpm package to the specified directory of the yum repository for yum installation.

 

3.5 Considerations:

1. the packaged software must be an absolute path.

2. The soft connection path cannot be packaged.

3. The software cannot be running during packaging

 

Recommended blog: http://blog.oldboyedu.com/category/automatic-operation/automatic-deployment/

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.