舊文章重新整理張貼 -
由於內部Linux主機愈來愈多了,每次在更新的時候,都會耗掉對外的頻寬,所以才想說要建立內部的YUM Server,除了可節省對外的頻寬外,安裝及更新的時間也都可以加快許多又方便
內部的Linux都是使用CentOS 6,所以就另外安裝一台Linux,作為YUM Server,做法如下:
1. 安裝所需套件:httpd, yum-arch, createrepo
先安裝EPEL
#rpm -Uvh http://http://mirror01.idc.hinet.net/EPEL/6/x86_64/epel-release-6-8.noarch.rpm安裝httpd, yum-arch, createrepo#yum groupinstall "Web Server"#yum install yum-arch createrepo啟動httpd 服務#service httpd start#chkconfig --level 235 httpd on --> 開機時自動啓動
2. 建立YUM Server 設定
3. YUM Client 設定
建立要放置Source 目錄
#mkdir -p /var/www/html/yum/centos/6.4/os/x86_64#mkdir -p /var/www/html/yum/centos/6.4/updates/x86_64#mkdir -p /var/www/html/yum/centos/6.4/extras/x86_64針對目錄mirror YUM Server 更新套件 (這裡使用rsync,而不是使用mirrordir的方式,因為當我使用mirrordir都會因為buffer over flow,而中斷無法更新)#rsync -aqzH --delete ftp.cs.pu.edu.tw::CentOS/6.4/os/x86_64 /var/www/html/yum/centos/6.4/os/x86_64#rsync -aqzH --delete ftp.cs.pu.edu.tw::CentOS/6.4/updates/x86_64 /var/www/html/yum/centos/6.4/updates/x86_64#rsync -aqzH --delete ftp.cs.pu.edu.tw::CentOS/6.4/extras/x86_64 /var/www/html/yum/centos/6.4/extras/x86_64RPM分析,並在目錄下產生headers資料夾#yum-arch /var/www/html/yum/centos/6.4/os/x86_64#yum-arch /var/www/html/yum/centos/6.4/updates/x86_64#yum-arch /var/www/html/yum/centos/6.4/extras/x86_64使用createrepo產生XML metadata,並在目錄下產生repodata資料夾#createrepo /var/www/html/yum/centos/6.4/os/x86_64#createrepo /var/www/html/yum/centos/6.4/updates/x86_64#createrepo /var/www/html/yum/centos/6.4/extras/x86_64設定每週自動更新套件#vim /usr/local/sbin/yum-update.sh加入上述rsync三個指令後,存檔,並修改權限#rsync -aqzH --delete ftp.cs.pu.edu.tw::CentOS/6.4/os/x86_64 /var/www/html/yum/centos/6.4/os/x86_64#rsync -aqzH --delete ftp.cs.pu.edu.tw::CentOS/6.4/updates/x86_64 /var/www/html/yum/centos/6.4/updates/x86_64#rsync -aqzH --delete ftp.cs.pu.edu.tw::CentOS/6.4/extras/x86_64 /var/www/html/yum/centos/6.4/extras/x86_64#chmod 777 /usr/local/sbin/yum-update.sh加到排程工作執行#crontab -e0 2 * * 7 /usr/local/sbin/yum-update.sh --> 設定為每週日凌晨2點執行
以上YUM Server/Client即完成設定
設定YUM#cp /etc/yum.repo/CentOS-Base.repo /etc/yum.repo/CentOS-Base.repo.bak#vi /etc/yum.repo/CentOS-Base.repo將[base] [updates] [extras] 的更新路徑變更為內部的YUM Server----------------------------------------------------------------------------------------------------------------------------[base]name=CentOS-$releasever - Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osbaseurl=http://YUM Server IP/yum/centos/$releasever/os/$basearch/gpgcheck=1#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6gpgkey=http://YUM Server IP/yum/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-6[updates]name=CentOS-$releasever - Updates#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesbaseurl=http://YUM Server IP/yum/centos/$releasever/updates/$basearch/gpgcheck=1#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6gpgkey=http://YUM Server IP/yum/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-6[extras]name=CentOS-$releasever - Extras#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasbaseurl=http://YUM Server IP/yum/centos/$releasever/extras/$basearch/gpgcheck=1#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6gpgkey=http://YUM Server IP/yum/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-6----------------------------------------------------------------------------------------------------------------------------#yum clean all#yum update
沒有留言:
張貼留言