1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 【Linux使用】Centos 7 YUM仓库配置文件代理服务器设置

【Linux使用】Centos 7 YUM仓库配置文件代理服务器设置

时间:2022-12-13 18:41:25

相关推荐

【Linux使用】Centos 7 YUM仓库配置文件代理服务器设置

文章目录

系统信息所有仓库都位于外网,访问都通过代理服务器时部分仓库在内网,部分仓库在外网,代理服务器设置

系统信息

[tony@tony-compute1 ~]$ cat /etc/redhat-releaseCentOS Linux release 7.6.1810 (Core)[tony@tony-compute1 ~]$ uname -aLinux tony-compute1 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC x86_64 x86_64 x86_64 GNU/Linux

所有仓库都位于外网,访问都通过代理服务器时

修改/etc/yum.conf,在[main]节下添加代理服务器设置。

[tony@tony-compute1 ~]$ sudo vim /etc/yum.conf[main]cachedir=/var/cache/yum/$basearch/$releasever...distroverpkg=centos-release<font color=red>proxy=http://$user:$password@$proxy:$port</font>

注意:代理服务器必须是一个URL格式,即以http://,ftp://,https://,socks4://,socks4a://,socks5://,socks5h://开头,否则会得到如下错误:

Options error: Error parsing “proxy = ‘user:password@proxy:8888’”:

URL must be http, ftp, https, socks4, socks4a, socks5 or socks5h not “”

部分仓库在内网,部分仓库在外网,代理服务器设置

事实上,代理服务器的设置是可以按仓库分别设定的。

如果大多数仓库访问都在外网,则在yum.conf中设置代理服务器,对于放置在内网的仓库,则设置为不使用代理服务器。具体步骤如下:

在/etc/yum.conf中设置主代理服务器,参看上文。在/etc/yum.repos.d目录找到仓库配置文件(以.repo后缀结尾的都是仓库配置文件),不使用代理服务器的仓库配置下面都加上proxy=_none_设置。

例如

[tony@tony-controller yum.repos.d]$ cat CentOS-Base.repo[base]baseurl = http://linux-ftp.local/pub/mirrors/centos/$releasever/os/$basearchenabled = 1gpgcheck = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7name = CentOS-$releasever - Baseproxy=_none_[updates]baseurl = http://linux-ftp.local/pub/mirrors/centos/$releasever/updates/$basearch/enabled = 1gpgcheck = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7name = CentOS-$releasever - Updatesproxy=_none_[extras]baseurl = http://linux-ftp.local/pub/mirrors/centos/$releasever/extras/$basearch/enabled = 1gpgcheck = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7name = CentOS-$releasever - Extrasproxy=_none_[centosplus]baseurl = http://linux-ftp.local/pub/mirrors/centos/$releasever/centosplus/$basearch/enabled = 1gpgcheck = 1gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7name = CentOS-$releasever - Plusproxy=_none_

反过来,如果大部分仓库在内网,则默认不使用代理服务器,对于需要代理服务器的仓库则单独设置;甚至对于不同的仓库可以分别设置使用不同的代理服务器。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。