配置本地yum源

火星人 @ 2014-03-03 , reply:0
←手機掃碼閱讀

配置本地yum源

配置本地yum源


系統平台:Red Hat Enterprise Linux Server release 5  update 1
核心 2.6.18-53.el5

過程:
一。手動修改
1、 將DVD光碟掛載到/media/cdrom中;

2、 拷貝/media/cdrom中的所有文件到/media/yum1;

3、 /etc/yum.repos.d/rhel-debuginfo.repo :



name=Red Hat Enterprise Linux $releasever - $basearch - Cluster

baseurl=file:///media/yum1/Cluster

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release



name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage

baseurl=file:///media/yum1/ClusterStorage

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release



name=Red Hat Enterprise Linux $releasever - $basearch - Server

baseurl=file:///media/yum1/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release



name=Red Hat Enterprise Linux $releasever - $basearch - VT

baseurl=file:///media/yum1/VT

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

4、/usr/lib/python2.4/site-packages/yum/yumRepo.py第411行:

remote = url + '/' + relative

改為:

remote = 「/media/yum1/Server」 + '/' + relative

5、yum clean all

6、yum install iptraf 測試!成功!!!

二。使用shell腳本(請根據自己的環境靈活修改)

客戶端
#!/bin/bash

sed -i  's/gpgcheck=1/gpgcheck=0/' /etc/yum.conf
cd /etc/yum.repos.d/
rm -rf *repo
cat  > server1.repo <<EOF

name=Red Hat Enterprise Linux $releasever - $basearch - rpms
baseurl=ftp://192.168.0.1/pub/RHEL5U1/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

name=Red Hat Enterprise Linux $releasever - $basearch - VT
baseurl=ftp://192.168.0.1/pub/RHEL5U1/VT
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

name=Red Hat Enterprise Linux $releasever - $basearch - Cluster
baseurl=ftp://192.168.0.1/pub/RHEL5U1/Cluster
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage
baseurl=ftp://192.168.0.1/pub/RHEL5U1/ClusterStorage
enabled=1
gpgcheck=0
EOF

服務端
#!/bin/bash

echo "install createrepo.rpm"
rpm -ivh --force "/var/ftp/pub/RHEL5U1/Server/createrepo-0.4.4-2.fc6.noarch.rpm"
echo "cd /var/ftp/pub/RHEL5U1"
cd /var/ftp/pub/RHEL5U1
rm -rf Server/.olddata/
rm -rf VT/.olddata/
rm -rf Cluster/.olddata/
rm -rf ClusterStorage/.olddata/
for i in `find | grep "xml$" | grep "comps"`;do createrepo -g ${i#./*/} ${i%/*/*.xml}; done
exit 0
《解決方案》

謝謝分享




[火星人 via ] 配置本地yum源已經有231次圍觀

http://www.coctec.com/docs/service/show-post-1097.html