zoukankan      html  css  js  c++  java
  • CentOS下yum使用代理的设置

    export后好像没用?

    问题描述:

    CentOS yum时出现“Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=addons error ”错误:

    [plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    1. [root@server mysql-5.0.56]# yum install gcc  
    2. Loaded plugins: fastestmirror  
    3. Loading mirror speeds from cached hostfile  
    4. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=addons error was  
    5. [Errno 4] IOError: <urlopen error (-3, 'xe5x9fx9fxe5x90x8dxe8xa7xa3xe6x9ex90xe6x9ax82xe6x97xb6xe5xa4xb1xe8xb4xa5')>  
    6. Error: Cannot find a valid baseurl for repo: addons  

    发现原来是没有配置resolv.conf,于是到/etc目录下配置resolv.conf加入nameserver IP:

    [plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    1. [root@server mysql-5.0.56]# vi /etc/resolv.conf  
    2. nameserver 218.85.157.99  
    3. search localdomain  

    保存resolv.conf,再次运行上面命令就可以。

    因为最近在研究LInux系统,公司环境有限,公司统一通过代理上网,我在自己电脑的虚拟机上安装了Linux服务器,因此在虚拟机里面设代理,电脑ip为xxx.xxx.xxx.xx,其中http端口808.

    经过在网络上的搜索终于发现了最终的解决方案,现在贴出来和大家做个分享!

    如果只是暂时使用代理,在命令行输入下面一条命令:
    export http_proxy="http://210.45.72.XX:808"

    对于长久使用代理的情况:
    yum里面可以单独设置代理
    就是yum源的参数加proxy=“http://ip:PORT”
    即在/etc/yum.conf中加入下面几句.
    proxy=http://210.45.72.XX:808
    proxy_username=username
    proxy_password=password
    另外: 
    /root/.bashrc中加入: 
    export http_proxy="http://username:password@210.45.72.XX:808"
    如果是通过ip或电脑的网卡地址认证,可忽略所有username 和 password .
    注:停止使用代理的时候,要把改过的文件改成原样.尤其是如果使用了export http_proxy="http://210.45.72.XX:808"命令,
    要在命令行输入: unset http_proxy ,去除环境变量.
    因为export http_proxy="http://210.45.72.XX:808"这条命令的实质是把export后面的设置写进环境设置文件中.
    输入env 可以看所有的环境变量设置.
    env >env.txt 可以把环境变量输出到env.txt中,然后打开看也可以.

    unset 变量 可以取消曾经设过的环境变量.

    转载请注明出处:http://blog.csdn.net/fwj380891124

  • 相关阅读:
    汉字的几何中心
    输入带空格的string类型字符串 c++
    cin函数返回值
    win7玩游戏两边有黑条
    unresolved external symbol __imp__WSACleanup@0
    sizeof和strlen
    printf 函数返回值
    clone() 操作系统实验
    unsigned char 与 char
    【转】向字符数组输入空格的方法
  • 原文地址:https://www.cnblogs.com/timssd/p/5167435.html
Copyright © 2011-2022 走看看