建立本地yum源
使用环境
- 服务器处于内网,需要更新
- 网络资源紧张,节约带宽
建立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源的更多相关文章
- Centos6.5建立本地YUM源
很多情况下公司的服务器是不允许连外网的,那么安装软件的时候就很不方便了,这里就需要建立一个本地YUM源了. 文件位置:/etc/yum.repos.d/ 后缀一定是.repo结束. 下面我们搭建 ...
- createrepo 建立本地yum源
linux使用createrepo制作本地yum源 目录 linux使用createrepo制作本地yum源 安装createrepo软件包 进入本地rpm包目录 执行完后可以看到生成的repod ...
- CentOS下建立本地YUM源并自动更新
1. 尽管有很多的免费镜像提供yum源服务,但是还是有必要建立自己的yum服务器,主要出于以下几点考虑: l 网络速度:访问互联网可能比较慢 l 节省带宽:如果有大量的服务器,架设自己的yum源可以有 ...
- CentOS 6 通过DVD快速建立本地YUM源
一.将DVD光盘放入RedHat/CentOS6.X服务器/电脑光驱中 二.挂载DVD光驱到/mnt/cdrom # mkdir -p /mnt/cdrom # mount -t iso9660 /d ...
- Centos6.4建立本地yum源
https://jingyan.baidu.com/article/e9fb46e1aed8207521f7662c.html
- Linux网络安全篇,配置Yum源(一),本地Yum源
1.创建挂载目录 mkdir /mnt/cdrom 2.挂载软件源cdrom mount /dev/cdrom /mnt/cdrom/ 3.建立本地yum源资源文件夹 mkdir /usr/local ...
- 本地yum源建立
一.openstack(ocata)本地yum源的建立: 1.配置yum缓存: vi /etc/yum.conf 把yum.conf配置改为: [main] cachedir=/var/cache/y ...
- Centos6.4 本地yum源配置
由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地yum源配置. 1.首先将需要rpm库添加到系统中: 1).虚拟机中安装的lin ...
- yum_rpm(利用dvd建立本地yum库)
#wget "http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os" 建立起了index.html ...
随机推荐
- Qt 学习之路 2(7):MainWindow 简介
Qt 学习之路 2(7):MainWindow 简介 豆子 2012年8月29日 Qt 学习之路 2 29条评论 前面一篇大致介绍了 Qt 各个模块的相关内容,目的是对 Qt 框架有一个高屋建 ...
- Gradle 引入本地定制 jar 包
第 1 步:创建文件夹,拷贝 jar 包 在自己的 Gradle 项目里建立一个名为 “libs” (这个名字可以自己定义,不一定非要叫这个名字)的文件夹,把自己本地的 jar 包拷贝到这个文件夹中. ...
- PAT - 1067 试密码 (20 分)
当你试图登录某个系统却忘了密码时,系统一般只会允许你尝试有限多次,当超出允许次数时,账号就会被锁死.本题就请你实现这个小功能. 输入格式: 输入在第一行给出一个密码(长度不超过 20 的.不包含空格. ...
- linux面试题:删除一个目录下的所有文件,但保留一个指定文件
面试题:删除一个目录下的所有文件,但保留一个指定文件 解答: 假设这个目录是/xx/,里面有file1,file2,file3..file10 十个文件 [root@oldboy xx]# touch ...
- Angular JS ng-repeat 报错 Error: [ngRepeat:dupes]
ng-repeat常用情况: <div class="form-group" ng-repeat="item in items"></div& ...
- 【Java】Java中的Collections类——Java中升级版的数据结构【转】
一般来说课本上的数据结构包括数组.单链表.堆栈.树.图.我这里所指的数据结构,是一个怎么表示一个对象的问题,有时候,单单一个变量声明不堪大用,比如int,String,double甚至一维数组.二维数 ...
- CTeX里面CTRL-Space和中文输入法的冲突问题解决
我使用的是windows xp,相信下面的方法也能应用到win7等windows系统上. 我希望在CTex套件的WinEdt 6.0里使用模板自动插入内容时,想快速从上到下遍历” * “并修改. 通过 ...
- 通过navigator.userAgent判断浏览器类型
1.navigator.userAgent返回一个浏览器信息字符串. 2.用到indexOf()方法,查找字符串中是否有指定的浏览器类型. 3. if(navigator.userAgent.inde ...
- CAD安装失败怎样卸载CAD 2011?错误提示某些产品无法安装
AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...
- 3d Max 2010安装失败怎样卸载3dsmax?错误提示某些产品无法安装
AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...