建立本地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 ...
随机推荐
- spring cloud 超时时间
zuul.host.socket-timeout-millis=60000 #zuul socket连接超时zuul.host.connect-timeout-millis=60000 #zull 请 ...
- error : Could not load UI satellite dll 'TrackerUI.dll'. Make sure it exists in an LCID subdirectory of 'C:\Program Files (x86)\MSBuild\12.0\bin\'.
原因 VS2013 + QT环境部署好后, 又安装了VS2015\ 解决方案: 在另一台电脑里重装VS2013, 并将 C:\Program Files (x86)\MSBuild\12.0\B ...
- [PowerShell]template engine
今天讨论的是如何在Powershell里实现一个简单的Template Engine的功能. 假设模板文件的内容如下:template.tt hello $name welcome $company ...
- case when null then 'xx' else 'yy' end 无效
Sql Server 中使用case when then 判断某字段是否为null,和判断是否为字符或数字时的写法不一样,而且语法能正常执行, 如果不注意数据内容,很容易搞错. 错误方法: CASE ...
- MERGE批量增删查改数据
MERGE优点: 在批量处理数据的时候,我可以用到merge一次完成数据处理. 示例代码一: MERGE INTO student AS t using ( AS age) s ON t.Age=s. ...
- nc工具详解
nc 安装 yum install -y nc参数: Command Summary: - Use IPv4 - Use IPv6 -D Enable the debug socket opti ...
- yii1的后台分页和列表
控制器: public function actionIndex(){ $model = new Cases('search'); $model->unsetAttributes(); // c ...
- linux的shell脚本
一.遇到的问题: 1.在Documents/shell_Document的文件夹下创建第一个脚本. 但是发现在图形化界面不能执行shell脚本.只能到命令行模式下才能执行.感觉太麻烦,我的虚拟机从图形 ...
- Mac 终端执行sql命令
https://www.cnblogs.com/sbj-dawn/p/6905930.html. 远程登录MYSQL数据库 > mysql -u username -p -h hostname ...
- 2019.03.21 读书笔记 基元类型的Parse与TryParse 性能与建议
Parse转换失败时会抛出异常,耗损性能,如果转换成功,则与TryParse无差异.查看源码,tryparse的代码更多一些,在失败时,反而性能更优,主要是抛出异常耗损了性能.所以在不确定是用Tryp ...