当前位置:   article > 正文

linux之yum源代理_yum 代理

yum 代理

环境介绍

       一般在内网环境中,多数服务器是不能直接上外网的(为了安全),只有个别的服务器可以访问外网,在不能访问外网的服务器上安装软件由于依赖的问题很容易出错,安装不下去,这时候就可以借助可以上外网的服务器做代理来安装软件。Centos7下设置代理案例。

A服务器

192.168.1.100

可以访问外网

B服务器

192.168.1.200

不能访问外网,可以通过内网IP访问A服务器

A服务器代理yum源

  1. #安装nginx服务器
  2. [root@gby-A ~]# yum install nginx -y
  3. #配置nginx服务
  4. [root@gby-A ~]# cat /etc/nginx/conf.d/yum.conf
  5. server {
  6. listen 80;
  7. server_name yum.com;
  8. location /centos/ {
  9. #具体代理url根据实际情况更改。可以根据b服务器url编写
  10. proxy_pass http://mirrors.aliyun.com/centos/ ;
  11. }
  12. location /epel/ {
  13. #具体代理url根据实际情况更改。可以根据b服务器url编写
  14. proxy_pass http://mirrors.aliyun.com/epel/ ;
  15. }
  16. }
  17. #重启nginx
  18. [root@gby-A ~]# nginx -s reload

B服务器yum指向A服务器

  1. #备份yum文件
  2. [root@gby-B ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
  3. [root@gby-B ~]# vim /etc/yum.repos.d/CentOS-Base.repo
  4. [base]
  5. name=CentOS-$releasever - Base - yum.com
  6. failovermethod=priority
  7. baseurl=http://yum.com/centos/$releasever/os/$basearch/
  8. http://yum.com/centos/$releasever/os/$basearch/
  9. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  10. gpgcheck=1
  11. gpgkey=http://yum.com/centos/RPM-GPG-KEY-CentOS-7
  12. #released updates
  13. [updates]
  14. name=CentOS-$releasever - Updates - yum.com
  15. failovermethod=priority
  16. baseurl=http://yum.com/centos/$releasever/updates/$basearch/
  17. http://yum.com/centos/$releasever/updates/$basearch/
  18. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  19. gpgcheck=1
  20. gpgkey=http://yum.com/centos/RPM-GPG-KEY-CentOS-7
  21. #additional packages that may be useful
  22. [extras]
  23. name=CentOS-$releasever - Extras - yum.com
  24. failovermethod=priority
  25. baseurl=http://yum.com/centos/$releasever/extras/$basearch/
  26. http://yum.com/centos/$releasever/extras/$basearch/
  27. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  28. gpgcheck=1
  29. gpgkey=http://yum.com/centos/RPM-GPG-KEY-CentOS-7
  30. #additional packages that extend functionality of existing packages
  31. [centosplus]
  32. name=CentOS-$releasever - Plus - yum.com
  33. failovermethod=priority
  34. baseurl=http://yum.com/centos/$releasever/centosplus/$basearch/
  35. http://yum.com/centos/$releasever/centosplus/$basearch/
  36. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  37. gpgcheck=1
  38. enabled=0
  39. gpgkey=http://yum.com/centos/RPM-GPG-KEY-CentOS-7
  40. #contrib - packages by Centos Users
  41. [contrib]
  42. name=CentOS-$releasever - Contrib - yum.com
  43. failovermethod=priority
  44. baseurl=http://yum.com/centos/$releasever/contrib/$basearch/
  45. http://yum.com/centos/$releasever/contrib/$basearch/
  46. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
  47. gpgcheck=1
  48. enabled=0
  49. gpgkey=http://yum.com/centos/RPM-GPG-KEY-CentOS-7
  50. #B服务器hosts指向A服务器
  51. [root@gby-B ~]# echo "192.168.1.100 yum.com" >>/etc/hosts
  52. #B服务器验证yum.com是否指向A服务器
  53. [root@gby-B ~]# ping 192.168.1.100
  54. #刷新yum缓存
  55. [root@gby-B ~]# yum clean all
  56. [root@gby-B ~]# yum makecache
  57. #进行yum操作如安装升级等。

结束之有话想说

既然看完了那就赶紧去试试吧骚年。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/168684
推荐阅读
相关标签