1, 建立yum库文件夹:/var/ftp/pub/;
2, 将光盘中Server文件夹复制到yum库文件夹内,权限不做修改(RHEL5);RHEL6将Server文件夹和Packages文件夹一起拷贝过去;
3, 找到createrepo的rpm包,使用rpm命令安装该文件包;RHEL6,需要先安装另外两个依赖文件:deltarpm-3.5-0.5.20090913git.el6.i686.rpm和python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm;然后安装createrepo-0.9.8-4.el6.noarch.rpm;
4, 用命令createrepo建立repodata的索引文件:createrepo /var/ftp/pub/Server;
如果缺少这步,会报错无法继续向下执行下去如下:
---> Downloading header for yum-utils to pack into transaction set.
media://1192663619.181374%234/xxxxxxxxxx: [Errno 4] IOError: <urlopen error unknown url type: media>
Trying other mirror.
Error: failed to retrieve yum-utils-1.0.4-3.el5.noarch.rpm from dvd-server
error was [Errno 4] IOError: <urlopen error unknown url type: media>
5, 建立yum源配置文件:vi /etc/yum.repos.d/base.repo
6, 将 /etc/yum.repos.d/ 下的原repo文件删除,不然的话,测试会报如下错误:
Error: Cannot retrieve repository metadata (repomd.xml) for repository: InstallMedia. Please verify its path and try again
7, 测试yum是否正常可用:yum clean all;yum makecache;yum install httpd;
完成。
转载于:https://blog.51cto.com/nan1hao/591503