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