1.配置nginx的autoindex模塊,開啓目錄瀏覽功能
2.使用rsync同步公網源上的軟件包,至本地目錄中
3.配置客戶端指向便可html
1.nginx提供目錄瀏覽功能nginx
[root@xuliangwei ~]# cat /etc/nginx/conf.d/yum.conf server { listen 80; listen [::]:80; server_name mirrors.bgx.com; location / { root /repo; autoindex on; #開啓目錄瀏覽功能 }
2.從公網的倉庫同步軟件包至本地,但須要注意,若是全同步,會特別佔用空間,因此咱們能夠將不須要的軟件包進行過濾。
rsync同步命令(建議將其加入定時任務)centos
#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@oldboyedu ~]# 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@xuliangwei ~]# cat /repo/exclude_7_epel.txt SRPMS/ aarch64/ ppc64/ ppc64le/ state
3.客戶端配置本地yum倉庫bash
[centos] name = Local Base Repository baseurl = http://mirrors.bgx.com/centos enable = 1 gpgcheck = 0 [epel] name = Local Epel Repository baseurl = http://mirrors.bgx.com/epel enable = 1 gpgcheck = 0
4.擴展:若是想爲下游提供同步服務,咱們能夠使用rsync協議將目錄共享出去,讓其餘人也能夠同步(通常玩不起,畢竟沒錢)。ui
[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