Monday, November 5, 2007

use NFS/http to create yum repository

YUM Server:
1. download and install createrepo rpm from http://dag.wieers.com/rpm/packages/createrepo/
or you can install rpmforge rpm from http://dag.wieers.com/rpm/FAQ.php#A1
after that, if it's RHEL, you might need to 'yum install createrepo', if it's centos, it might be already there.
2. on yum server, you need NFS and createrepo as follows:
[root@mars rh5]# more /etc/exports
/data/centos5 *(ro,sync,root_squash,anonuid=65534,anongid=65534)
/data/rh5 *(ro,sync,root_squash,anonuid=65534,anongid=65534)

[root@mars rh5]# ls
1 3 5 repodata rhel-5-server-i386-disc1.iso rhel-5-server-i386-disc3.iso rhel-5-server-i386-disc5.iso
2 4 md5sum rh5.md5 rhel-5-server-i386-disc2.iso rhel-5-server-i386-disc4.iso tmp

[root@mars rh5]# more /etc/modprobe.conf
alias eth0 e100
alias scsi_hostadapter aic7xxx
alias scsi_hostadapter1 aacraid
options loop max_loop=64
(note: if you didn't put the last option, you don't have to reboot server actualy, just umount all loop devides and 'rmmod loop' , then add above line, run 'modprobe loop' to automatically create /dev/loop8-63 devices

3. mount all iso files as loopback
[root@mars yum.repos.d]# df -h | grep rh5
/data/rh5/rhel-5-server-i386-disc1.iso
630M 630M 0 100% /data/rh5/1
/data/rh5/rhel-5-server-i386-disc2.iso
631M 631M 0 100% /data/rh5/2
/data/rh5/rhel-5-server-i386-disc3.iso
630M 630M 0 100% /data/rh5/3
/data/rh5/rhel-5-server-i386-disc4.iso
629M 629M 0 100% /data/rh5/4
/data/rh5/rhel-5-server-i386-disc5.iso
224M 224M 0 100% /data/rh5/5
4. put all commands to /etc/rc.d/rc.local
cd /data/centos5
mount -o loop CentOS-5.0-i386-bin-1of6.iso 1
mount -o loop CentOS-5.0-i386-bin-2of6.iso 2
mount -o loop CentOS-5.0-i386-bin-3of6.iso 3
mount -o loop CentOS-5.0-i386-bin-4of6.iso 4
mount -o loop CentOS-5.0-i386-bin-5of6.iso 5

5. configureing http alias so that yum client can use http url as yum server location
[root@mars httpd]# pwd
/etc/httpd
[root@mars httpd]# grep rh5 conf/httpd.conf
Alias /rh5 "/data/rh5"

6. on yum client /etc/fstab, put
[root@hphost1 kernels]# grep rh5 /etc/fstab
mars:/data/rh5/ /nfs/rh5 nfs defaults 1 2

No comments: