CentOS : เปลี่ยน repo มาใช้ในไทย เพื่อให้ yum ได้เร็วขึ้น
โพสต์: อังคาร 01 มี.ค. 2016 03:29
CentOS : เปลี่ยน repo มาใช้ในไทย เพื่อให้ yum ได้เร็วขึ้น
1. ดูก่อนว่า CentOS มี list ของ repo อะไรอยู่บ้าง
จะได้ผลลับดังนี้
2. ใช้คำสั่ง curl เพื่อดู list ของ repo โดยอ้างถึง link ตาม mirrorlist ในข้อ 1
จะได้ผลดังนี้
สังเกตุ mirror ในไทยจะลงท้ายด้วย .th ซึ่งก็คือ
http://mirrors.psu.ac.th/pub/centos/6.5/os/i386/
http://mirror1.ku.ac.th/centos/6.5/os/i386/
หรือจะหามาจากที่อื่นก็ได้ ซึ่งควรจะใช้ตัวที่อยู่ใกล้เราที่สุด
ผมจะขอใช้ http://mirror.adminbannok.com/centos/6.7/os/i386/
3. ทำการแก้ไขไฟล์ /etc/yum.repos.d/CentOS-Base.repo
โดยทำการเติม # หน้า mirrorlist และ copy #baseurl=http://mirror.centos.org/centos/$releas ... $basearch/
และเอา # ด้านหน้าออก และเปลี่ยน http://mirror.centos.org/centos เป็น path ที่เราเลือก คือ http://mirror.adminbannok.com/centos/6.7/os/i386/
แก้ไขดังนี้
4. ทำการ save และทดสอบดูว่า CentOS เลือก repo ตามที่เรากำหนดไว้หรือไม่
จะได้ผลตามนี้
เท่านี้ก็เป็นอันเรียบร้อย Yum ได้แบบสบายใจ
ที่มา :
http://mirror-status.centos.org/
http://spalinux.com/2012/05/change-yum- ... n-thailand
1. ดูก่อนว่า CentOS มี list ของ repo อะไรอยู่บ้าง
โค้ด: เลือกทั้งหมด
[root@localhost ~]# yum-config-manager base
โค้ด: เลือกทั้งหมด
Loaded plugins: fastestmirror, refresh-packagekit
================================== repo: base ==================================
[base]
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/6
baseurl = http://mirror.adminbannok.com/centos/6/os/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/6/base
cost = 1000
enabled = True
enablegroups = True
exclude =
failovermethod = priority
gpgcadir = /var/lib/yum/repos/x86_64/6/base/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/6/base/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
hdrdir = /var/cache/yum/x86_64/6/base/headers
http_caching = all
includepkgs =
keepalive = True
mdpolicy = group:primary
mediaid =
metadata_expire = 21600
metalink =
mirrorlist =
mirrorlist_expire = 86400
name = CentOS-6 - Base
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/6/base
pkgdir = /var/cache/yum/x86_64/6/base/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
username =
โค้ด: เลือกทั้งหมด
[root@localhost ~]# curl 'http://mirrorlist.centos.org/?release=6&arch=i386&repo=os'
โค้ด: เลือกทั้งหมด
http://mirror1.ku.ac.th/centos/6.7/os/i386/
http://mirrors.bangmodhosting.com/centos/6.7/os/i386/
http://mirrors.thzhost.com/centos/6.7/os/i386/
http://mirrors.psu.ac.th/pub/centos/6.7/os/i386/
http://mirrors.hosting.in.th/centos/6.7/os/i386/
http://mirrors.bestthaihost.com/centos/6.7/os/i386/
http://mirror.adminbannok.com/centos/6.7/os/i386/
http://mirror2.totbb.net/centos/6.7/os/i386/
http://mirrors.btte.net/centos/6.7/os/i386/
http://mirrors.zju.edu.cn/centos/6.7/os/i386/
สังเกตุ mirror ในไทยจะลงท้ายด้วย .th ซึ่งก็คือ
http://mirrors.psu.ac.th/pub/centos/6.5/os/i386/
http://mirror1.ku.ac.th/centos/6.5/os/i386/
หรือจะหามาจากที่อื่นก็ได้ ซึ่งควรจะใช้ตัวที่อยู่ใกล้เราที่สุด
ผมจะขอใช้ http://mirror.adminbannok.com/centos/6.7/os/i386/
3. ทำการแก้ไขไฟล์ /etc/yum.repos.d/CentOS-Base.repo
โดยทำการเติม # หน้า mirrorlist และ copy #baseurl=http://mirror.centos.org/centos/$releas ... $basearch/
และเอา # ด้านหน้าออก และเปลี่ยน http://mirror.centos.org/centos เป็น path ที่เราเลือก คือ http://mirror.adminbannok.com/centos/6.7/os/i386/
โค้ด: เลือกทั้งหมด
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Base.repo
โค้ด: เลือกทั้งหมด
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirror.adminbannok.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://mirror.adminbannok.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://mirror.adminbannok.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://mirror.adminbannok.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=http://mirror.adminbannok.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
4. ทำการ save และทดสอบดูว่า CentOS เลือก repo ตามที่เรากำหนดไว้หรือไม่
โค้ด: เลือกทั้งหมด
[root@localhost ~]# yum -v repolist
โค้ด: เลือกทั้งหมด
Loading "fastestmirror" plugin
Loading "refresh-packagekit" plugin
Loading "security" plugin
Not loading "whiteout" plugin, as it is disabled
Config time: 0.030
Yum Version: 3.2.29
Loading mirror speeds from cached hostfile
Setting up Package Sacks
pkgsack time: 0.061
Repo-id : base
Repo-name : CentOS-6 - Base
Repo-revision: 1438723315
Repo-updated : Wed Aug 5 04:24:45 2015
Repo-pkgs : 6,485
Repo-size : 5.3 G
Repo-baseurl : http://mirror.adminbannok.com/centos/6/os/x86_64/
Repo-expire : 21,600 second(s) (last: Tue Mar 1 02:02:20 2016)
Repo-excluded: 90
Repo-id : extras
Repo-name : CentOS-6 - Extras
Repo-revision: 1452698437
Repo-updated : Wed Jan 13 22:20:38 2016
Repo-pkgs : 50
Repo-size : 18 M
Repo-baseurl : http://mirror.adminbannok.com/centos/6/extras/x86_64/
Repo-expire : 21,600 second(s) (last: Tue Mar 1 02:02:20 2016)
Repo-id : updates
Repo-name : CentOS-6 - Updates
Repo-revision: 1455821493
Repo-updated : Fri Feb 19 01:55:44 2016
Repo-pkgs : 1,147
Repo-size : 5.5 G
Repo-baseurl : http://mirror.adminbannok.com/centos/6/updates/x86_64/
Repo-expire : 21,600 second(s) (last: Tue Mar 1 02:02:20 2016)
Repo-excluded: 84
repolist: 7,682
ที่มา :
http://mirror-status.centos.org/
http://spalinux.com/2012/05/change-yum- ... n-thailand