使用环境
  • 服务器处于内网,需要更新
  • 网络资源紧张,节约带宽
建立yum目录
mkdir -p /opt/opmgmt/yum
rsync服务器列表
同步脚本

/opt/opmgmt/yum/rsync_centos.sh

#!/bin/bash
repo_root='/opt/opmgmt/yum/centos/'
sync_cmd='rsync -arv --delete-after --delete-excluded'
sync_srv='rsync://mirrors.shu.edu.cn/centos/'
exclude='--exclude [23456]/ --exclude [2345]\.*/ --exclude i386/ --exclude drpms/ --exclude SCL/ --exclude centosplus/ --exclude contrib/ --exclude cr/ --exclude fasttrack/ --exclude isos/ --exclude virt/ --exclude paas/ --exclude 7.[012]*/ --exclude atomic/ --exclude cloud/ --exclude storage/' [ -d $repo_root ] && mkdir -p $repo_root
$sync_cmd $exclude $sync_srv $repo_root &

/opt/opmgmt/yum/rsync_epel.sh

#!/bin/bash
repo_root='/opt/opmgmt/yum/epel/'
sync_cmd='rsync -arv --delete-after --delete-excluded'
sync_srv='rsync://mirrors.shu.edu.cn/epel/'
exclude='--exclude [45]*/ --exclude testing/ --exclude SRPMS/ --exclude i386/ --exclude ppc64*/ --exclude aarch64/ --exclude debug/ --exclude=repoview' [ -d $repo_root ] && mkdir -p $repo_root
$sync_cmd $exclude $sync_srv $repo_root &
cd yum
rsync -avzRHP --delete-after --exclude={'debug/','drpms/'} rsync://hkg.mirror.rackspace.com/epel/7/x86_64/ epel/
rsync -avzRHP --delete-after --exclude={'atomic/','cr/','dotnet/','fasttrack/','isos/','nfv/','opstools/','rt/'} rsync://hkg.mirror.rackspace.com/centos/7/ centos/
计划任务

/etc/cron.d/sync-yum-repo

0 1 * * * root /bin/sh /opt/opmgmt/yum/rsync_centos.sh
0 2 * * * root /bin/sh /opt/opmgmt/yum/rsync_epel.sh
自定义源
yum install createrepo
mkdir -p /opt/opmgmt/yum/custom/x86_64
copy *rpm /opt/opmgmt/yum/custom/x86_64
createrepo -p -d --update /opt/opmgmt/yum/custom/x86_64
nginx服务配置

/etc/nginx/conf.d/yum.conf

server {
listen 192.168.0.100:80;
server_name yum.localhost; #allow 10.0.1.0/24;
#deny all; charset utf-8;
access_log /var/log/nginx/$server_name.access.log main; location / {
root /opt/www/yum;
index index.html index.htm;
} error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
repo文件

/opt/opmgmt/yum/repo/centos.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://yum.localhost/centos/$releasever/os/$basearch
gpgcheck=0
enabled=1
priority=1 [updates]
name=CentOS-$releasever - Updates
baseurl=http://yum.localhost/centos/$releasever/updates/$basearch
gpgcheck=0
enabled=1
priority=1 [extras]
name=CentOS-$releasever - Extras
baseurl=http://yum.localhost/centos/$releasever/extras/$basearch
gpgcheck=0
enabled=1
priority=1 [centos-sclo-sclo]
name=CentOS-$releasever - SCLo sclo
baseurl=http://yum.localhost/centos/$releasever/sclo/$basearch/sclo
gpgcheck=0
enabled=1
priority=2 [centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=http://yum.localhost/centos/$releasever/sclo/$basearch/rh
gpgcheck=0
enabled=1
priority=2

另外一种方法

yum install yum-utils
reopsync

建立本地yum源的更多相关文章

  1. Centos6.5建立本地YUM源

    很多情况下公司的服务器是不允许连外网的,那么安装软件的时候就很不方便了,这里就需要建立一个本地YUM源了. 文件位置:/etc/yum.repos.d/    后缀一定是.repo结束. 下面我们搭建 ...

  2. createrepo 建立本地yum源

    linux使用createrepo制作本地yum源   目录 linux使用createrepo制作本地yum源 安装createrepo软件包 进入本地rpm包目录 执行完后可以看到生成的repod ...

  3. CentOS下建立本地YUM源并自动更新

    1. 尽管有很多的免费镜像提供yum源服务,但是还是有必要建立自己的yum服务器,主要出于以下几点考虑: l 网络速度:访问互联网可能比较慢 l 节省带宽:如果有大量的服务器,架设自己的yum源可以有 ...

  4. CentOS 6 通过DVD快速建立本地YUM源

    一.将DVD光盘放入RedHat/CentOS6.X服务器/电脑光驱中 二.挂载DVD光驱到/mnt/cdrom # mkdir -p /mnt/cdrom # mount -t iso9660 /d ...

  5. Centos6.4建立本地yum源

    https://jingyan.baidu.com/article/e9fb46e1aed8207521f7662c.html

  6. Linux网络安全篇,配置Yum源(一),本地Yum源

    1.创建挂载目录 mkdir /mnt/cdrom 2.挂载软件源cdrom mount /dev/cdrom /mnt/cdrom/ 3.建立本地yum源资源文件夹 mkdir /usr/local ...

  7. 本地yum源建立

    一.openstack(ocata)本地yum源的建立: 1.配置yum缓存: vi /etc/yum.conf 把yum.conf配置改为: [main] cachedir=/var/cache/y ...

  8. Centos6.4 本地yum源配置

    由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地yum源配置. 1.首先将需要rpm库添加到系统中: 1).虚拟机中安装的lin ...

  9. yum_rpm(利用dvd建立本地yum库)

    #wget "http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os" 建立起了index.html ...

随机推荐

  1. PAT天梯赛L1-020 帅到没朋友

    题目链接:点击打开链接 当芸芸众生忙着在朋友圈中发照片的时候,总有一些人因为太帅而没有朋友.本题就要求你找出那些帅到没有朋友的人. 输入格式: 输入第一行给出一个正整数N(<=100),是已知朋 ...

  2. [Unity3D]Unity3D游戏开发之怪物AI

    大家好.欢迎大家关注由我为大家带来的Unity3D游戏开发系列文章,我的博客地址为:http://blog.csdn.net/qinyuanpei.        在上一篇文章中,我们基本上实现了一个 ...

  3. Exadata X7来了

    1.Exadata Brings In-Memory OLTP to Storage Exadata Storage Servers add a memory cache in front of Fl ...

  4. inner join、left join、right join、full join

    A表 a1 b1 c1 01 数学 95 02 语文 90 03 英语 80  B表 a2 b2 01 张三 02 李四 04 王五 SQL语句:select A.*,B.* from A inner ...

  5. Django之ORM其他骚操作 执行原生SQl

      Django ORM执行原生SQL # extra # 在QuerySet的基础上继续执行子语句 # extra(self, select=None, where=None, params=Non ...

  6. 页面布局常用,让子级div排排坐

    画页面的时候经常遇到页面布局的问题,父级div包裹多个子div很常见,代码如下: <div> <div style='width:100px;height: 100px;backgr ...

  7. C语言标准库函数memcpy和memmove的区别以及内存重叠问题处理

    ①memcpy()和memmove()都是C语言中的标准库函数,定义在头文件string.h中,作用是拷贝一定长度的内存的内容,原型分别如下: void *memcpy(void *dst, cons ...

  8. 缓存方案:本地guavaCache, 远程redis?

    线程内部缓存:a. 局部变量HashMap, 方法间传递  b. 使用ThreadLocal 本地缓存:单jvm内共享 可以使用(Concurrent)HashMap自己实现,也可以使用GuavaCa ...

  9. (转)Caffe搭建:常见问题解决办法和ubuntu使用中遇到问题(持续更新)

    参考网址:http://www.cnblogs.com/empty16/p/4828476.html 严正声明: 在linux下面使用命令行操作时,一定要懂得命令行的意思,然后再执行,要不然在不知道接 ...

  10. java——io、字节流缓冲区拷贝文件、字节缓冲流

    使用try catch finally关闭文件流: 写入文件: import java.io.*; public class exp{ public static void main(String[] ...