許多 VPS 使用者在操作 CentOS 時,常會遇到 yum 套件下載速度極慢的情況,特別是國外源在國內訪問時。這不僅浪費時間,也影響部署效率。針對此問題,安裝 Axel 多線程下載插件是一個行之有效的解決方案。Axel 能將單一檔案拆分為多個片段,透過多條 HTTP/FTP 連線並行下載,顯著提升傳輸速度。
wget -c https://wp.cdn.gongzi.org/soft/axel-2.4-1.el5.rf.i386.rpm
rpm -ivh axel-2.4-1.el5.rf.i386.rpm
cd /etc/yum/pluginconf.d/
wget https://cnfreesoft.googlecode.com/svn/trunk/axelget/axelget.conf
cd /usr/lib/yum-plugins/
wget https://cnfreesoft.googlecode.com/svn/trunk/axelget/axelget.py
請確認 /etc/yum.conf 中已啟用插件功能:plugins=1。
yum install -y yum-fastestmirror
完成上述步驟後,再次執行 yum install 或 yum update,即可觀察到下載速度明顯提升。結合 fastestmirror 自動匹配最優節點,雙管齊下,徹底解決 yum 下載緩慢的痛點。