1 Keep the rpm package downloaded when yum installed the software Just modify the yum configuration file. The downloaded rpm package will be automatically saved in the /var/cache/yum/directory [root@swag ~]# sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf [root@swag ~]# yum install sl -y [root@swag ~]# tree /var/cache/yum/x86_64/6/epel/ /var/cache/yum/x86_64/6/epel/ ├── 83f14a3d88054141092be5da12eb18cb1baabd7d52e1ae38bfc98d3d5005490c-primary.sqlite ├── cachecookie ├── packages │ └── sl-5.02-1.el6.x86_64.rpm └── repomd.xml 1 directory, 4 files 2 Compile and install Nginx # Download tar.gz package cd /home/oldboy/tools wget -q http://nginx.org/download/nginx-1.6.3.tar.gz # Yum install Dependent package yum install openssl openssl-devel -y yum install pcre pcre-devel -y rpm -qa pcre pcre-devel # Useradd www useradd www -s /sbin/nologin -M # Compile and install tar -xf nginx-1.6.3.tar.gz cd nginx-1.6.3 ./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/ make && make install # Create a soft link ln -s /application/nginx-1.6.3/ /application/nginx # Start nginx /application/nginx/sbin/nginx # Check port 80 lsof -i :80 3 Install fpm tool First install the dependency packages Download ruby. fpm is written in ruby, so the system environment requires ruby. It is not recommended to install Ruby using yum, as this may cause some problems during testing. [root@swag tools]# wget https://ruby.taobao.org/mirrors/ruby/ruby-2.3.0.tar.gz [root@swag tools]# tar -xf ruby-2.3.0.tar.gz [root@swag tools]# cd ruby-2.3.0 [root@swag ruby-2.3.0]# ./configure [root@swag ruby-2.3.0]# make && make install [root@swag ruby-2.3.0]# ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] [root@swag ~]# whereis gem gem: /usr/local/bin/gem [root@swag ~]# /usr/local/bin/gem install fpm [root@swag ~]# fpm -v 1.9.3 # Add Alibaba Cloud's Rubygems repository. The default source is a foreign source, which has a slow download speed. Remove the native Ruby repository before adding it. [root@swag ~]# gem sources *** CURRENT SOURCES *** https://rubygems.org/ [root@swag ~]# gem sources --remove https://rubygems.org/ https://rubygems.org/ removed from sources # Add Ali warehouse [root@swag ~]# gem sources -a http://mirrors.aliyun.com/rubygems/ http://mirrors.aliyun.com/rubygems/ added to sources [root@swag ~]# gem sources *** CURRENT SOURCES *** http://mirrors.aliyun.com/rubygems/ fpm common parameters Source type packages supported by fpm Target type packages supported by fpm 4 Packaging Nginx [root@swag tools]# wget https://ruby.taobao.org/mirrors/ruby/ruby-2.3.0.tar.gz [root@swag tools]# tar -xf ruby-2.3.0.tar.gz [root@swag tools]# cd ruby-2.3.0 [root@swag ruby-2.3.0]# ./configure [root@swag ruby-2.3.0]# make && make install [root@swag ruby-2.3.0]# ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] [root@swag ~]# whereis gem gem: /usr/local/bin/gem [root@swag ~]# /usr/local/bin/gem install fpm [root@swag ~]# fpm -v 1.9.3 # Add Alibaba Cloud's Rubygems repository. The default source is a foreign source, which has a slow download speed. Remove the native Ruby repository before adding it. [root@swag ~]# gem sources *** CURRENT SOURCES *** https://rubygems.org/ [root@swag ~]# gem sources --remove https://rubygems.org/ https://rubygems.org/ removed from sources # Add Ali warehouse [root@swag ~]# gem sources -a http://mirrors.aliyun.com/rubygems/ http://mirrors.aliyun.com/rubygems/ added to sources [root@swag ~]# gem sources *** CURRENT SOURCES *** [root@swag tools]# wget https://ruby.taobao.org/mirrors/ruby/ruby-2.3.0.tar.gz [root@swag tools]# tar -xf ruby-2.3.0.tar.gz [root@swag tools]# cd ruby-2.3.0 [root@swag ruby-2.3.0]# ./configure [root@swag ruby-2.3.0]# make && make install [root@swag ruby-2.3.0]# ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] [root@swag ~]# whereis gem gem: /usr/local/bin/gem [root@swag ~]# /usr/local/bin/gem install fpm [root@swag ~]# fpm -v 1.9.3 # Add Alibaba Cloud's Rubygems repository. The default source is a foreign source, which has a slow download speed. Remove the native Ruby repository before adding it. [root@swag ~]# gem sources *** CURRENT SOURCES *** https://rubygems.org/ [root@swag ~]# gem sources --remove https://rubygems.org/ https://rubygems.org/ removed from sources # Add Ali warehouse [root@swag ~]# gem sources -a http://mirrors.aliyun.com/rubygems/ http://mirrors.aliyun.com/rubygems/ added to sources [root@swag ~]# gem sources *** CURRENT SOURCES *** 5 Other machine tests # scp transfer the rpm package [root@swag ~]# scp nginx-1.6.3-1.x86_64.rpm [email protected]:/home/oldboy/tools # Test [root@swag3 tools]# yum localinstall nginx-1.6.3-1.x86_64.rpm -y 6 Yum warehouse construction Install createrepo [root@swag2 ~]# yum install createrepo -y Create a yum repository directory and initialize the repodata index file [root@swag2 ~]# mkdir -p /application/yum/centos6.9/x86_64/ [root@swag2 ~]# cd /application/yum/centos6.9/x86_64/ # Copy the customized rpm package to this directory [root@swag2 x86_64]# createrepo -pdo /application/yum/centos6.9/x86_64/ /application/yum/centos6.9/x86_64/ Provide yum service # Here we use python to provide web services, you can also use apache or nginx to provide web services [root@swag2 x86_64]# python -m SimpleHTTPServer 80 &>/dev/null & # python's httpd module [root@swag2 x86_64]# lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python 24680 root 3u IPv4 32493 0t0 TCP *:http (LISTEN) If a new rpm package is added, it must be updated [root@swag2 x86_64]# createrepo --update /application/yum/centos6.9/x86_64/ The client modifies the yum source cat >>/etc/yum.repo.d/<<EOF [only] name=Server baseurl=http://10.0.0.7 # baseurl specifies the yum repository IP. If it is not port 80, add port enabled=1 gpgcheck=0 EOF # Client takes nginx installation as an example# Clear local cache[root@swag4 ~]# yum clean all # Display the local yum source list [root@swag4 ~]# yum --enablerepo=only --disablerepo=base,extras,updates,epel list # Note here that --enablerepo is only defined in the local.repo file # Install nginx as an example# yum --enablerepo=local --disablerepo=base,extras,updates,epel install nginx -y Some usage of yum # Only download the package without installing it # yum local installation rpm package yum localinstall pcre-devel openssl-devel # yum enables some sources and disables some sources to install software packages yum --enablerepo=local --disablerepo=base,extras,updates,epel install pcre-devel openssl-devel # Yum installation without GPG-check yum install --nogpgcheck pcre-devel openssl-devel # View yum history # List enabled software repositories yum repolist yum repolist all # List all software repositories, including disabled ones Troubleshooting
# Pay attention to whether the configuration file is written correctly 7 Mirroring and synchronizing public network yum sources The above is just to put the rpm package you made into the yum source. But there is another requirement. Usually, software installation is downloaded from the public network, which takes up bandwidth. Therefore, the repodata of the public network yum source can be used directly. The upstream yum source must support the rsync protocol, otherwise rsync cannot be used for synchronization. http://mirrors.ustc.edu.cn/status/ # CentOS official standard source: rsync://mirrors.ustc.edu.cn/centos/ # epel source: rsync://mirrors.ustc.edu.cn/epel/ # Synchronous commands: # Use rsync to synchronize the yum source. In order to save bandwidth, disk and download time, only the rpm package of CentOS6 is synchronized here. In this way, all rpm packages only occupy 21G, and the full synchronization requires about 300G. # Synchronize the base source. Tip: the CD image of our installation system contains some rpm packages, about 3G, so there is no need to download them 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/ # Using the intranet yum source method# You can build an intranet dns yourself. If you don’t have one, you can use hosts resolution. echo '192.168.0.200 mirrors.aliyun.com' >>/etc/hosts # Result display [root@swag5 data]# du -sh yum_data 21G yum_data [root@swag5 data]# tree -L 3 yum_data/ yum_data/ ├── centos │ ├── 6 │ │ ├── extras │ │ ├── os │ │ └── updates │ └── RPM-GPG-KEY-CentOS-6 ├── epel │ └── 6 │ └── x86_64 Summarize The above is the tutorial on how to customize rpm packages and build yum repositories for Centos. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
>>: $nextTick explanation that you can understand at a glance
When the DataSource property of a DataGrid control...
First time writing. Allow me to introduce myself....
The one I wrote before is too complicated, let’s ...
1. Enable Prometheus telemetry data By default, t...
Table of contents 1 Introduction to the new opera...
Recent product testing found a problem that when ...
Table of contents Preface Scope 1. What is scope?...
This article uses an example to illustrate the us...
Every website usually encounters many non-search ...
Click here to return to the 123WORDPRESS.COM HTML ...
1. Introduction MySQL locks can be divided into g...
Preface tcpdump is a well-known command-line pack...
In the previous article, I introduced the functio...
HTML <div class="spinner"></di...
I found an example when I was looking for a way t...