Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

One-click automated deployment (customized rpm package)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Deployment-Previous

In the morning, MySQL multi-instance deployment is completed. Due to some specific requirements of the company, source code installation is required. Now batch deployment is required. If one is deployed, it will be too troublesome and waste time. At this time, automated deployment will show its value.

We will make MySQL custom rpm package, and then put it in our yum repository, in yum all clients, all point to yum source, after that is to drink tea, look at the film, easy batch deployment, no more nonsense, start dry.

If MySQL multi-instance is not configured, or do not know how to install the software

Please refer to: qiuyt.blog.51cto.com/1229789/1920686

#Blogger's new blog address: https://www.dgstack.cn/ Enter surprise ~~ Welcome to collection

I. Introduction to Yum Installation

yum is {Yellow dog Updater, Modified} ×× dog, used to manage rpm packages.

Its advantages: simple, efficient, to solve the problem of dependence; disadvantages: early customization package complex

Second, make rpm package

The author of FPM is Jordansissel.

FPM github: github.com/jordansissel/fpm

The FPM function is simply to convert one type of package into another type

rpm: Redhat package manager, with 5 functions such as upgrade, query, verification, installation, and uninstall;

rpm --help is available ##--hep to view built-in system parameters

1, rpm supports which packet conversions?

Source Type Package:

dir : Package the directory into an rpm package, which is to package the compiled and installed directory directly, and to the opposite end is equivalent to decompressing the installation directory. rpm: convert rpm gem: convert rubygem python: package python packages into corresponding types

Destination Type Packet: What type of packet can be forwarded

rpm Convert to rpm package deb Convert to Deb package solaris Convert to solaris package puppet Converting to puppet module

2. Install the FPM packaging tool

1) Install ruby module

yum -y install ruby ruby-devel gem sources list #View currently used rubygems repositories

2) Update yum source

Note: Add domestic Taobao Rubygems repository, foreign source slow, remove native Ruby repository

gem sources --add http://gems.ruby-china.org --remove http://rubygems.org/

3) Install fpm and json dependency packages

gem install json -v 1.8.3gem install fpm -v 1.3.3

gem install software from rubygem repository similar to yum install software from yum repository. First install a lower version of json, a higher version of json requires ruby2.0 or above, and then install a lower version of fpm, enough on the line.

#The above two-step installation is only suitable for CentOS6 system, CentOS 7 system in one step, namely gem install fpm

4) Verification

rpm --help #If there is output, the installation is successful

3, FPM parameter description

See fpm -help for details

Common parameters-s Specify source type (e.g. dir directory)-t Specify the target type, i.e. why you want to make a package (e.g. you want to make an rpm package)-n Specify the name of the package, -name -v Specifies the version number of the package (used to distinguish rpm, same name but different version)-C Change directory to here before searching forfiles-d Specify which packages depend on-f If there is an installation package with the same name in the directory when packaging for the second time, force it to overwrite it-p The directory of the output installation package. If you don't want to put it in the current directory, you need to specify--post-install. script to run after executing rpm package; same as--after-install--pre-install Script to run before package installation completes; same as--before-install--post-uninstall Script to run after package uninstall; same as--after-remove--pre-uninstall Script to run before package uninstall completes; same as--before-remove

4. Custom MySQL rpm package

Usage: script run before rpm package + rpm package + script after rpm package

Our myslq was compiled and installed before, so there was no script before the rpm package was run. We directly considered which directories needed to be packaged.

1. Confirm package directory

rpm What directories need to be packaged: (Check which directories need to be packaged from your compilation and installation process)

/data directory ##This is a multi-instance data storage directory/application/mysql-5.5.32/ #This is the mysql installation directory

2. Create a script

The commands that need to be executed after packaging are put into the script (check which commands need to be executed after extracting the directory from your compilation and installation process)

After confirmation, create the script mkdir -p /server/scripts && cd /server/scriptscat >mysql_rpm.sh/etc/rc.local #Add boot autoboot echo "/data/3306/mysql start " >/etc/rc.local echo "/data/3307/mysql start " >/etc/rc.localEOF

3. Generate rpm package

Package the directory (rpm package containing scripts and directories)(box in front followed by apple)

1) Mysql custom rpm package

[root@db02 scripts]# fpm -s dir -t rpm -n mysql -v5.5.32 --post-install/server/scripts/mysql_rpm.sh-f /data/ /application/mysql-5.5.32 2/no value for epoch is set, defaulting to nil {:level=>:warn}no value for epoch is set, defaulting to nil {: level =>:warn}Created package {:path=>"mysql-5.5.32-1.x86_64.rpm"}[root@db02 scripts]#lsmysql-5.5.32 - 1.x86@@_64.rpm mysql_rpm.sh#-s Specify directory type-t Specify packaging type-n Specify rpm package name-v Version number--post-install Script executed after packaging-f Specify directory path to package #Note packaging to use relative path problem

2) Site deployment www bbs blog

fpm -s dir -t rpm -n three_web -v 1.0 -f /application/nginx/html/

3) LB Load Balancer

fpm -s dir -t rpm -n lb -v 1.8.1 -d 'pcre-devel,openssl-devel' --post-install /server/scripts/install_LB.sh -f /application/nginx-1.8.1/lb-1.8.1-1.x86_64

Third, check the information in the rpm package

rpm -qp --scripts mysql-5.5.32-1.x86_64.rpm #View script info in package rpm -qpl mysql-5.5.32-1.x86_64.rpm ##See which files and directories are included in the rpm package

Note: mysql is a large directory, and it takes a long time to package with fpm. Usually we may need to optimize nginx or php, which will have to be repackaged. So we can separate mysql and package it separately. Just add mysql dependencies when making rpm packages for nginx+php.

IV. Put it into YUM warehouse and install it with one click on client side.

1) Upload rpm package to yum repository

scp mysql-5.5.32-1.x86_64.rpm root@172.16.1.101:/application/yum/centos6.8/x86_64#I here yum repository is an intranet using IP address: 172.16.1.101, if there is no *** can consider giving an external network IP10.0.0.101

2) Update yum repository list

[root@Qiuyuetao x86_64]# createrepo --update /application/yum/centos6.8/x86_64/rpm Package Name: mysql-5.5.32-1.x86_64.rpm

3) One-click deployment Mysql (client)

#Start a new device and configure the yum repository client cd /etc/yum.repos.dmkdir yum_bak & mv *repo yum_bakcat >>oldboy.repo

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report