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

 
 

方法一:支持rsync的网站

对于常用的centos、Ubuntu、等使用官方yum源在 http://mirrors.ustc.edu.cn 都存在镜像。

  同时 http://mirrors.ustc.edu.cn 网站又支持 rsync 协议, 可以通过rsync实现 镜像yum源。

  1. _______________________________________________________________
  2. | University of Science and Technology of China |
  3. | Open Source Mirror (mirrors.ustc.edu.cn) |
  4. |===============================================================|
  5. | |
  6. | Debian primary mirror in China mainland (ftp.cn.debian.org), |
  7. | also mirroring a great many OSS projects & Linux distros. |
  8. | |
  9. | Currently we don't limit speed. To prevent overload, Each IP |
  10. | is only allowed to start upto 2 concurrent rsync connections. |
  11. | |
  12. | This site also provides http/https/ftp access. |
  13. | |
  14. | Supported by USTC Network Information Center |
  15. | and USTC Linux User Group (http://lug.ustc.edu.cn/). |
  16. | |
  17. | Sync Status: https://mirrors.ustc.edu.cn/status/ |
  18. | News: https://servers.ustclug.org/ |
  19. | Contact: lug@ustc.edu.cn |
  20. | |
  21. |_______________________________________________________________|

在windows上使用rsync需要用到 cwRsync  下载地址是 https://www.itefix.net/dl/cwRsync_5.5.0_x86_Free.zip;

  其官网为 https://www.itefix.net/cwrsync

使用rsync的时候需要编写脚本,设置要同步的内容

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

  1. @echo off
  2. SETLOCAL
  3.  
  4. SET CWRSYNCHOME=%~dp0
  5.  
  6. IF NOT EXIST %CWRSYNCHOME%home\%USERNAME%\.ssh MKDIR %CWRSYNCHOME%home\%USERNAME%\.ssh
  7.  
  8. SET CWOLDPATH=%PATH%
  9.  
  10. SET PATH=%CWRSYNCHOME%bin;%PATH%
  11.  
  12. 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协议的源

  1. 由于线上跑的系统还有CentOS5.46.46.56.56.66.8,而各镜像站维护的最早的版本已经是6.9,所以需要爬archive站点的rpm包来自建yum仓库。
  2.  
  3. # wget -r -p -np -k http://archives.fedoraproject.org/pub/archive/epel/5Server/x86_64/
  4.  
  5. # wget -r -p -np -k http://archives.fedoraproject.org/pub/epel/6Server/x86_64/
  6.  
  7. -c, --continue resume getting a partially-downloaded file. 断点续传
  8. -nd, --no-directories don't create directories. 不创建层级目录,所有文件下载到当前目录
  9. -r, --recursive specify recursive download. 递归下载
  10. -p, --page-requisites get all images, etc. needed to display HTML page.
  11. 下载页面所有文件,使页面能在本地打开
  12. -k, --convert-links make links in downloaded HTML or CSS point to local files.
  13. 转换链接指向本地文件
  14. -np, --no-parent don't ascend to the parent directory. 不下载父级目录的文件
  15. -o, --output-file=FILE log messages to FILE. 指定日志输出文件
  16. -O, --output-document=FILE write documents to FILE. 指定文件下载位置
  17. -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%

    

  1. c:\>wget -V
  2. SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  3. syswgetrc = D:\GnuWin32/etc/wgetrc
  4. GNU Wget 1.11.4
  5.  
  6. Copyright (C) 2008 Free Software Foundation, Inc.
  7. License GPLv3+: GNU GPL version 3 or later
  8. <http://www.gnu.org/licenses/gpl.html>.
  9. This is free software: you are free to change and redistribute it.
  10. There is NO WARRANTY, to the extent permitted by law.
  11.  
  12. 最初由 Hrvoje Niksic <hniksic@xemacs.org> 编写。
  13. Currently maintained by Micah Cowan <micah@cowan.name>.

提供web服务

同时提供web服务需要用到nginx

  nginx 下载 页面 http://nginx.org/en/download.html

附:nginx 配置文件

  1. worker_processes 1;
  2.  
  3. events {
  4. worker_connections 1024;
  5. }
  6.  
  7. http {
  8. include mime.types;
  9. default_type application/octet-stream;
  10. sendfile on;
  11. keepalive_timeout 65;
  12. server {
  13. listen 80;
  14. server_name localhost;
  15. location / {
  16. autoindex on;
  17. root html;
  18. index index.html index.htm;
  19. }
  20. }
  21. server {
  22. listen 80;
  23. server_name repo.zabbix.com;
  24. location / {
  25. autoindex on;
  26. root html/zabbix;
  27. index index.html index.htm;
  28. }
  29. }
  30. server {
  31. listen 80;
  32. server_name sp.repo.webtatic.com mirror.webtatic.com;
  33. location / {
  34. autoindex on;
  35. root html/webtatic;
  36. index index.html index.htm;
  37. }
  38. }
  39. }

最后使用浏览器访问

  

在linux服务器中设置解析

  1. [root@m01 ~]# cat /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 10.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命令使用

              此文章出自惨绿少年,转载请注明   

在windows上搭建镜像yum站的方法的更多相关文章

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

    方法一:支持rsync的网站 对于常用的centos.Ubuntu.等使用官方yum源在 http://mirrors.ustc.edu.cn 都存在镜像. 同时 http://mirrors.ust ...

  2. 在linux上搭建本地yum源

    准备yum仓库的光盘镜像IOS文件: 设置光驱加载本地磁盘的yum仓库的光盘镜像文件: 在linux的命令行输入setup命令打开设置窗口,选择"System Service": ...

  3. 如何在Windows上搭建Android开发环境

    Android开发越来越火,许多小伙伴们纷纷学习Android开发,学习Android开发首要任务是搭建Android开发环境,由于大家 主要实在Windows 上开发Android,下面就详细给大家 ...

  4. 在Windows上搭建PhoneGAP(crodova)的开发环境

    PhoneGAP是一个可以将web应用打包成移动应用的开源框架,使用它可以迅速的将HTML.CSS和JavaScript开发的web应用打包成跨平台的移动应用程序,而Apache Cordova是Ph ...

  5. Windows上搭建远程访问服务

    Windows上搭建远程访问服务 转自:https://blog.51cto.com/13871378/2153308?source=dra 概述:允许客户机通过拨号连接或虚拟专用网连接到公司局域网, ...

  6. 在windows上搭建git server Gitblit

    在Windows上搭建Git Server   第1步:下载Java并安装Java.我这里下载的是jdk1.7.0_79 第2步:配置Java环境变量 右键” 计算机” => ”属性” => ...

  7. Windows上搭建Flume运行环境

    1.如果没有安装过Java环境,则需首先安装JDK. 可参考<Windows上搭建Kafka运行环境>中的搭建环境安装JDK部分 2.官方下载Flume(当前为apache-flume-1 ...

  8. (转)Windows上搭建Kafka运行环境

    转自:<Windows上搭建Kafka运行环境> 完整解决方案请参考: Setting Up and Running Apache Kafka on Windows OS   在环境搭建过 ...

  9. [转]Windows上搭建Kafka运行环境

    [转]http://www.cnblogs.com/alvingofast/p/kafka_deployment_on_windows.html Windows上搭建Kafka运行环境   完整解决方 ...

随机推荐

  1. Word中图片自动编号且与文中引用的编号对应

    当我们在进行大篇幅 word 文档的编写时, 为了节约修改文章中图片所花费的大量时间, 可以将图片自动编号,且让文中引用的顺序跟着图片顺序的变化而变化,具体操作如下: 1. 将鼠标定在欲加编号的下方, ...

  2. 跨域和jsonp的了解和学习

    一.为什么会有跨域问题呢 因为有浏览器的同源策略. 同源:如果两个页面的协议,端口(如果有指定)和主机都相同,则两个页面具有相同的源.我们也可以把它称为“协议/主机/端口 tuple”,或简单地叫做“ ...

  3. LeetCode 583 Delete Operation for Two Strings 删除两个字符串的不同部分使两个字符串相同,求删除的步数

    Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 t ...

  4. TortoiseSVN 搭建本地版本库及简单操作使用

    TortoiseSVN是windows上一款著名的版本控制软件,对于我们管理自己的代码,特别是对一个团队来说,非常重要. 本文探讨的是如何搭建本地的版本库. (1)安装TortoiseSVN之后需要创 ...

  5. 宋宝华:swappiness=0究竟意味着什么?

    http://mp.weixin.qq.com/s/BixMISiPz3sR9FDNfVSJ6w 本文解释swappiness的作用,以及swappiness=0究竟意味着什么. 内存回收 我们都知道 ...

  6. python socket客户端

    #./usr/bin/env python#coding:utf-8import socket#.....ip...print ('server start...')ip_port = ('144.3 ...

  7. [荐]推荐一个shell学习的网站

    最近再用shell脚本,发现一个脚本学习的网站,非常好用,特此推荐一下. shell学习网站链接:http://c.biancheng.net/cpp/shell/

  8. oracle最高账号sys的密码认证模式

    CONNECT USERNAME/PASSWORD@SERVERNAME AS SYSDBAconnect 是指连接到username是指用户名password是指密码servername是指服务名a ...

  9. zabbix 监控项

    监控项 概述 监控项是从主机收集的数据信息. 配置主机后,你需要添加一些监控项以开始获取实际数据. 一个监控项是一个独立的指标.快速添加多个监控项的一种方法是将一个预定义的模板附加到主机.然而,为了优 ...

  10. jQuery-安装方法(2类)

    一.下载到本地,调用本地jQuery库 下载地址:http://jquery.com/download/ 共有两个版本的 jQuery 可供下载: 1.精简版:用于实际的网站中,已被精简和压缩. 2. ...