zoukankan      html  css  js  c++  java
  • 公司内网穿透代理使用公网yum源

    环境:centos 6.5

    之前写过一篇关于公司内网配置代理的帖子,配完之后还会有些杂七杂八的问题,记得当时用的是centos7 的系统,今天公司生产环境有台centos6 的机器有问题,所以需要在测试环境上穿透代理上内网,我按照之前的经验改好/etc/profile /etc/yum.conf之后,使用nslookup进行域名解析,由于阿里的镜像源最近总是出问题,此次测试使用的是清华大学的yum源

     可以正常解析,此时说明到镜像源的网络没问题了

    然后按照他们官方提供的方法

     (看来低版本的centos系统,逐渐被淘汰了呢)进行repo文件的配置

    centos-vault 镜像使用帮助

    该文件夹提供较早版本的 CentOS,例如 CentOS 6;同时提供当前 CentOS 大版本的历史小版本的归档; 还提供 CentOS 各个版本的源代码和调试符号。

    建议先备份 /etc/yum.repos.d/ 内的文件。

    然后编辑 /etc/yum.repos.d/ 中的相应文件,在 mirrorlist= 开头行前面加 # 注释掉;并将 baseurl= 开头行取消注释(如果被注释的话),把该行内的域名及路径(例如mirror.centos.org/centos)替换为 mirrors.tuna.tsinghua.edu.cn/centos-vault

    以上步骤可以被下方的命令一步完成

    sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' 
             -e 's|^#baseurl=http://mirror.centos.org/centos/|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/|g' 
             -i.bak 
             /etc/yum.repos.d/CentOS-*.repo

    注意其中的*通配符,如果只需要替换一些文件中的源,请自行增删。

    注意,如果需要启用其中一些 repo,需要将其中的 enabled=0 改为 enabled=1

    最后,更新软件包缓存

    sudo yum makecache

    此时我的配置文件 /etc/yum.repos.d/CentOS-Base.repo

    cat /etc/yum.repos.d/CentOS-Base.repo
    
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$releasever/os/$basearch/
    enabled=1
    gpgcheck=0

    遇到如下问题

    [root@centos6 ~]# yum makecache
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.0/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 407"
    Trying other mirror.
    Error: Cannot retrieve repository metadata (repomd.xml) for repository: mnt. Please verify its path and try again

    web的407错误码是用户认证的问题,但是我代理的用户和密码是没有问题的,所以我直接找到yum源里面的某个rpm包的路径用wget命令测试了一下

    [root@centos6 tmp]# wget https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/x86_64/Packages/openssh-5.3p1-94.el6.x86_64.rpm
    --2021-03-29 23:09:29--  https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/x86_64/Packages/openssh-5.3p1-94.el6.x86_64.rpm
    Connecting to 10.4.200.168:18765... connected.
    ERROR: certificate common name “tuna.tsinghua.edu.cn” doesn’t match requested host name “mirrors.tuna.tsinghua.edu.cn”.
    To connect to mirrors.tuna.tsinghua.edu.cn insecurely, use ‘--no-check-certificate’.
    [root@centos6 tmp]# wget https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/x86_64/Packages/openssh-5.3p1-94.el6.x86_64.rpm --no-check-certificate
    --2021-03-29 23:10:08--  https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/x86_64/Packages/openssh-5.3p1-94.el6.x86_64.rpm
    Connecting to 10.4.200.168:18765... connected.
    WARNING: certificate common name “tuna.tsinghua.edu.cn” doesn’t match requested host name “mirrors.tuna.tsinghua.edu.cn”.
    Proxy request sent, awaiting response... 200 OK
    Length: 264144 (258K) [application/x-redhat-package-manager]
    Saving to: “openssh-5.3p1-94.el6.x86_64.rpm”
    
    100%[===================================================================================>] 264,144      595K/s   in 0.4s
    
    2021-03-29 23:10:12 (595 KB/s) - “openssh-5.3p1-94.el6.x86_64.rpm” saved [264144/264144]
    
    [root@centos6 tmp]# ls
    openssh-5.3p1-94.el6.x86_64.rpm  yum.log

    最终是下载成功了的,仔细看了一下,不知道是哪里出的问题,他们提供的repo文件的系统版本写错了 ,我的是6.5,然后我自己手动下载的时候也是指定的6.5的路径,但是yum makecache的时候,他给我指定的路径是 6.0,大家看上面的报错信息就知道了,于是我手动修改配置如下

    [root@centos6 /]# cat /etc/yum.repos.d/CentOS-Base.repo
    # CentOS-Base.repo
    
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/$basearch//
    enabled=1
    gpgcheck=0

    再次执行yum makecache,这次yum算是可以用了,由于我想安装的iperf 是由epel仓库提供的,所以我需要安装epel-release

    [root@centos6 tmp]# yum -y install epel-release
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Setting up Install Process
    No package epel-release available.
    Error: Nothing to do

    看来这个方法,清华的镜像源不支持,或者是版本太低已经把这个包弃用了,所以不能直接通过yum安装的方式配置epel了,于是再次手动配置

    EPEL 镜像使用帮助

    EPEL(Extra Packages for Enterprise Linux)是由Fedora Special Interest Group维护的Enterprise Linux(RHEL、CentOS)中经 常用到的包。

    下面以CentOS 7为例讲解如何使用tuna的epel镜像。

    首先从CentOS Extras这个源(tuna也有镜像)里安装epel-release:

    yum install epel-release

    当前tuna已经在epel的官方镜像列表里,所以不需要其他配置,mirrorlist机制就能让你的服务器就近使用tuna的镜像。如果你想强制 你的服务器使用tuna的镜像,可以修改/etc/yum.repos.d/epel.repo,将mirrorlistmetalink开头的行注释掉。

    接下来,取消注释这个文件里baseurl开头的行,并将其中的http://download.fedoraproject.org/pub替换成https://mirrors.tuna.tsinghua.edu.cn

    可以用如下命令自动替换:(来自 https://github.com/tuna/issues/issues/687)

    sed -e 's!^metalink=!#metalink=!g' 
        -e 's!^#baseurl=!baseurl=!g' 
        -e 's!//download.fedoraproject.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' 
        -e 's!http://mirrors.tuna!https://mirrors.tuna!g' 
        -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo

    修改结果如下:(仅供参考,不同版本可能不同)

    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    
    [epel-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    
    [epel-source]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Source
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1

    运行 yum update 测试一下吧。

    官方提供的是centos7的配置方法,我们自己改一下就好了,如下

    [root@centos6 /]# cat /etc/yum.repos.d/epel.repo
    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    baseurl=https://archives.fedoraproject.org/pub/archive/epel/6/$basearch
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    #failovermethod=priority
    enabled=1
    gpgcheck=0

    此处我用的域名是 https://archives.fedoraproject.org/pub/archive/epel  因为清华的镜像源里面也弃用centos6的epel仓库了

    配置好之后,yum makecache有报错了

    [root@centos6 yum.repos.d]# yum makecache
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    base                                                                                                  | 3.7 kB     00:00
    base/group_gz                                                                                         | 220 kB     00:00
    base/filelists_db                                                                                     | 5.9 MB     00:05
    base/primary_db                                                                                       | 4.4 MB     00:04
    base/other_db                                                                                         | 2.8 MB     00:01
    https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/repodata/repomd.xml: [Errno 14] problem making ssl connection
    Trying other mirror.
    Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again

    同上wget在我指定的域名路径下载一个rpm包,是可以下载成功的,然后我上网查了一下 [Errno 14] problem making ssl connection

    说是没有证书,ca-certificates 其实目前系统里面已经有这个包了,而且是6.5所支持的最新版本,又查了半天才发现是openssl的版本过低,

    没办法,把base的路径改成 6.10 的仓库,升级这些包

    [root@centos6 /]# cat /etc/yum.repos.d/CentOS-Base.repo
    # CentOS-Base.repo
    
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/os/$basearch/
    #baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.5/os/x86_64/
    enabled=1
    gpgcheck=0

    [root@centos6 yum.repos.d]# yum -y update yum curl openssl nss

    然后重新yum makecache 以上,问题解决

    参考文档:

    https://centrify.force.com/support/Article/KB-11461-Centrify-Yum-repo-fails-with-Errno-14-problem-making-ssl-connection/

  • 相关阅读:
    matlab 动态绘图保持figure不变
    ucos-ii在ti dsp 28377芯片上的运行过程和移植过程
    关于ucos_ii 就绪表的理解
    dsp 28377在线升级 实例总结
    关于DSP的boot mode / boot loader /上电顺序 /在线升级等问题的总结
    开源看板wekan docker 源码构建
    开源看板 wekan windows 环境下 离线部署
    公司内网两台电脑无法ping通的问题
    excle 根据单位、岗位、成绩 等排名
    python爬虫学习:从数据库读取目标爬虫站点及爬虫规则,批量爬取目标站点指定数据(scrapy框架)
  • 原文地址:https://www.cnblogs.com/augusite/p/14592975.html
Copyright © 2011-2022 走看看