Saturday, December 8, 2012

YUM Server in RHEL 5 configuration


How To Install YUM Server In Red-hat(RHEL5)

In Linux you can install packages through many ways like.
1. Through RPM,
2. Through shell script
3. Through source tar balls etc.

YUM(Yellow-dog Updater and Modifier) is another and advanced way of installing the packages in Linux distro’s such as Red-hat, Fedora and CenOS.
In RHEL4 installing packages is a tedious process, some times its headache to install all the dependencies. So Red-hat come with a solution to overcome this dependencies problem in most situations, the solution for this is nothing but YUM implementation. This will resolve this dependency issue and other known issues. Here we are going to present some basic way how to use YUM utility to install packages locally(there are so many ways to install packages from different sources either local or remote such as ftp, http).

Basic YUM implementation locally:

Step1 :Copy the entire OS cd’s (DVD) content to Hard-drive as below.

#cp -ar /media/cdrom/Server/* /destinationfolder

Example :
server1#cp -ar /media/cdrom/Server/* /var/ftp/pub/Server/
Note :
1. From second cd too Server content in to our /var/ftp/pub/Server/ folder as shown below.
2. Here please take destination folder as /var/ftp/pub so that we can implement FTP server to share our repository.
3. If you have RHEL5 DVD then execute below command once.


server1#cp -ar /media/cdrom/Server/* /var/ftp/pub/Server/
 
Step2 : Now change the directory to /var/ftp/pub/Server and install the createrepo package

server1#cd /var/ftp/pub/Server
server1#rpm -ivh createrepo*   

Step3 : Specify the repository location to YUM.

server1#createrep -v .

Note:There is the dot in the above command.


Step4 :
Create a file with repo as extension and specify the YUM details in /etc/yum.repos.d folder


server1#cd /etc/yum.repos.d/
server1#vi testing.repo

Note : The directory /etc/yum.repos.d/ contaions two .repo files which should be removed or moved to other directory, so that YUM server will check default .repo file it self.

Q. What if I don’t move or remove the default .repo files from /etc/yum.repos.d/ folder?
A: Every time when you try to install packages through YUM, your yum will check all these files for repositories for getting packages which will or will not work and most probably delay is increased in getting those packages from online servers.
The new file which is created contains as follows.
[server1.example.com]
comment ="Vikas Linux Repo -- Repo 01"
baseurl=file:///var/ftp/pub/Server
gpgcheck=0
After entering these entries save and exit from the file.
Let me explain what actually these four entries mean.
[server1.example.com] ==>This informs what is the repository name.
comment ==> Its used to see the information about the repo.
baseurl ==> This is the server and path of the repo(here its a local repo so the base url is just a file:///
For example you are creating YUM client through FTP then base url should be like this

baseurl=ftp://station1.example.com/pub/Server
gpgcheck ==> This is to check the authentication of the repository, which is disabled in this case.
Local YUM repository is created, now you can install any package you want with yum command. In order to know more about YUM, Please see man pages for YUM.
Note:In-order to use yum repository we have to clean the yum meta data, so before installing any package first time use yum clean all command as shown below.


server1#yum clean all
 
Basic YUM Server Repository through FTP server :
So what about Installing packages remotely by using this repository?
Let us see how to configure client to access this repository. Before doing client configuration we have to share this repository through FTP or HTTP.

Step1 : Install vsftpd server on server

server1#yum install vsftpd

Step2 : Start the ftp service and on it
 
server1#service vsftpd restart
server1#chkconfig vsftpd on

That’s it on the server side every thing configured properly, Now move on to client machine.

Conflagration on client side :
Step3 : Remove/move the local repository file from /etc/yum.repo.d/ folder to some other location #mv /etc/yum.repo.d/* /tmp/
Step4 : Create server.repo file in /etc/yum.repo.d/ with following contents
[server1.linuxnix.com]

comment ="test"

baseurl=ftp://server1.example.com/pub/Server

gpgcheck=0
Save and exit the file Now start using yum to install packages, as follows.
client1#yum clean all
client1#yum install packagename
Example :
client1#yum install httpd
To uninstall a package through YUM
client1#yum remove httpd
To see the info of a package
client1#yum info packagename
To see the package is already installed or not
client1#rpm -qa grep packagename

No comments:

Post a Comment