服务端配置
1.挂载光盘镜像
mkdir /mnt/cdrom
mount /dev/sr0
2.搭建apache服务器
yum -y install httpd
service httpd restart
chkconfig httpd on
3.复制光盘镜像到www目录
mkdir -p /var/www/html/yum/CentOS
cp -Rp /mnt/cdrom/* /var/www/html/yum/CentOS
4.安装createrepo
yum -y install createrepo
createrepo /var/www/html/yum/CentOS
客户端配置
修改CentOS-Base.repo文件
vi /etc/yum.repos.d/ CentOS-Base.repo
enabled为1的baseurl都设置为服务端ip
baseurl=
# CentOS-Base.repo
# # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base baseurl= gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 #released updates [updates] name=CentOS-$releasever - Updates baseurl= gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl= gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl= gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib mirrorlist= $releasever&arch=$basearch&repo=contrib&infra=$infra #baseurl=$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6