8、创建
createrepo -g /var/yum/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server/
createrepo -g /var/yum/VT/repodata/comps-rhel5-vt.xml /var/yum/VT/
createrepo -g /var/yum/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster/
createrepo -g /var/yum/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage/
9、vi /etc/yum.repos.d/local.repo # 创建本地yum客户端的repo文件,名字可以随便起,但是要以.repo为后缀
yum
名字可以随便起
搜索路径,必须指向你本机的
gpgcheck
enabled=1 #是否启用,0为不启用,1为启用,涂过没这一项,就是启用
[VT]
name=VT
baseurl=file:///var/yum/VT
gpgcheck=0
[Cluster]
name= Cluster
baseurl=file:///var/yum/ Cluster
gpgcheck=0
[CS]
name= ClusterStorage
baseurl=file:///var/yum/ ClusterStorage
gpgcheck=0
二、用脚本自动实现yum配置
#!/bin/bash
if [ -e /media/cdrom ];then
mount /dev/cdrom /media/cdrom
else
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
fi
if [ -e /var/yum ];then
echo "coping to file from CDROM" && cp -r /media/cdrom/* /var/yum &
else
mkdir /var/yum && echo "coping to file" && cp -r /media/cdrom/* /var/yum &
fi
rpm -qa |grep yum &>/dev/null
if [ $? -eq 0 ];then
rpm -q createrepo
if [ $? -ne 0 ];then
rpm -ivh /media/cdrom/Server/createrepo*
fi
fi
creatxml() {
createrepo -g /var/yum/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server
createrepo -g /var/yum/VT/repodata/comps-rhel5-vt.xm /var/yum/VT
createrepo -g /var/yum/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster
createrepo -g /var/yum/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage
}
creatxml #对函数引用
cat >> /etc/yum.repos.d/local.repo << eof
[server]
name=server
baseurl=file:///var/yum/Server
gpgcheck=0
enable=1
[VT]
name=vt
baseurl=file:///var/yum/VT
gpgcheck=0
enable=1
[Cluster]
name=cluster
baseurl=file:///var/yum/Cluster
gpgcheck=0
enable=1
[ClusterStorage]
name=cluster
baseurl=file:///var/yum/ClusterStorage
gpgcheck=0
enable=1
本文转自 张玉坡 51CTO博客,原文链接:http://blog.51cto.com/fighter/475051