Search Posts on Binpipe Blog

Creating Offline RPM Repository in Redhat & CentOS Linux

Redhat / CentOS flavours of Linux use YUM to manage software updates and package installers. Here are the steps to create a local offline repository for installation.

Creating RPM Repository in Local Server

1. Insert your Red hat DVD installer inside DVD ROM.
2. Mount the DVD by
[root@localhost ~]#mounts /dev/cdrom /media
3. Create a folder of your choice. In my case I have created /home/rpms
4. Copy all the RPM from /media/Server/ to /hom/rpms folder
[root@localhost ~]#mkdir /home/rpms  [root@localhost ~]#cp -rv /media/Server/*  /home/rpms
6. Now look for a folder /etc/yum.repos.d. If the directory exists then YUM package is already installed and you can skip this step. So you just need to configure. If it is not there you have to install yum and yum-utils package. Also install one RPM called createrepo.
[root@localhost rpms]# cd /media/Server/  
[root@localhost Server]# rpm -ivh yum-3.0.1-5.el5.noarch.rpm  
[root@localhost Server]# rpm –ivh yum-utils-1.0.4-3.el5.noarch.rpm  
[root@localhost Server]# rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
7. Once YUM packages are installed you will get the /etc/yum.repos.d folder. Go inside the folder and open the entire .repo file present inside that folder. In all .repo file search for
enabled = 1
and replace by
enabled = 0
This means you are disabling the default repository locations or else you can delete all repo files.
8. Edit the /etc/yum.conf file,change the following line:

keepcache=0 to keepcache=1
9. Now prepare the directory /rpms to act as a repository. For this we run the command
[root@localhost ~]createrepo -p /rpms 
This command will take some time to finish and once finished you can see a directory called repodata will be created inside the /rpms directory.
11.If some error comes like "Cannot delete .olddata" Then you have to remove it manually by "rm -rf /home/rpms/.olddata"
yum error 39
10. Now create a file myrepo.repo inside /etc/yum.repos.d folder
[root@localhost ~]touch /etc/yum.repos.d/myrepo.repo
11. Put the following contents inside the myrepo.repo file
[myrepo]   name=My Local Repo   baseurl=file:///home/rpms   enabled=1   gpgcheck=0
Save the file and exit.
Now your repository is ready. Before running any installation first clean the cache by
Yum clean all
Now you can install anything like
[root@localhost ~]yum install httpd
You will get a screen like below where you have to say "y" or "n"
yum installation
N:B-Here I have used file:// protocol as base url.You can use ftp:/// or http:// if you have remote repository location.

Common Errors and their solutions

1)Errno 256:Metadata file does not match checksum
Solution:
1) Edit /etc/yum.conf and add the following line
http_caching=packages
2) Run "yum clean metadata"
3) Retry the yum install
2)"TypeError: rpmdb open failed" or "TypeError: rpmdb unable to join the environment"
Solution:
# yum clean all  
#rm -f /var/lib/rpm/__db*  
#rpm –rebuilddb  
#yum update
3)ValueError: need more than 1 value to unpack
Solution:
#yum clean all

#yum clean metadata
#yum clean dbcache

and then execute
#yum makecache
4)thread.error: can't start new thread
Solution:
#rm /usr/lib/yum-plugins/ threading.py
#yum update
5)[Errno -3] Error performing checksum
Solution:
#createrepo -v -s sha1 <repository location>
#yum clean all
6)TypeError: unsubscriptable object
Solution:
#yum clean metadata
#yum update missing dependency error
Solution:
#yum clean all
#yum update
7)Yum install GPG error
Solution:
#rpm --import /etc/pki/rpm-gpg/RPM*
8)Error: Cannot retrieve repository metadata (repomd.xml)
Solution:
This is a network issue.Please check DNS,Proxy etc. settings for the same.

No comments:

Post a Comment

Hi, Leave a comment here and one of the binary piper's will reply soon :)