分类: LINUX
2010-03-18 15:23:28
原文发布在我的博客
建立yum服务器,方便软件安装,下面操作的环境是centos 5.4 x86_64,采用http方式安装。
1、安装必要软件:
#yum install httpd createrepo
//apache服务和rpeo下的xml生成工具
2、拷贝相关文件:
#mkdir -p /app/yum.repo/centos/5/os/x86_64/RPMS
#mkdir -p /app/yum.repo/centos/5/updates
#mkdir -p /app/yum.repo/tools/
#mkdir /mnt/cdrom
#mount -t iso9660 /dev/cdrom /mnt/cdrom
#cp -R /mnt/cdrom/Centos/* /app/yum.repo/centos/5/os/x86_64/RPMS/
#cp -R /mnt/cdrom/repodata /app/yum.repo/centos/5/os/x86_64/
#cp -R /mnt/cdrom/RPM-GPG-KEY-CentOS-5 /app/yum.repo/
//拷贝其他包到/app/yum.repo/tools下,这个可以自定义添加你想要的rpm包,比如jdk
3、启动http服务:
#rm -rf /var/www/html
#ln -s /app/yum.repo /var/www/html
#service httpd start
4、修改repo文件:
#cd /etc/yum.repo/
#vi CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=
gpgcheck=1
gpgkey=
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=
gpgcheck=1
gpgkey=
#vi CentOS-Tools.repo
[tools]
name=CentOS-$releasever - Base
baseurl=
gpgcheck=0
5、附加内容
在上述步骤结束后,更新需要使用yum机器/etc/yum.repo目录中的文件为第四步中更改的内容,即可使用yum;
yum 命令在这里就不说了,补充几个yum服务器常用的命令:
#createrepo /app/yum.repo/centos/5/os/x86_64
//更新或创建主目录文件索引
#createrepo /app/yum.repo/centos/5/updates/x86_64/
//更新或创建升级目录文件索引
#createrepo /app/yum.repo/tools
//更新或创建tools目录文件索引
#createrepo -g /mnt/cdrom/repodata/comps.xml /var/www/html/yum.repo/centos/5/updates/x86_64/
#createrepo -g /mnt/cdrom/repodata/comps.xml /var/www/html/yum.repo/centos/5/os/x86_64/
//更新或创建yum组索引,yum组,比如admin tools 它包含多个rpm,可以用yum grouplist查看