展会信息港展会大全

CentOS下yum使用代理的设置
来源:互联网   发布日期:2015-08-20 21:56:16   浏览:1880次  

导读: 问题描述: CentOS yum时出现 Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5arch=i386repo=addons error 错误: [plain] view plaincopyprint? [root@servermysql-5.0.56]#yuminstallgcc Loadedplugins:fastestmirror Loadingmirro...

问题描述:

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

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片

[root@server mysql-5.0.56]# yum install gcc

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=i386&repo=addons error was

[Errno 4] IOError: <urlopen error (-3, '\xe5\x9f\x9f\xe5\x90\x8d\xe8\xa7\xa3\xe6\x9e\x90\xe6\x9a\x82\xe6\x97\xb6\xe5\xa4\xb1\xe8\xb4\xa5')>

Error: Cannot find a valid baseurl for repo: addons

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

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片

[root@server mysql-5.0.56]# vi /etc/resolv.conf

nameserver 218.85.157.99

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

赞助本站

人工智能实验室

相关热词: CentOS 使用 代理 设置

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港