目录
一、服务端下载发布模式
1、准备安装环境
项目 | IP地址 |
---|---|
yum服务器 | 192.168.100.100 |
2、环境搭建
2.1、http安装
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
2.2、createrepo安装
yum -y install createrepo
2.3、创建repodata目录
cd /var/www/html/
mkdir test_yum/x86_64 -p
createrepo test_yum/x86_64
2.4、把需要发布的安装包存放到repodata目录
cp ./*.rpm /var/www/html/ test_yum/x86_64
2.5、更新发布yum源
createrepo --update test_yum/x86_64
# 更新本地源
3、单独下载及更新源
3.1、下载相应的软件
yum install tree -y --downloadonly --downloaddir=/var/www/html/test_yum/x86/
3.2、同步yum软件信息
createrepo --update /var/www/html/test_yum/x86/
4、客户端设备上增加repo源文件
cd /etc/yum.repos.d
vim test_yum.repo
[test_yum]
name= test_yum
baseurl=http://192.168.100.100/test_yum/x86_64
gpgcheck=0
5、测试是否生效
先清除客户端本地yum数据源缓存,在进行安装
yum clean all
yum install test.rpm
二、服务端代理模式
1. 在有外网的服务器上安装 nginx
#安装 nginx
yum -y install nginx
2. 配置 nginx 代理 yum 源
#新增 nginx 配置文件
vim /etc/nginx/conf.d/centos-7-yum.conf
#输入以下内容,如果需要其他yum源可以自行添加
# centos 7 yum local source
server {
listen 7000;
# server_name X;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
location / {
root html;
index index.html index.htm;
}
location /centos/ {
proxy_pass http://mirrors.aliyun.com/centos/;
}
location /epel/ {
proxy_pass http://mirrors.aliyun.com/epel/;
}
location /docker-ce/ {
proxy_pass https://mirrors.aliyun.com/docker-ce/;
}
}
检查nginx 配置,并重载nginx配置
nginx -t
nginx -s reload
3. 在内网服务器上面配置 yum 源
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 10.175.247.105:7000
failovermethod=priority
baseurl=http://10.175.247.105:7000/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://10.175.247.105:7000/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 10.175.247.105:7000
failovermethod=priority
baseurl=http://10.175.247.105:7000/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://10.175.247.105:7000/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 10.175.247.105:7000
failovermethod=priority
baseurl=http://10.175.247.105:7000/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://10.175.247.105:7000/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 10.175.247.105:7000
failovermethod=priority
baseurl=http://10.175.247.105:7000/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://10.175.247.105:7000/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 10.175.247.105:7000
failovermethod=priority
baseurl=http://10.175.247.105:7000/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://10.175.247.105:7000/centos/RPM-GPG-KEY-CentOS-7
刷新 yum 源
yum clean all
yum makecache fast
yum repolist all