设为首页 加入收藏

TOP

centos7自建yum仓库同步阿里云yum源
2023-07-23 13:39:51 】 浏览:27
Tags:centos7 自建 yum 步阿里

背景:内网环境服务器不能直接安装工具或服务,可以用一台外网服务器同步阿里云的yum仓库,作为本地仓库

搭建本地yum仓库

编辑yum配置文件,开启缓存使用功能,设置缓存路径

cp /etc/yum.conf /etc/yum.conf.bak

vim /etc/yum.conf

cachedir=/yum/$basearch/$releasever
keepcache=1

安装创建yum源索引工具

 yum -y install createrepo

创建yum源索引,索引路径即安装包文件路径

createrepo -v /yum

配置nginx,发布yum仓库

vim  /usr/local/nginx/conf/conf.d/yumrepo.conf
server {
   listen 8090;
   server_name 10.252.90.40;
   location / {
     root /data/yum/epel/;
     autoindex on; ##开 启 目 录  
     index index.html index.htm;
    }
}

同步阿里云yum源,每周更新

[root@node40 ~]# crontab -l
0 3 * * 1 /bin/bash /root/yum_repo_update.sh
[root@node40 ~]# cat /root/yum_repo_update.sh
#!/bin/bash
echo 'Updating Aliyum Source'
DATETIME=`date +%Y-%m-%d`
exec > /var/log/aliyumrepo_$DATETIME.log
reposync -np /yum/
if [ $? -eq 0 ];then
createrepo --update /yum/base
createrepo --update /yum/extras
createrepo --update /yum/updates
createrepo --update /yum/epel
echo "SUCESS: $DATETIME aliyum_yum update successful" >>/var/log/aliyumrepo_$DATETIME.log
else
echo "ERROR: $DATETIME aliyum_yum update failed" >> /var/log/aliyumrepo_$DATETIME.log
fi

客户端配置

编辑yum源地址

 
[root@node40 ~]# mv /etc/yum.repos.d/* /etc/yum.repos.d/bak/
[root@node40 ~]# vim /etc/yum.repos.d/local.repo
[local]
name=Server
baseurl=http://10.252.90.40:8090/
enable=1
gpgcheck=0

刷新yum缓存,使yum源生效

[root@node40 ~]# yum clean all && yum makecache fast
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇ASF挂卡 下一篇MIT 6.828 Homework: Xv6 System ..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目