本地yum源

1.基本信息
在这里插入图片描述2.安装
大体流程:
1.下载阿里云yum源以及salt的yum源到/etc/yum.repos.d/
2.使用yum-utils命令将xxx.repo中所有需要的包同步到本地
3.使用createrepo命令在本地创建yum源生成元数据
4.配合nginx作为文件存储服务器,使本地yum源文件可以被访问
5.编写repo文件 并测试

## 1.安装nginx
# 需要使用nginx作为文件存储服务器  安装步骤和上面一样 只需要改下配置
# cat /alidata1/tools/nginx/conf/vhost/{www.outer,repo.inner}
server {
    listen                              80;
    server_name                         11.100.5.251;
    include                             vhost/repo.inner;
}
#### 文件切割线  #####
proxy_set_header                    Host $http_host;
proxy_next_upstream                 error http_500 http_502 http_503 http_504;
proxy_connect_timeout               30;
proxy_read_timeout                  30;
fastcgi_buffer_size 64k;
fastcgi_buffers 16 64k;
proxy_buffer_size 32k;
proxy_buffers      8 32k

location /repo {
    alias /alidata1/repo/;
    autoindex on;
    if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
        add_header Content-Disposition attachment;
    }
    autoindex_exact_size off; # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)
    autoindex_localtime on;   # 显示本机时间而非 GMT 时间
    charset utf-8; # 避免中文乱码
}


## 2.安装本地yum源
## (1)安装依赖  下载阿里云yum源文件以及salt的yum源文件
# yum install -y createrepo yum-utils
# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# yum install https://repo.saltstack.com/yum/redhat/salt-repo-2019.2.el7.noarch.rpm

## (2)同步远程源到本地
# mkdir /alidata1/repo/{CentOS7,CentOS6} -p
# reposync -p /alidata1/repo/CentOS7/

## (3)在本地创建yum源生成元数据
# pwd ; ls
/alidata1/repo/CentOS7
base  epel  extras  salt-2019.2  updates

## 当前目录下均需要执行createrepo .
# cd base/Packages/ ; createrepo .   
# cd epel/Packages/ ; createrepo . 
# cd extras/Packages/ ; createrepo . 
# cd updates/Packages/ ; createrepo . 
# cd salt-2019.2/ ; createrepo . 

## (4)编写本地yum源文件, 将此文件移动到其他服务器测试是否可用
# cat CentOS7-local.repo
[base]
name=CentOS-7-Base - mirror.template.com
baseurl=http://11.100.5.251/repo/CentOS7/base/Packages/
enabled=1
gpgcheck=0

[updates]
name=CentOS-7-Updates - mirror.template.com
baseurl=http://11.100.5.251/repo/CentOS7/updates/Packages/
enabled=1
gpgcheck=0

[extras]
name=CentOS-7-Extras - mirrors.template.com
baseurl=http://11.100.5.251/repo/CentOS7/extras/Packages/
enabled=1
gpgcheck=0
 
[epel]
name=CentOS-7-epel - mirrors.template.com
baseurl=http://11.100.5.251/repo/CentOS7/epel/Packages/
failovermethod=priority
enabled=1
gpgcheck=0

[salt]
name=salt - mirrors.template.com
baseurl=http://11.100.5.251/repo/CentOS7/salt-2019.2
enabled=1
gpgcheck=0

3.更新rpm包

# reposync -np /alidata1/repo/CentOS7/
# createrepo --update .      ## 到更新的目录下执行此命令,更新元数据

4.只下载rpm以及依赖不安装

## 只是在此处做个记录   安装本地yum源没有使用
# yum install yum-utils -y
# yumdownloader --destdir=/tmp --resolve httpd
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sun_xuegang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值