本地yum源部署,网络yum源部署

创建本地或者网络yum仓库源
mkdir /usr/share/nginx/html/yum.repo #创建存放yum包地址

yum -y install createrepo yum-utils #安装索引命令
yum -y install epel-release.noarch #nginx需要epel源
yum -y install nginx 安装nginx

vim /etc/nginx/nginx.conf
 #在location /{
 }加入
 autoindex on;              # 表示:自动在html的索引打开
    autoindex_exact_size on;   # 表示:如果有文件,则显示文件的大小
    autoindex_localtime on;    # 表示:显示更改时间,以当前系统的时间为准
#修改网页地址 
root /usr/share/nginx/html/yum.repo

systemctl enable nginx --now #启动nginx
createrepo -pdo /usr/share/nginx/html/yum.repo /usr/share/nginx/html/yum.repo #建立yum仓库服务索引

createrepo --update /usr/share/nginx/html/yum.repo   #有新rpm包更新索引

#同步官方yum源
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/ /usr/share/nginx/html/yum.repo
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /usr/share/nginx/html/yum.repo
rsync -av rsync://mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /usr/share/nginx/html/yum.repo
rsync -av --exclude=debug rsync://mirrors.ustc.edu.cn/epel/7/x86_64/ /usr/share/nginx/html/yum.repo

#也可以使用脚本自动下载更新yum源
yum -y install inotify-tools
yum -y install rsync
systemctl restart rsyncd
systemctl enable rsyncd

vim inotify.sh
#!/bin/bash
#This is rsync script on inotify.
export PATH=/bin:/usr/bin:/usr/local/bin
Desdir=rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/
Localdir=/usr/share/nginx/html/yum.repo
inotifywait -mrq --timefmt '%y-%m-%d %H:%M' --format '%T %w%f %e' --event modify,create,move,delete,attrib, $Localdir | while read line 
do
echo "$line" > /var/log/inotify.log 2>&1
/usr/bin/rsync -avz --delete --progress  $Desdir $Localdir >>/var/log/sync.log 2>&1
done &

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值