在windows上搭建鏡像yum站的方法(附bat指令碼),yumbat
方法一:支援rsync的網站
對於常用的centos、Ubuntu、等使用官方yum源在 http://mirrors.ustc.edu.cn 都存在鏡像。
同時 http://mirrors.ustc.edu.cn 網站又支援 rsync 協議, 可以通過rsync實現 鏡像yum源。
_______________________________________________________________| University of Science and Technology of China || Open Source Mirror (mirrors.ustc.edu.cn) ||===============================================================|| || Debian primary mirror in China mainland (ftp.cn.debian.org), || also mirroring a great many OSS projects & Linux distros. || || Currently we don't limit speed. To prevent overload, Each IP || is only allowed to start upto 2 concurrent rsync connections. || || This site also provides http/https/ftp access. || || Supported by USTC Network Information Center || and USTC Linux User Group (http://lug.ustc.edu.cn/). || || Sync Status: https://mirrors.ustc.edu.cn/status/ || News: https://servers.ustclug.org/ || Contact: lug@ustc.edu.cn || ||_______________________________________________________________|
在windows上使用rsync需要用到 cwRsync 是 https://www.itefix.net/dl/cwRsync_5.5.0_x86_Free.zip;
其官網為 https://www.itefix.net/cwrsync
使用rsync的時候需要編寫指令碼,設定要同步的內容
其中centos7_base.bat指令碼內容 供大家參考:
@echo offSETLOCALSET CWRSYNCHOME=%~dp0IF NOT EXIST %CWRSYNCHOME%home\%USERNAME%\.ssh MKDIR %CWRSYNCHOME%home\%USERNAME%\.sshSET CWOLDPATH=%PATH%SET PATH=%CWRSYNCHOME%bin;%PATH%rsync -av --delete rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/ /cygdrive/f/yum/nginx/html/centos/7/os/x86_64/
方法二:使用wget命令下載不支援rsync協議的源
由於線上跑的系統還有CentOS5.4、6.4、6.5、6.5、6.6、6.8,而各鏡像站維護的最早的版本已經是6.9,所以需要爬archive網站的rpm包來自建yum倉庫。# wget -r -p -np -k http://archives.fedoraproject.org/pub/archive/epel/5Server/x86_64/# wget -r -p -np -k http://archives.fedoraproject.org/pub/epel/6Server/x86_64/-c, --continue resume getting a partially-downloaded file. 斷點續傳-nd, --no-directories don't create directories. 不建立層級目錄,所有檔案下載到目前的目錄-r, --recursive specify recursive download. 遞迴下載-p, --page-requisites get all images, etc. needed to display HTML page.下載頁面所有檔案,使頁面能在本地開啟-k, --convert-links make links in downloaded HTML or CSS point to local files.轉換連結指向本地檔案-np, --no-parent don't ascend to the parent directory. 不下載父級目錄的檔案-o, --output-file=FILE log messages to FILE. 指定日誌輸出檔案-O, --output-document=FILE write documents to FILE. 指定檔案下載位置-L, --relative follow relative links only. 只下載相對連結,如果頁面嵌入其他網站不會被下載
windows上wget命令使用方法
下載:http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe
官網:http://gnuwin32.sourceforge.net/packages/wget.htm
安裝
雙擊即可安裝,安裝到目錄:D:\GnuWin32
修改環境變數
右鍵電腦 -> 屬性 -> 進階系統設定 -> 環境變數 -> 系統變數 GNU_HOME=D:\GnuWin32\bin
添加path變數,在cmd中可以使用wget命令。 PATH=;%GNU_HOME%
c:\>wget -VSYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrcsyswgetrc = D:\GnuWin32/etc/wgetrcGNU Wget 1.11.4Copyright (C) 2008 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later<http://www.gnu.org/licenses/gpl.html>.This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.最初由 Hrvoje Niksic <hniksic@xemacs.org> 編寫。Currently maintained by Micah Cowan <micah@cowan.name>.
提供web服務
同時提供web服務需要用到nginx
nginx 下載 頁面 http://nginx.org/en/download.html
附:nginx 設定檔
worker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { autoindex on; root html; index index.html index.htm; } } server { listen 80; server_name repo.zabbix.com; location / { autoindex on; root html/zabbix; index index.html index.htm; } } server { listen 80; server_name sp.repo.webtatic.com mirror.webtatic.com; location / { autoindex on; root html/webtatic; index index.html index.htm; } }}最後使用瀏覽器訪問
在linux伺服器中設定解析
[root@m01 ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain610.0.0.1 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com
附件:
附件1、 cwrsync + 全部 bat 指令碼 https://files.cnblogs.com/files/clsn/cwRsync.rar
附件2、 nginx + 設定檔 https://files.cnblogs.com/files/clsn/nginx.zip
特別感謝:國強哥提供wget命令使用
此文章出自慘綠少年,轉載請註明