14, yum warehouse building

A local warehouse

1.yum up a local warehouse (How to achieve single)

1) 挂载cd光盘,因为里面很多的软件包 
[[email protected] ~]# mount /dev/cdrom /mnt 

2) 创建一个本地的仓库 
[[email protected] ~]# cd /etc/yum.repos.d/ 
[[email protected] /etc/yum.repos.d]# gzip * 
[[email protected] /etc/yum.repos.d]# cat xxx.repo 
[LocalBase]                            #真实的仓库名称 
name=This is Local Base      #当前仓库的描述 
baseurl=file:///mnt                     #仓库所在的路径,可以是 http:// https:// ftp:// file:// 
enabled=1                                   #启用当前的仓库,默认是启用的 
gpgcheck=0  #校验安装的rpm是否是合法的,0表示不校验 1表示校验,同时还需要gpgkey参数指定校验的公钥 

3) 使用当前本地的仓库 
[[email protected] /etc/yum.repos.d]# yum makecache 
[[email protected] /etc/yum.repos.d]# yum repolist 
Loaded plugins: fastestmirror, langpacks 
Loading mirror speeds from cached hostfile 

repo id               repo  name                       status         
LocalBase         This is Local Base          4,021 
repolist: 4,021

2.yum up a local warehouse ---> share to all servers in the LAN use

Preparing the environment:
10.0.0.99 as a yum repository
10.0.0.98 use yum repository as a client
1. build a yum repository 10.0.0.99 http: // https: // ftp : // file: //

2.1. Acquaintance environment

[root@www ~]# systemctl disable firewalld      #关闭开机自动启动firewalld防火墙 
[root@www ~]# systemctl stop firewalld         #现在立即关闭firewalld防火墙 
[root@www ~]# setenforce 0                          #关闭selinux防火墙
[root@www ~]# sed -i 's#^SELINUX=.*#SELINUX=disabled#g' /etc/selinux/config    #下次不再启动selinux防火墙 

2.2. Ftp service installation and start

[root@www ~]# yum install vsftpd -y          #安装ftp服务
[root@www ~]# systemctl start vsftpd        #启动ftp服务 
[root@www ~]# systemctl status vsftpd     #查看ftp服务状态是否是active Running 

2.3. Ftp to prepare the ground for shared directories Package

[root@www ~]# mkdir /var/ftp/centos7   #提供基础base仓库 
[root@www ~]# mount /dev/cdrom /mnt/ 
[root@www ~]# find /mnt/Packages/ -type f -name "*.rpm" |xargs -I {} cp -rp {} /var/ftp/centos7/ 

2.4. To prepare ftp directory that is shared extension package (need to synchronize the public face of online software)

[root@www ~]# cd /var/ftp/ 
[root@www ~]# mkdir zabbix 
[root@www ~]# cd zabbix 
[root@www ~]# wget 下载所有的软件包,通过取值的方式 
[root@www ftp]# createrepo /var/ftp/zabbix/ 

2.5. If you need to synchronize warehouse jenkins how to do this?

wget下载      (随时,但步骤太多,而且后期的可维护性差)
rsync同步     (凌晨1-8点) 

2.6. The ftp directory corresponding generated as a yum repository

[root@www ftp]# yum install createrepo -y 
[root@www ftp]# createrepo /var/ftp/centos7/ 

2.7. The client points to and use yum inside the warehouse 10.0.0.98

[root@client yum.repos.d]# gzip * 
[root@client yum.repos.d]# cat ftp_99.repo
[FtpRepos] 
name = This is Ftp Share Repos 
baseurl = ftp://10.0.0.99/centos7/ 
enabled = 1 
gpgcheck = 0

2.8. Check the yum repository server to download packages from the public network down whether the normal use

[root@client yum.repos.d]# cat ftp_zabbix_99.repo 
[FtpZabbixRepos] 
name = This is Ftp Share Zabbix Repos
baseurl = ftp://10.0.0.99/zabbix/ 
enabled = 1 
gpgcheck = 0

Second, the public network synchronization yum warehouse

nginx + rsync source for local and public network yum yum source

1.配置nginx的autoindex模块,开启目录浏览功能
2.使用rsync同步公网源上的软件包,至本地目录中
3.配置客户端指向即可

1. Install nginx

[root@yum ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

[root@yum ~]# yum install nginx -y

2.nginx provide a directory browsing

[root@yum ~]# cat /etc/nginx/conf.d/yum.conf
server {
    listen 80;
    listen [::]:80;
    server_name mirrors.linanxi.fun;
    location / {
        root /repo;
        autoindex on; #开启目录浏览功能
    }
}

3. Synchronize packages from the warehouse to the local public network

Note that, if fully synchronous, will be particularly footprint, so we can filter unwanted packages.
rsync synchronization command (recommended to add a scheduled task)

#1.同步centos7的基础源
rsync -zaP --exclude-from /repo/exclude_7.txt rsync://rsync.mirrors.ustc.edu.cn/centos/7.6.1810/ /repo/centos

#2.同步centos7的epel源
rsync -zaP --exclude-from /repo/exclude_7_epel.txt rsync://rsync.mirrors.ustc.edu.cn/epel/7/ /repo/epel

#centos7排除的文件(保留os和extras)
[root@yum ~]# cat /repo/exclude_7.txt
atomic/
centosplus/
cloud/
configmanagement/
cr/
dotnet/
fasttrack/
isos/
nfv/
opstools/
paas/
rt/
sclo/
storage/
virt/
debug/
drpms/

#centos7_epel排除的文件(保留x86_64)
[root@yum ~]# cat /repo/exclude_7_epel.txt
SRPMS/
aarch64/
ppc64/
ppc64le/
state

4. The corresponding directory is generated as ftp repository yum

[root@yum ~]# yum install createrepo -y
[root@yum ~]# createrepo /repo/centos/
[root@yum ~]# createrepo /repo/epel/

5. Client Configuration local yum repository

[centos]
name = Local Base Repository
baseurl = http://mirrors.linanxi.fun/centos
enable = 1
gpgcheck = 0

[epel]
name = Local Epel Repository
baseurl = http://mirrors.linanxi.fun/epel
enable = 1
gpgcheck = 0

Note: If a virtual machine, you need to configure resolved in / etc / hosts: 10.0.0.222 mirrors.linanxi.fun

6. Expansion:

If you want to provide the downstream synchronization service, we can use rsync protocol to share out the directory, so that other people can also be synchronized (usually afford, after all, no money).

[root@xuliangwei ~]# cat /etc/rsyncd.conf
uid = nginx
gid = nginx
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log

ignore errors
read only = true #只提供同步,所以只读即可
list = true #允许查看列表,认证的什么的不需要配置
hosts allow = 0.0.0.0/0 #允许任何人同步

##########提供同步的模块
[centos]
path = /repo/centos
[epel]
path = /repo/epel




Guess you like

Origin www.cnblogs.com/Forever-x/p/e8a3c60420e128ebdf32103aa82c0943.html