为了避免从网络下载软件包可能发生的软件包不完整、下载速度慢、网络故障等问题,我们强烈建议您使用本地的 DVD/CD iso 来创建 yum 仓库,这样在安装的时候速度快,而且可以保证所有软件包都能顺利安装。
1、将光盘放入光驱,安装必须的包,(下面这些包如果已经安装,可跳过;安装完ssh服务,就可以用putty等软件远程操作了。):
[root@mjwdj ~]# mkdir /mnt/iso/ [root@mjwdj ~]# mount /dev/hdc /mnt/iso/ [root@mjwdj ~]# rpm -i --nodeps /mnt/iso/Server/fipscheck-lib-1.2.0-1.el5.i386.rpm [root@mjwdj ~]# rpm -i --nodeps /mnt/iso/Server/fipscheck-1.2.0-1.el5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/openssh-4.3p2-72.el5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/tcp_wrappers-7.6-40.7.el5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/openssh-server-4.3p2-72.el5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/openssh-client-4.3p2-72.el5.i386.rpm [root@mjwdj ~]# service sshd start [root@mjwdj ~]# chkconfig sshd on [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/rpm-python-4.4.2.3-22.el5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/yum-metadata-parser-1.1.2-3.el5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/createrepo-0.4.11-3.el5.noarch.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/python-elementtree-1.2.6-5.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/python-iniparse-0.2.3-4.el5.noarch.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/m2crypto-0.16-6.el5.8.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/python-urlgrabber-3.1.0-6.el5.noarch.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/python-sqlite-1.1.7-1.2.1.i386.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/yum-3.2.22-33.el5.noarch.rpm [root@mjwdj ~]# rpm -ivh /mnt/iso/Server/yum-utils-1.1.16-13.el5_4.1.noarch.rpm
a、如果您使用的是官方的 DVD ISO或多个CD ISO文件,则需要将它复制到系统上,挂载后制作 yum 仓库:
[root@mjwdj ~]# mkdir /mnt/iso [root@mjwdj ~]# mount -o loop /home/CentOS-5.8-i386-bin-DVD.iso /mnt/iso/ [root@mjwdj ~]# cd /mnt [root@mjwdj mnt]# createrepo . [root@mjwdj ~]# mkdir -p /mnt/{1,2,3,4,5,6} [root@mjwdj ~]# mount -o loop /home/CentOS5.8-disc1.iso /mnt/1 [root@mjwdj ~]# mount -o loop /home/CentOS5.8-disc2.iso /mnt/2 [root@mjwdj ~]# mount -o loop /home/CentOS5.8-disc3.iso /mnt/3 [root@mjwdj ~]# mount -o loop /home/CentOS5.8-disc4.iso /mnt/4 [root@mjwdj ~]# mount -o loop /home/CentOS5.8-disc5.iso /mnt/5 [root@mjwdj ~]# cd /mnt/ [root@mjwdj mnt]# createrepo .
b、如果您光盘,需要挂载后制作 yum 仓库。
[root@mjwdj ~]# mount /dev/hdc /media/iso/ [root@mjwdj ~]# cd /mnt/ [root@mjwdj mnt]# createrepo .
清空并重新定义yum仓库:
[root@mjwdj ~]# rm -f /etc/yum.repos.d/* [root@mjwdj ~]# echo "[DVDISO]" >> /etc/yum.repos.d/dvdiso.repo [root@mjwdj ~]# echo "name=DVD ISO" >> /etc/yum.repos.d/dvdiso.repo [root@mjwdj ~]# echo "baseurl=file:///mnt/" >> /etc/yum.repos.d/dvdiso.repo [root@mjwdj ~]# echo "enabled=1" >> /etc/yum.repos.d/dvdiso.repo [root@mjwdj ~]# echo "gpgcheck=0" >> /etc/yum.repos.d/dvdiso.repo [root@mjwdj ~]# yum clean all [root@mjwdj ~]# yum list
如果在 'yum list' 命令的输出中能够看到刚才制作的仓库里的软件包的名字,那就是 OK 了。再试着安装一个软件包看是否成功:
[root@mjwdj ~]# yum install mysql-server
原文地址:http://blog.chinaunix.net/space.php?uid=20346344&do=blog&id=3264166