在一次安装软件过程中,需要依赖包,但是这个依赖包没有在原先的ISO源里面。因为下载的系统包有CD1跟CD2,检查后发现所需的rpm包在CD2里面,直接配置CD2为yum源时缺需要CD1里面的rpm包。最后想了个办法,用软连接把两个ISO的包合并后得到一个完整的安装源。
在一台机器上配置后,可以在这台服务器上搭建http服务器,把它当作一个内网的yum仓库使用。通过目录区分不同版本的yum源,简化并统一内网服务器的yum源配置。
一、原始的yum配置。
[root@mysql-243 ~]# cat /etc/yum.repos.d/cd.repo
[iso]
name=iso
baseurl=file:///mnt/iso/
enabled=1
gpgcheck=0
[root@mysql-243 ~]# mount /dev/cdrom /mnt/iso/
mount: block device /dev/sr0 is write-protected, mounting read-only
#### 安装rrdtool-perl时候报错 ####
[root@mysql-243 ~]# yum install rrdtool-perl -y
......
Error Downloading Packages:
rrdtool-perl-1.3.8-6.el6.x86_64: failure: Packages/rrdtool-perl-1.3.8-6.el6.x86_64.rpm from iso: [Errno 256] No more mirrors to try.
#### 查看ISO目录下,未发现rpm包 ####
[root@mysql-243 ~]# ls /mnt/iso/Packages/ |grep rrdtool-perl
#### 挂载CD2,并查看发现该rpm包在CD2上面 ####
[root@mysql-243 yum.repos.d]# umount /mnt/iso/
[root@mysql-243 ~]# mount -o loop /vm/iso/CentOS-6.5-x86_64-bin-DVD2.iso /mnt/iso
[root@mysql-243 ~]# grep *rrdtool-perl*
#### 再次安装时找不到其他依赖包 ####
[root@mysql-243 ~]# yum install rrdtool-perl -y
Error Downloading Packages:
rrdtool-1.3.8-6.el6.x86_64: failure: Packages/rrdtool-1.3.8-6.el6.x86_64.rpm from iso: [Errno 256] No more mirrors to try.
dejavu-sans-mono-fonts-2.30-2.el6.noarch: failure: Packages/dejavu-sans-mono-fonts-2.30-2.el6.noarch.rpm from iso: [Errno 256] No more mirrors to try.
dejavu-fonts-common-2.30-2.el6.noarch: failure: Packages/dejavu-fonts-common-2.30-2.el6.noarch.rpm from iso: [Errno 256] No more mirrors to try.
dejavu-lgc-sans-mono-fonts-2.30-2.el6.noarch: failure: Packages/dejavu-lgc-sans-mono-fonts-2.30-2.el6.noarch.rpm from iso: [Errno 256] No more mirrors to try.
二、卸载当前ISO,将两个ISO分别挂载到/mnt/cd1,/mnt/cd2上,然后通过软链接的形式合并两个ISO的rpm包。
[root@mysql-243 ~]#umount /mnt/iso/
[root@mysql-243 ~]#mkdir -p /mnt/iso/6.5/Packages
[root@mysql-243 ~]#mkdir /mnt/cd1
[root@mysql-243 ~]#mkdir /mnt/cd2
[root@mysql-243 ~]#mount -o loop /vm/iso/CentOS-6.5-x86_64-bin-DVD1.iso /mnt/cd1
[root@mysql-243 ~]#mount -o loop /vm/iso/CentOS-6.5-x86_64-bin-DVD2.iso /mnt/cd2
[root@mysql-243 ~]#ln -s /mnt/cd1/Packages/* /mnt/iso/6.5/Packages/
[root@mysql-243 ~]#ln -s /mnt/cd2/Packages/* /mnt/iso/6.5/Packages/
[root@mysql-243 ~]#rm -f /mnt/iso/6.5/Packages/TRANS.TBL
[root@mysql-243 ~]#cat /mnt/cd1/Packages/TRANS.TBL /mnt/cd2/Packages/TRANS.TBL |sort > /mnt/iso/6.5/Packages/TRANS.TBL
[root@mysql-243 ~]#ln -s /mnt/cd1/repodata/ /mnt/iso/6.5/
[root@mysql-243 ~]#
三、修改yum配置,并测试安装。
#### 由于新建立的目录修改为/mnt/iso/6.5/,需要对原先的yum源进行修改 ####
[root@mysql-243 /]# cat /etc/yum.repos.d/cd.repo |grep baseurl
baseurl=file:///mnt/iso/6.5/
[root@mysql-243 ~]#yum clean all
[root@mysql-243 ~]#yum list all
#### 整合后能够成功安装rrdtool-perl ####
[root@mysql-243 ~]#yum install rrdtool-perl -y
......
Installed:
rrdtool-perl.x86_64 0:1.3.8-6.el6
Dependency Installed:
dejavu-fonts-common.noarch 0:2.30-2.el6 dejavu-lgc-sans-mono-fonts.noarch 0:2.30-2.el6 dejavu-sans-mono-fonts.noarch 0:2.30-2.el6 rrdtool.x86_64 0:1.3.8-6.el6
Complete!
四、接下来部署apache服务搭建本地的yum源,将/mnt/iso/目录以http的方式发布出去。
#### 安装apache ####
[root@mysql-243 ~]#yum install httpd -y
#### 发布yum仓库 ####
[root@mysql-243 ~]#cat /etc/httpd/conf.d/yum.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /mnt/iso/
</VirtualHost>
<Directory "/mnt/iso/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
[root@mysql-243 ~]# chkconfig httpd --level 345 on
[root@mysql-243 ~]#/etc/init.d/httpd restart
#### 添加ISO盘开机自动挂载。直接将挂载写在rc.local文件里。 ####
#### 此处不建议修改/etc/fstab,以避免移除ISO导致系统启动失败。####
[root@mysql-243 ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
mount -o loop /vm/iso/CentOS-6.5-x86_64-bin-DVD1.iso /mnt/cd1
mount -o loop /vm/iso/CentOS-6.5-x86_64-bin-DVD2.iso /mnt/cd2