300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 搭建私有yum源仓库同步阿里云yum源到本地私有yum仓库

搭建私有yum源仓库同步阿里云yum源到本地私有yum仓库

时间:2023-05-31 17:16:04

相关推荐

搭建私有yum源仓库同步阿里云yum源到本地私有yum仓库

本地私有仓库搭建步骤:

1.安装nginx

2.在本机配置阿里云yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo /repo/Centos-7.repowget -O /etc/yum.repos.d/CentOS-epel.repo /repo/epel-7.repo

##这里将阿里的第三方epel源一起进行配置

3.同步公网镜像到本地私有仓库

用repoync 命令,Reposync用于将远程yum存储库同步到本地存储库

reposync -np /data/centos/7/base/##这里同步的源文件就是上一步配置的yum源,/data/centos/7/base/ 为生成的本地yum仓库文件即rpm包所在路径

reposync

-n:只下载最新的包

-p:下载包的路径:默认为当前目录

4.将yum仓库文件即rpm包所在路径设置为 nginx发布目录

server {listen 80;server_name ;root /data/centos/7/base/; #这里是yum源存放目录 location / { autoindex on; #打开目录浏览功能autoindex_exact_size off; # off:以可读的方式显示文件大小autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时间charset utf-8,gbk; #展示中文文件名index index.html;} error_page 500 502 503 504 /50x.html;location = /50x.html {root html;} }

5.设置定时同步任务

定时脚本:yum_update.sh

#!/bin/bashecho 'Updating Aliyum Source'DATETIME=`date +%F_%T`exec > /var/log/aliyumrepo_$DATETIME.logreposync -np /data/package/centos/7/baseif [ $? -eq 0 ];thencreaterepo --update /data/centos/7/base/basecreaterepo --update /data/centos/7/base/extrascreaterepo --update /data/centos/7/base/updatescreaterepo --update /data/centos/7/base/epelecho "SUCESS: $DATETIME aliyum_yum update successful" >>/var/log/aliyumrepo_$DATETIME.logelseecho "ERROR: $DATETIME aliyum_yum update failed" >> /var/log/aliyumrepo_$DATETIME.logfi

添加定时任务:

0 3 * * 1 /bin/sh /data/crond/yum_update.sh

##每周一凌晨三点执行

##参考:

/moyuanbomo/article/details/81667006

/lldsn/p/10479493.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。