Centos同步网络yum源到本地
去无外网环境去发布服务时候,安装应用需要很多依赖包,在网络上下载占用网络带宽,下载速度慢。为了解决这个问题,我们可以在本地部署一个yum源服务器,实现离线安装
方法步骤
1、安装同步所需要准备的工具
[]
2、根据需要可以移除其他镜像
[][]
3、下载其他yum源、如阿里云,腾讯云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo[root@prometheus yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo[root@repo yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
4、同步到本地
[][][][][][][]
5、创建yum源
[][][][][][][][]
6、配置基于本地yum源
[root@node1 ~]# vim /etc/yum.repos.d/base.repo[base]name=CentOS-Basebaseurl=file:///root/yum/basepath=/enabled=1 #是否将该仓库做为软件包提供源gpgcheck=0 #是否进行gpg校验[updates]name=CentOS-Updatesbaseurl=file:///root/yum/updatespath=/enabled=1gpgcheck=0[extras]name=CentOS-Extrasbaseurl=file:///root/yum/extraspath=/enabled=1gpgcheck=0[root@node1 ~]# vim /etc/yum.repos.d/epel.repo[epel]name=CentOS-Epelbaseurl=file:///root/yum/epelpath=/enabled=1gpgcheck=0
清除之前的缓存[][][]到此本地YUM仓库搭建完成,如果在对应的仓库中加入软件包时,需要更新仓库更新仓库[]
nginx 网络源[root@node1 ~]# vim /etc/nginx/nginx.conf #主要修改有注释的两个地方server {listen 80;server_name localhost;location / {root /root/yum/; #修改成yum仓库所在的目录index index.html index.htm;autoindex on; #开启目录}[root@node1 ~]# nginx -t 验证无误进行下一步[root@node1 ~]# systemctl restart nginx
配置本地网络yum源[root@node1 ~]# vim /etc/yum.repos.d/base.repo[base]name=CentOS-Basebaseurl=http://192.168.1.10/basepath=/enabled=1 #是否将该仓库做为软件包提供源gpgcheck=0 #是否进行gpg校验[updates]name=CentOS-Updatesbaseurl=http://192.168.1.10/updatespath=/enabled=1gpgcheck=0[extras]name=CentOS-Extrasbaseurl=http://192.168.1.10/extraspath=/enabled=1gpgcheck=0[root@node1 ~]# vim /etc/yum.repos.d/epel.repo[epel]name=CentOS-Epelbaseurl=http://192.168.1.10/epelpath=/enabled=1gpgcheck=0
