[Linux] 在 CentOS 上設定 yum/debuginfo-install 用的 proxy
今天想用 debuginfo-install 安裝 python 的 debug symbol,結果遇到了連線錯誤:
Loaded plugins: fastestmirror, langpacks http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to debuginfo.centos.org port 80: No route to host" Trying other mirror. http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to debuginfo.centos.org port 80: No route to host" Trying other mirror. http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to debuginfo.centos.org port 80: No route to host" [base-debuginfo] Trying other mirror. ^Chttp://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted" Trying other mirror. failure: repodata/repomd.xml from base-debuginfo: [Errno 256] No more mirrors to try. http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to debuginfo.centos.org port 80: No route to host" http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to debuginfo.centos.org port 80: No route to host" http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to debuginfo.centos.org port 80: No route to host" http://debuginfo.centos.org/7/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted"
嗯… 因為這台機器沒辦法直接連上網,得透過一個 web proxy 才能連出去,
因此我們得設定 yum 讓它可以透過 proxy 來連線才行~
舉例來說,我這次要抓的是 debug symbol,
因此是透過 CentOS-Debuginfo.repo 這個設定檔來連線的,
所以要修改一下 /etc/yum.repos.d/CentOS-Debuginfo.repo 這個檔,
(也可以直接修改 /etc/yum.conf 這個全域設定檔)
加上最下面的 proxy, proxy_username, proxy_password 這三行;
[base-debuginfo] name=CentOS-7 - Debuginfo baseurl=http://debuginfo.centos.org/7/$basearch/ gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7 enabled=1 proxy=http://10.1.2.3:8080 proxy_username=user proxy_password=pass
如果 proxy 不需要帳號密碼的話,就不需要加上 proxy_username, proxy_password 這兩行~
設定好之後,再執行一次 debuginfo-install,果然就連線成功了:
root@localhost / # debuginfo-install python-2.7.5-18.el7_1.1.x86_64
......
Installing : glibc-debuginfo-common-2.17-106.el7_2.4.x86_64 1/3
Installing : glibc-debuginfo-2.17-106.el7_2.4.x86_64 2/3
Installing : python-debuginfo-2.7.5-18.el7_1.1.x86_64 3/3
Verifying : glibc-debuginfo-2.17-106.el7_2.4.x86_64 1/3
Verifying : glibc-debuginfo-common-2.17-106.el7_2.4.x86_64 2/3
Verifying : python-debuginfo-2.7.5-18.el7_1.1.x86_64 3/3
Installed:
glibc-debuginfo.x86_64 0:2.17-106.el7_2.4 python-debuginfo.x86_64 0:2.7.5-18.el7_1.1
Dependency Installed:
glibc-debuginfo-common.x86_64 0:2.17-106.el7_2.4
Complete!
除了修改 repo 檔和 yum.conf 之外,還可以設定 http_proxy 這個環境變數,
這樣就只對目前的 shell session 有用,例如:
export http_proxy=http://user:pass@10.1.2.3:8080
參考資料:Using yum with a Proxy Server
(本頁面已被瀏覽過 1,107 次)