一 利用安装光盘
1.安装httpd 和 createrepo
yum install httpd createrepo
2.拷贝相关文件
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
mkdir -p /var/www/html/yum.repo/centos/5/os/x86_64/RPMS
mkdir -p /var/www/html/yum.repo/centos/5/updates
mkdir -p /var/www/html/yum.repo/tools
cp -R /mnt/cdrom/CentOS/* /var/www/html/yum.repo/centos/5/os/x86_64/RPMS
cp -R /mnt/cdrom/repodata /var/www/html/yum.repo/centos/5/os/x86_64/
cp -R /mnt/cdrom/RPM-GPG-KEY-CentOS-5 /var/www/html/yum.repo/
3.创建yum源 索引
createrepo /var/www/html/yum.repo/centos/5/os/x86_64
createrepo /var/www/html/yum.repo/centos/5/updates/x86_64/
createrepo /var/www/html/yum.repo/tools
添加rpm包后修改索引
createrepo --update /var/www/html/yum.repo/tools
4. 客户端修改vi CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://192.168.1.222/yum.repo/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://192.168.1.222/yum.repo/RPM-GPG-KEY-CentOS-5
#released updates
#[updates]
#name=CentOS-$releasever - Updates
#baseurl=http://192.168.1.222/yum.repo/centos/$releasever/updates/$basearch/
#gpgcheck=1
#gpgkey=http://192.168.1.222/yum.repo/RPM-GPG-KEY-CentOS-5
[tools]
name=CentOS-$releasever - Tools
baseurl=http://192.168.1.222/yum.repo/tools/
gpgcheck=0
enabled=1
二 使用centos官网 建立本地镜像站点
rsync -aqzH --delete msync.centos.org::CentOS /path/to/local/mirror/root
EU users may wish to use eu-msync.centos.org::CentOS
US users may wish to use us-msync.centos.org::CentOS