阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

在Windows上搭建镜像yum站的方法(附bat脚本)

169次阅读
没有评论

共计 4082 个字符,预计需要花费 11 分钟才能阅读完成。

方法一:支持 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 的时候需要编写脚本,设置要同步的内容

 在 Windows 上搭建镜像 yum 站的方法(附 bat 脚本)

其中 centos7_base.bat 脚本内容 供大家参考:

@echo off
SETLOCAL

SET CWRSYNCHOME=%~dp0

IF NOT EXIST %CWRSYNCHOME%home\%USERNAME%\.ssh MKDIR  %CWRSYNCHOME%home\%USERNAME%\.ssh

SET 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

在 Windows 上搭建镜像 yum 站的方法(附 bat 脚本)

修改环境变量

右键计算机 -> 属性 -> 高级系统设置 -> 环境变量 -> 系统变量  GNU_HOME=D:\GnuWin32\bin

在 Windows 上搭建镜像 yum 站的方法(附 bat 脚本)

添加 path 变量,在 cmd 中可以使用 wget 命令。PATH=;%GNU_HOME%

在 Windows 上搭建镜像 yum 站的方法(附 bat 脚本)

c:\>wget -V
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = D:\GnuWin32/etc/wgetrc
GNU Wget 1.11.4

Copyright (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;
        }
    }
}

最后使用浏览器访问

在 Windows 上搭建镜像 yum 站的方法(附 bat 脚本)

在 linux 服务器中设置解析

[root@m01 ~]# cat /etc/hosts
127.0.0.1    localhost localhost.localdomain localhost4 localhost4.localdomain4
::1          localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.1     mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com

附件:

cwrsync + 全部 bat 脚本 与 nginx + 配置文件 可以到 Linux 公社资源站下载:

—————————————— 分割线 ——————————————

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是 www.linuxidc.com

具体下载目录在 /2017 年资料 /11 月 /21 日 / 在 Windows 上搭建镜像 yum 站的方法(附 bat 脚本)/

下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm

—————————————— 分割线 ——————————————

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-11/148766.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计4082字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中