其他综合-CentOS 7 rsync+nginx实现公网yum源
CentOS 7 rsync+nginx实现公网yum源
1、实验描述
镜像同步公网 yum 源上游 yum 源必须要支持 rsync 协议,否则不能使用 rsync 进行同步。CentOS 7.6 默认已经安装了,当然,还需要能够上网才行。这里同步的是 6.10 和 7.6.1810,所以,虚拟机硬盘要给100G左右。
2、实验环境
【你可能需要】【CentOS 7 搭建模板机】点我快速打开文章
【你可能需要】【VMware 从模板机快速克隆多台】点我快速打开文章
【你可能需要】【CentOS 7 命令行显示优化】点我快速打开文章
【你可看需要】【CentOS 7 配置yum源】点我快速打开文章
虚拟机:
- 系统:CenOS 7.6
- 内存:2G+
- 数量:2台
- 硬盘:100G+
使用软件的版本:
VMware 15 Pro

3、实验工具
【VMware12&15】【001-VMware 12&15】点我快速打开分享(若异常,请私信,万分感谢) 【提取码:0rb9 】
【CentOS7.6】【002-CentOS 7.6】点我快速打开分享(若异常,请私信,万分感谢) 【提取码:9tri 】
4、实验步骤
【公网源官方地址】点我快速打开文章



4.1 安装nginx服务
1. 配置官方源
echo '[nginx]
name=Nginx repo by MineGi
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1' >/etc/yum.repos.d/nginx.repo
cat /etc/yum.repos.d/nginx.repo


2. 安装与配置
yum install -y nginx &>/dev/null
echo $?
IP=$(ip a|awk -F '[ /]+' '$NF~/eth0/ {print $3}')
cat >/etc/nginx/conf.d/yum.conf <<EOF
server {
listen 80;
listen [::]:80;
server_name $IP;
location / {
root /usr/share/nginx/html;
autoindex on;
}
}
EOF
cat /etc/nginx/conf.d/yum.conf
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default


3. 启动自启动
nginx -t
systemctl enable nginx
systemctl start nginx
netstat -lntup|grep -c nginx


4.2 同步公网yum源
1. 创建排除文件
cat >/root/.rsync_exclude.txt <<EOF
centosplus/
cloud/
contrib/
cr/
fasttrack/
isos/
sclo/
storage/
virt/
i386/
debug/
drpms/
EOF
cat /root/.rsync_exclude.txt
cat >/root/.rsync_exclude2.txt <<EOF
atomic/
centosplus/
cloud/
configmanagement/
cr/
dotnet/
fasttrack/
isos/
nfv/
opstools/
paas/
rt/
sclo/
storage/
virt/
debug/
drpms/
EOF
cat /root/.rsync_exclude2.txt


2. 手动执行
/usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude2.txt \
rsync://rsync.mirrors.ustc.edu.cn/centos/7.6.1810 /usr/share/nginx/html/centos
/usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt \
rsync://rsync.mirrors.ustc.edu.cn/centos/6.10 /usr/share/nginx/html/centos
/usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt \
rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64 /usr/share/nginx/html/epel/7/
/usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt \
rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64 /usr/share/nginx/html/epel/6/
/usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude2.txt \
rsync://rsync.mirrors.ustc.edu.cn/centos/7 /usr/share/nginx/html/centos
/usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt \
rsync://rsync.mirrors.ustc.edu.cn/centos/6 /usr/share/nginx/html/centos
由于需要时间很长,我只演示第一条,提示,后面两条是做软连接的。


由于网络原因,可能失败,多试几次即可

3. 定时任务
crontab -e
30 21 * * * /usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude2.txt rsync://rsync.mirrors.ustc.edu.cn/centos/7.6.1810 /usr/share/nginx/html/centos &>/dev/null
00 22 * * * /usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt rsync://rsync.mirrors.ustc.edu.cn/centos/6.10 /usr/share/nginx/html/centos &>/dev/null
00 21 * * * /usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64 /usr/share/nginx/html/epel/7/ &>/dev/null
30 20 * * * /usr/bin/rsync -zaP --exclude-from /root/.rsync_exclude.txt rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64 /usr/share/nginx/html/epel/6/ &>/dev/null
crontab -l


4. 验证结果
1. 文件
rm -f /usr/share/nginx/html/*.html
cd /usr/share/nginx/html/ && ls
du -smh centos epel
cd centos && ll


2. 结果
在其它局域网机器进行测试
curl -s -o /etc/yum.repos.d/CentOS-Base.repo \
http://mirrors.aliyun.com/repo/Centos-7.repo
curl -s -o /etc/yum.repos.d/epel.repo \
http://mirrors.aliyun.com/repo/epel-7.repo
echo '10.0.0.10 mirrors.aliyun.com' >>/etc/hosts
tail -1 /etc/hosts
rpm -e --nodeps bc
rpm -qa bc
yum install -y bc &>/dev/null
rpm -qa bc


4.3 开启下游同步
cat >/etc/rsyncd.conf <<EOF
#rsync server
uid = nginx
gid = nginx
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = true
list = true
hosts allow = 0.0.0.0/0
[centos]
path = /usr/share/nginx/html/centos
[epel]
path = /usr/share/nginx/html/epel
EOF
cat /etc/rsyncd.conf


【本文图片下载地址】【021-公网yum】点我快速打开分享(若异常,请私信,万分感谢) 【提取码:nu5c 】
今天你学习了吗?若有疑问,请留言、私信或加QQ群:647033350,大家一起进步吧!
其他综合-CentOS 7 rsync+nginx实现公网yum源的更多相关文章
- rsync同步公网yum源搭建本地yum仓库
镜像同步公网yum源上游yum源必须要支持rsync协议,否则不能使用rsync进行同步. centos源:rsync://rsync.mirrors.ustc.edu.cn/centos/ epel ...
- CentOS 5/6.X 使用 EPEL YUM源
参考:http://www.linuxidc.com/Linux/2013-08/88523.htm 大纲 一.什么是EPEL? 二.与163 YUM源比较 三.CentOS 5.X 安装使用EPEL ...
- Centos 6.5将光盘作为yum源的设置方法
Centos 6.5将光盘作为yum源的设置方法 在使用Centos 的时候,用yum来安装软件包是再方便不过了,但是如果在无法连接互联网的情况下,yum就不好用了. 下面介绍一种方式,就是将Cent ...
- nginx+rsync实现本地yum源以及公网yum源
1.配置nginx的autoindex模块,开启目录浏览功能 2.使用rsync同步公网源上的软件包,至本地目录中 3.配置客户端指向即可 1.nginx提供目录浏览功能 [root@xuliangw ...
- CentOS配置Nginx官方的Yum源
由于yum源中没有我们想要的nginx,那么我们就需要创建一个"/etc/yum.repos.d/nginx.repo"的文件,其实就是新增一个yum源. [root@niaoyu ...
- 【nginx】利用yum源安装nginx
先安装nginx的yum源 http://nginx.org/en/linux_packages.html#stable 找到链接,安装: rpm -ivh http://nginx.org/pack ...
- 配置nginx官网yum源
由于yum源中没有我们想要的nginx,那么我们就需要创建一个“/etc/yum.repos.d/nginx.repo”的文件,其实就是新增一个yum源 二.添加nginx.repo 文件: [roo ...
- Centos 6.0将光盘作为yum源的设置方法
在使用Centos 的时候,用yum来安装软件包是再方便不过了,但是如果在无法连接互联网的情况下,yum就不好用了. 下面介绍一种方式,就是将Centos安装光盘作为yum源,然后使用yum来安装软件 ...
- Centos 6.5 搭建阿里云yum源
Linux系统下yum源配置(Centos 6) 1.备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo ...
随机推荐
- day49_9_10jQuery剩余
一.表单筛选器. 在jQuery中有,专门对表单中的元素,进行筛选的表单筛选器. 其实使用基本筛选器也可以筛选出相应的元素,但是,为了jQuery的简便性,以及对表单操作的频繁,这里可以使用专门的筛选 ...
- session.invalidate() 退出登录
当浏览器第一次请求时,服务器创建一个session对象,同时生成一个sessionId,并在此次响应中将sessionId 以响应报文的方式传回客户端浏览器内存或以重写url方式送回客户端,来保持整个 ...
- CentOs篇
Advanced-高级配置.Security-安全.Boot-启动引导: 1.Removable Devices-移动设备 2.Hard Drive-本地硬盘 3.CD-ROM- Drive-光盘 4 ...
- (day53)五、模型层(ORM)、settings文件配置
目录 一.settings配置 (一)测试文件配置 (二)查看对应sql语句 二.模型表数据的增删改查 (一)创建数据 (1)create方法 (2)利用对象的绑定方法 (二)修改数据 (1)利用qu ...
- 大宗商品交易与风险管理(CTRM)软件产品介绍
https://mp.weixin.qq.com/s/grA8MhryPfDB2PmBqsao4Q 从全球范围来看,大宗商品行业风险管理领域的主流软件产品是CTRM系列.CTRM是Commodity ...
- github 入门教程之 github 访问速度太慢怎么办
github 是全世界最流行的开源项目托管平台,其代表的开源文化从根本上改变了软件开发的方式. 基本上所有的需求都能从 github 上或多或少找到现成的实现方案,再也不用重头开始造轮子而是自定义轮子 ...
- Python 栈(stack)
Python 栈(stack) 栈(stack)又名堆栈,它是一种运算受限的线性表 栈只能在一端进行插入和删除操作,它按照先进后出(FILO)的原则存储数据,先进入的数据被压入栈底,最后的数据在栈顶 ...
- Educational Codeforces Round 78 (Rated for Div. 2) 题解
Shuffle Hashing A and B Berry Jam Segment Tree Tests for problem D Cards Shuffle Hashing \[ Time Lim ...
- talk 64
dGhpcyBpcyBhIGV4YW1wbGUKYmIxMjMxMjNACgoxNjMKCmFhMzA2MzA2
- CF-378 B.Semifinals
题目意思:有n个参赛者,他们都需要参加两场半决赛.第一场半决赛的成绩依次是a1, a2, ..., an,分别对应第1-第n个人的成绩.第二场则是b1, b2, ..., bn.其中这两个序列都是以递 ...