Centos7 by reposync synchronous domestic yum source - set up a local network LAN Yum source

In a production environment not connected to an external network, also commonly need to install a lot of dependencies on the basis of some software installation, it is common practice to use a local configuration system image source yum, yum install dependencies used, but generally less mirror big, if only for the installation of a two mirror yum package configuration a source of time and effort, we can advance in their own way can be connected to the external network test environment using the host country reposync synchronization source download cache yum rpm package to a local machine, use createrepo command to make a local network yum repository.

Testing the host operating system: centos7.4 x64,2c4G, 100G system disk, 1T data disk. Lvm partition format, a single data disk LV, mount / data directory.

reposync command is a python script. Yum-utils contained in the package. Therefore, if we want to use reposync command when you need to install yum-utils package.

Use the following command: yum install yum-utils

reposync -r repository name (usually base) -p target directory

No small door installation partners own yum-utils

1. repository installation and management tools apache-utils yum
yum yum the install the httpd-utils the createrepo -Y
systemctl enable the httpd
systemctl Start the httpd

2. Create a file directory
mkdir -p / the Data / Website / CentOS / 6 /
mkdir -p / the Data / Website / CentOS / 7 /
mkdir -p / the Data / Website / EPEL /

3. Modify /etc/yum.repos.d/CentOS-Base.repo

## centos7

[base7]

name=CentOS-7-os-cmiot.local baseurl=http://mirrors.163.com/centos/7/os/x86_64/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates7] name=CentOS-7-updates-cmiot.local baseurl=http://mirrors.163.com/centos/7/updates/x86_64/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras7] name=CentOS-7-extras-cmiot.local baseurl=http://mirrors.163.com/centos/7/extras/x86_64/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 ## centos6 [base6] name=CentOS-6-os-cmiot.local baseurl=http://mirrors.163.com/centos/6/os/x86_64/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates6] name=CentOS-6-updates-cmiot.local baseurl=http://mirrors.163.com/centos/6/updates/x86_64/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras6] name=CentOS-6-extras-cmiot.local baseurl=http://mirrors.163.com/centos/6/extras/x86_64/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 ## epel [epel6] name=CentOS-6-epel-cmiot.local baseurl=https://mirrors.aliyun.com/epel/6/x86_64/ gpgcheck=0 [epel7] name=CentOS-7-epel-cmiot.local baseurl=https://mirrors.aliyun.com/epel/7/x86_64/ gpgcheck=0 

4. Use yum repolist verify whether CentOS-Base.repo files into force

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                              repo name
base6                                CentOS-6-os-cmiot.local
base7                                CentOS-7-os-cmiot.local
epel6                                CentOS-6-epel-cmiot.local
epel7                                CentOS-7-epel-cmiot.local
extras6                              CentOS-6-extras-cmiot.local
extras7                              CentOS-7-extras-cmiot.local
updates6                             CentOS-6-updates-cmiot.local
updates7                             CentOS-7-updates-cmiot.local

5. Sync CentOS-Base.repo file centos6 package file 163

reposync -n --repoid=extras6 --repoid=updates6 --repoid=base6 -p /data/website/centos/6 reposync -n --repoid=epel6 -p /data/website/epel/ 

6. Synchronization CentOS-Base.repo file centos7 package file 163

reposync -n --repoid=extras7 --repoid=updates7 --repoid=base7 -p /data/website/centos/7 reposync -n --repoid=epel7 -p /data/website/epel/ 

createrepo command creates yum source (depot), is the number of packets stored in the local rpm particular location index, dependency information describing the required each packet, and the formation of metadata.
Parameter Option Description:

-u  --baseurl <url>
    指定Base URL的地址

-o --outputdir <url> 指定元数据的输出位置 -x --excludes <packages> 指定在形成元数据时需要排除的包 -i --pkglist <filename> 指定一个文件,该文件内的包信息将被包含在即将生成的元数据中,格式为每个包信息独占一行,不含通配符、正则,以及范围表达式。 -n --includepkg 通过命令行指定要纳入本地库中的包信息,需要提供URL或本地路径。 -q --quiet 安静模式执行操作,不输出任何信息。 -g --groupfile <groupfile> 指定本地软件仓库的组划分,范例如下: createrepo -g comps.xml /path/to/rpms 注意:组文件需要和rpm包放置于同一路径下。 -v --verbose 输出详细信息。 -c --cachedir <path> 指定一个目录,用作存放软件仓库中软件包的校验和信息。 当createrepo在未发生明显改变的相同仓库文件上持续多次运行时,指定cachedir会明显提高其性能。 --update 如果元数据已经存在,且软件仓库中只有部分软件发生了改变或增减, 则可用update参数直接对原有元数据进行升级,效率比重新分析rpm包依赖并生成新的元数据要高很多。 -p --pretty 以整洁的格式输出xml文件。 -d --database 该选项指定使用SQLite来存储生成的元数据,默认项。 

7. Create Index
format: createrepo -po source output location directory metadata directory index

createrepo -po /data/website/centos/6/base6/ /data/website/centos/6/base6/ createrepo -po /data/website/centos/6/updates6/ /data/website/centos/6/updates6/ createrepo -po /data/website/centos/6/extras6/ /data/website/centos/6/extras6/ createrepo -po /data/website/epel/epel6/ /data/website/epel/epel6/ createrepo -po /data/website/centos/7/base7/ /data/website/centos/7/base7/ createrepo -po /data/website/centos/7/updates7 /data/website/centos/7/updates7 createrepo -po /data/website/centos/7/extras7 /data/website/centos/7/extras7 createrepo -po /data/website/epel/epel7 /data/website/epel/epel7 

8. Create an index file group
Description: yum groupinstall time will use this index.
wget http://mirrors.163.com/centos/6/base6/repodata/43d8fd068164b0f042845474d6a22262798b9f0d1f49ad1bf9f95b953089777d-c6-x86_64-comps.xml -P / tmp
wget http://mirrors.163.com/centos/7/base7/repodata /38b60f66d52704cffb8696750b2b6552438c1ace283bc2cf22408b0ba0e4cbfa-c7-x86_64-comps.xml -P / tmp
the createrepo /tmp/43d*-comps.xml -g / Data / Website / CentOS /. 6 / base6 /
the createrepo /tmp/38b*-comps.xml -g / data / website / centos / 7 /

9. KEY download files
when the user to download and install the RPM package, RH official introduction of the RPM GPG public key to verify the RPM package is not the official signature of RH
wget http://mirrors.163.com/centos/7/os / the x86_64 / the RPM-the GPG-KEY. 7-the CentOS- -P / Data / Website / CentOS /
wget http://mirrors.163.com/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6 - P / data / website / centos /

10. Set the root to the apache / data / website
modifications /etc/httpd/conf/httpd.conf
Note #DocumentRoot "/ var / www / htmlthis line, in which the added

#DocumentRoot "/var/www/html"
DocumentRoot "/data/website"
<Directory "/data/website"> Options Indexes FollowSymLinks Options Indexes AllowOverride All Order allow,deny IndexOptions Charset=UTF-8 Allow from all Require all granted </Directory> 

11. Delete the welcome configured, to access the server directly address the real root of the site
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak
12. open httpd service
systemctl restart httpd
systemctl enable httpd
browser can access / data / website by accessing the directory to IP


 
website directory .jpg

13. Timing synchronization task reposync

Client /etc/yum.repos.d/CentOS-Base.repo modify file
below to centos6 example:

[base]
name=CentOS-$releasever - Base - cmiot.local baseurl=http://172.20.11.249/centos/$releasever/base6 gpgcheck=1 gpgkey=http://172.20.11.249/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates - cmiot.local baseurl=http://172.20.11.249/centos/$releasever/updates6 gpgcheck=1 gpgkey=http://172.20.11.249/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - cmiot.local baseurl=http://172.20.11.249/centos/$releasever/extras6 gpgcheck=1 gpgkey=http://172.20.11.249/centos/RPM-GPG-KEY-CentOS-6 [epel] name=CentOS-$releasever - Extras - cmiot.local baseurl=http://172.20.11.249/epel/epel6 gpgcheck=0 

Set the timer daily update script update.sh

#!/bin/bash
echo 开始同步ubuntu
apt-mirror
echo ubuntu同步结束

echo 开始同步centos6
reposync -n --repoid=extras6 --repoid=updates6 --repoid=base6 -p /data/website/centos/6
reposync -n  --repoid=epel6 -p /data/website/epel/
echo centos6同步结束

echo 开始同步centos7
reposync -n --repoid=extras7 --repoid=updates7 --repoid=base7 -p /data/website/centos/7
reposync -n  --repoid=epel7 -p /data/website/epel/
echo centos7同步结束

#更新元数据
createrepo --update /data/website/centos/6/base6/
createrepo --update /data/website/centos/6/updates6/
createrepo --update /data/website/centos/6/extras6/
createrepo --update /data/website/epel/epel6/
createrepo --update /data/website/centos/7/base7/
createrepo --update /data/website/centos/7/updates7/
createrepo --update /data/website/centos/7/extras7/
createrepo --update /data/website/epel/epel7/

14. crontab -e Add Task Timing

0 6 * * * /data/update.sh 

    crontab -l View scheduled tasks
0 6 * * * /data/update.sh



Author: also to wide horse
link: https: //www.jianshu.com/p/6c3090968d71
Source: Jane books

Guess you like

Origin www.cnblogs.com/vilenx/p/12533361.html