Prior to the introduction of the Linux environment local Yum source configuration method, but this is the simplest and most basic configuration, in the Yum installation may be some package is not complete, the following is the full Yun mirror source system Environment deployment record (Yum source update script: https:// PAN.BAIDU.COM/S/1MIMNPGC Extract Password:hq6u):
1) Install Nginx for Yum image source Access configuration [[email protected] ~]# yum-y install gcc pcre-devel zlib-devel openssl-devel[[email Protected] ~]# cd/data/software[[email protected] software]# wget http://nginx.org/download/ Nginx-1.12.0.tar.gz[[email protected] software]# tar-zvxf nginx-1.12.0.tar.gz [[email protected] Software ]# CD nginx-1.12.0 Add www user, where-m parameter indicates not to add user home directory,-s parameter indicates specified shell type [[[email protected] nginx-1.12.0]# useradd www-m-S/ Sbin/nologin [[email protected] nginx-1.12.0]#./configure--prefix=/data/nginx--user=www--group=www-- With-http_ssl_module--with-http_flv_module--with-http_stub_status_module--with-http_gzip_static_module-- With-pcre[[email protected] nginx-1.12.0]# make && make install2) configuration nginx[[email protected] ~]# CAT/ Data/nginx/conf/vhosts/mirrors.confserver {Listen 80; server_name yum.kevin.com mirrors.kevin.com localhost; Index index.html index.php index.htm; Access_log/data/nginx/logs/access.log main; Error_loG/data/nginx/logs/error.log; Location/{root/data/mirrors; AutoIndex on; Autoindex_exact_size off; Autoindex_localtime on; }}[[email protected] ~]#/data/nginx/sbin/nginx-tnginx:the configuration file/data/nginx/conf/nginx.conf Syntax is oknginx:configuration file/data/nginx/conf/nginx.conf test is successful[[email protected] ~]#/data/ Nginx/sbin/nginx [[email protected] ~]# lsof-i:80command PID USER FD TYPE DEVICE size/off NODE Namenginx 7741 Root 6u IPv4 28311 0t0 tcp *:http (LISTEN) nginx 7769 www 6u IPv4 28311 0t0 tcp *:http (LISTEN) ng Inx 7770 www 6u IPv4 28311 0t0 tcp *:http (LISTEN) nginx 7771 www 6u IPv4 28311 0t0 TCP *:http (LISTEN) nginx 7772 www 6u IPv4 28311 0t0 TCP *:http (LISTEN) nginx 7773 www 6u IPv4 28311 0t0 T CP *:http (LISTEN) nginx 7774 www 6u IPv4 28311 0t0 TCP *:http (LISTEN) nginx 7775 www 6u IPv4 28311 0t0 TCP *:http (LISTEN) nginx 7776 www 6u IPv4 28311 0t0 TCP *:http (LISTEN) 3) Create Yum source data directory [[EMAIL&NBSP;PR Otected] ~]# mkdir-p/data/mirrors[[email protected] ~]# cd/data/mirrors/[[email protected] mirrors]# mkdir CentOS Epel etc Rpmforge [[email protected] mirrors]# lscentos Epel etc rpmforge 4) write the Yum source download update script (from MIRRORS.USTC. edu.cn Mirror website download and update) [[email protected] ~]# cat/data/script/mirrors.sh #!/bin/bash #============================== ============# Program:/bin/update_yum_source.sh# Info: Regularly synchronize official Yum source to local # version:2017.12.10 v1.0# Author: kevin# Usage:3 3 * * */bin/bash/data/script/mirrors.sh#========================================== Date= ' Date +%Y%m %d ' logfile= '/data/logs/$Date. Log "receivemail=" [email protected] "rsyncbin="/usr/bin/rsync "rsyncperm="-AVRT --delete--exclude=debug/--exclude=isos/--exclude=srpms/--exclude=ppc/--delete-excluded "#============ CentOS = = ==========centos_path= "/data/mirrors/centos" YuMsitelist= "rsync://mirrors.ustc.edu.cn/centos/" centosparm= "--exclude=2*/--exclude=3*/--exclude=4*/--exclude=5* /"#============ Epel ==============epelsite=" Rsync://mirrors.ustc.edu.cn/fedora-epel "epelLocalPath="/data/ Mirrors/epel "epelparm="--include=7/x86_64--include=7server/x86_64--include=6/x86_64--include=6Server/x86_64 "#= =========== rpmforge ==============rpmforgesite= "rsync://apt.sw.be/pub/freshrpms/pub/dag/redhat/" #rpmforgeSite = " rsync://apt.sw.be/redhat/"rpmforgelocalpath="/data/mirrors/rpmforge/"rpmforgeparm="--exclude=ppc/--exclude= EL2.1/--exclude=el3/--exclude=el4/--exclude=el5/"echo"----$Date ' Date +%t ' Begin----' >> $LogFile # Centos$rsy Ncbin $RsyncPerm $centosparm $YumSiteList $CentOS _path >> $LogFile # epel$rsyncbin $RsyncPerm $epelparm $epelLocalPath >> $LogFile # rpmforge$rsyncbin $RsyncPerm $rpmforgeparm $rpmforgeSite $rpmforgeLocalPath >> $LogFile echo "----$Date ' Date +%t ' End---->> $LogFile #/bin/mail-s"Opt001-update yum source-$Date" $ReceiveMail < $LogFile points to note in the script above:--exclude means that when rsync synchronizes, Directories that need to be excluded (specific: The directory is empty, the size is 0)--include indicates rsync synchronization, only want to synchronize the directory because this case is to deploy the Yum source, for the Linux server on the local Yum solution installation, There is no need to synchronize ISOs mirroring (while also saving machine space resources), so the ISOs Mirror directory screen is executed synchronously when synchronizing. This process is relatively long, presumably to download nearly 180G of content. Need to wait patiently ~~[[email protected] ~]# sh-x/data/script/mirrors.sh [[email protected] ~]# du-sh/data/mirrors/*93g /data/mirrors/centos80g/data/mirrors/epel4.0k/data/mirrors/etc4.0k/data/mirrors/rpmforge410m/data/mirrors/ Software[[email protected] ~]# LS/DATA/MIRRORS/CENTOS/2 3.6 6.0 6.6 7.1.1503 Dostools rpm-gpg- Key-centos-3 rpm-gpg-key-centos-debug-6 TIMESTAMP.TXT3 3.7 6.1 6.7 7.2.1511 filelist.gz Rpm-gpg-ke Y-centos4 rpm-gpg-key-centos-debug-73.1 3.8 6.2 6.8 7.3.1611 Graphics rpm-gpg-key-centos-4 rpm-gpg- key-centos-security-63.3 4 6.3 6.9 7.4.1708 header.html rpm-gpg-key-centos-5 rpm-gpg-key-centos-testin g-63.4 5 6.4 7 build Header.images rpm-gpg-key-centos-6 rpm-gpg-key-centos-testing-73.5 6 6.5 7.0. 1406 dir_sizes Rpm-gpg-key-beta rpm-gpg-key-centos-7 time[[email protected] ~]# LS/DATA/MIRRORS/EPEL/4 5Clien T 7Server fullfilelist. KDUVZC9WPK rpm-gpg-key-epel-4 rpm-gpg-key-epel-7server4as 5Server epel-release-latest-6.noarch.rpm ful Lfiletimelist-epel rpm-gpg-key-epel-5 testing4es 6 epel-release-latest-7.noarch.rpm Fullfileti Melist-epel. Wao7kuhvyz rpm-gpg-key-epel-64ws 6Server fullfilelist imagelist-epel Rpm-gpg-ke Y-epel-6server5 7 fullfilelist. AWIES3LJSB Rpm-gpg-key-epel rpm-gpg-key-epel-75) Replace the Yum source address of Linux native [[email protected] ~]# CD /etc/yum.repos.d/[[email protected] yum.repos.d]# Lscentos-base.repo Centos-debuginfo.repo Centos-fasttrack.repo Centos-media.repo centos-vault.repo[[email&Nbsp;protected] yum.repos.d]# mkdir bak[[email protected] yum.repos.d]# mv *.repo bak/[[email protected] yum.repos.d]# Lsbak writing yum source files [[email protected] yum.repos.d]# cat Centos-base.repo # centos-base.repo## the Mirrors system uses the connecting IP address of the client and the# update status of each mirrors to pick mirrors, that is update D to and# geographically close to the client. You should use this for CentOS updates# unless is manually picking other mirrorss.## If the mirrorslist= does not wor K for your, as a fall back you can try the # remarked out Baseurl= line instead.##[base]name=centos-centos-$releasever-ba se#mirrorslist=http://mirrorlist.centos.org/?release=centos-$releasever &arch= $basearch &repo=os& Infra= $infrabaseurl =http://mirrors.kevin.com/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=http:// mirrors.kevin.com/etc/pki/rpm-gpg/rpm-gpg-key-centos-$releasever #released Updates [updates]name=centos-centos-$ Releasever-updates#mirrorslist=http://mirrorlist.centos.org/?release=centos-$releasever &arch= $basearch &repo=updates&infra=$ infrabaseurl=http://mirrors.kevin.com/centos/$releasever/updates/$basearch/gpgcheck=1gpgkey=http:// mirrors.kevin.com/etc/pki/rpm-gpg/rpm-gpg-key-centos-$releasever #additional packages that could be useful[extras]name =centos-centos-$releasever-extras#mirrorslist=http://mirrorlist.centos.org/?release=centos-$releasever & Arch= $basearch &repo=extras&infra= $infrabaseurl =http://mirrors.kevin.com/centos/$releasever/extras/$ basearch/gpgcheck=1gpgkey=http://mirrors.kevin.com/etc/pki/rpm-gpg/rpm-gpg-key-centos-$releasever #additional Packages that extend functionality of existing packages[centosplus]name=centos-centos-$releasever-plus#mirrorslist= http://mirrorlist.centos.org/?release=centos-$releasever &arch= $basearch &repo=centosplus&infra=$ infrabaseurl=http://mirrors.kevin.com/centos/$releasever/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=http:/ /mirrors.kevin.com/etc/pki/rpm-gpg/rpm-gpg-key-centos-$releasever #contrib-packages by CentOS users[contrib]name=centos-centos-$releasever -contrib#mirrorslist=http://mirrorlist.centos.org/?release=centos-$releasever &arch= $basearch &repo= Contrib&infra= $infrabaseurl =http://mirrors.kevin.com/centos/$releasever/contrib/$basearch/gpgcheck= 1enabled=0gpgkey=http://mirrors.kevin.com/etc/pki/rpm-gpg/rpm-gpg-key-centos-$releasever [[email protected ] yum.repos.d]# cat Epel.repo [Epel]name=extra Packages for Enterprise Linux $releasever-$basearchbaseurl =http://mirror s.kevin.com/epel/$releasever/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6& Arch= $basearchfailovermethod =priorityenabled=1gpgcheck=1gpgkey=http://mirrors.kevin.com/etc/pki/rpm-gpg/ rpm-gpg-key-epel-$releasever [Epel-debuginfo]name=extra Packages for Enterprise Linux 6-$basearch-debugbaseurl=http ://mirrors.kevin.com/epel/$releasever/$basearch/debug#mirrorlist=https://mirrors.fedoraproject.org/metalink? Repo=epel-debug-6&arch= $basearchfailovermethod =priorityenabled=0gpgkey=http://mirrors.kevin.com/etc/pki/ rpm-gpg/rpm-gpg-key-epel-$releasevergpgcheck =1[epel-source]name=extra Packages for Enterprise Linux 6-$basearch- sourcebaseurl=http://mirrors.kevin.com/epel/$releasever/srpms#mirrorlist=https://mirrors.fedoraproject.org/ Metalink?repo=epel-source-6&arch= $basearchfailovermethod =priorityenabled=0gpgkey=http://mirrors.kevin.com/ etc/pki/rpm-gpg/rpm-gpg-key-epel-$releasevergpgcheck =1[[email protected] yum.repos.d]# yum clean all[[email protected] yum.repos.d]# Yum makecache other servers if you want to use this Yum source, follow the steps above to/etc/ The repo files in the YUM.REPOS.D directory are removed, and the two files written above are then put in, and the Yum clean all and Yum Makecache can be executed! ============================================================================ Warm tip: The above Yum source configuration and two Yum files are available under the CENTOS6 and CENTOS7 systems ! Already verified!! ============================================================================ Update the above yum source script: You can put the above two files Mirrors.kevin.com/software inside, for download in script [[email protected] ~]# Cd/data/mirrors/software/[[email protected] software]# lsyum_reset.sh Centos-base.repo Epel.repo [[email protected] software]# cat yum_reset.sh #!/bin/bashcd/etc/yum.repos.d//bin/mkdir/etc/yum.repos. D/bakmv/etc/yum.repos.d/*.repo/etc/yum.repos.d/bakwget Http://mirrors.kevin.com/software/CentOS-Base.repowget Http://mirrors.kevin.com/software/epel.repo/usr/bin/yum clean All/usr/bin/yum Makecache only need to be the yum_ above The reset.sh script is downloaded to the target server and then executed to update the Yum source of the target server. # wget http://mirrors.kevin.com/software/yum_reset.sh# sh-x yum_reset.sh
The above Yum source synchronization scripts (mirros.sh) can be updated periodically, for example, updated monthly
[[email protected] ~]# crontab-e# 1th number per month 23:00 Point synchronization once yum source 0 1 * */bin/bash-x/data/script/mirrors.sh >/dev/null 2> &1
Yum Image source environment deployment record under Linux system