Tuesday, December 27, 2011

Configure Yum Server on Red Hat Enterprise Linux 5(Part-1)


Configuring Local Yum Server on RHEL 5

Overview:

Yum or yellow dot update manager is the front of RPMs. It is only design for packages dependencies. Yum can collect packages from more than one location. To download & install RPM packages, it use a repository file, a repository is a single collection point for all documents that relate to the program. Generically repository refers to a central place where data is stored and maintained. A repository can be a place where multiple databases or files are located for distribution over the network, or a local machine. Yum first read this file list then it can download & install the packages.

Why Yum?

Generally in every Linux platform, it is difficult to install the packages (Software), because in Linux a single package is related with other packages, so if you want to install any package or packages then you need to know the other related packages/dependent packages name, but it is tough to remember so you can install packages by using yum. By using yum you can solve to installing all the dependent packages, this way you can remove the dependencies problem. Yum could be use as Local server that means by configuring yum you can install packages on local machine or can be use remote machines on your network. You can also download and install packages from internet by using yum.

Pre-requisites of Yum Server:

§  A Linux Server with IP address 210.207.201.254 & hostname yumsrv
§  A Linux Client with IP address 210.207.201.x & hostname pc1
§  Configure NIC card on every machine
§  Update /etc/hosts file on both Linux system or use DNS system for name resolution.
§  A DVD-ROM with RHEL5 DVD 

Necessary configuration for Server & Client Machine

IP Configuration: Change your server & client machine IP address as like below.

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

#Broadcom Corporation Net link BCM57875 Gigabyte Ethernet PCI Express
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29: EB: B2: CA
ONBOOT=yes
TYPE=Ethernet
PEERDNS=no
USERCTL=no
IPV6INIT=no
IPADDR=210.207.201.254
NETMASK=255.255.255.0
NETWORK=210.207.201.0
BROADCAST=210.207.201.255

Changing Host name: Change your server & client machine name as like below.

[root@localhost ~]# vi /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=yumsrv

Local Yum Server

Step-1: Mounting the RHEL5 DVD.

Insert the RHEL5 DVD into your DVD-ROM and create a directory under the /mnt/ directory named rhel5 then mount the DVD into /mnt/rhel5/ directory.

[root@yumsrv ~]# mkdir /mnt/rhel5
[root@yumsrv ~]# mount /dev/block device name /mnt/rhel5/

Note: If you are using usb-dvd-rom then your block device name will be scd0, if your device IDE dvd-rom then your device will dvd-hdd, if else you are using SATA dvd-rom then device will be only dvd, but keep remember it that when you are working on Vmware Workstation then you have to use only cdrom.

Step-2: Copy all the files from DVD source.

Create a directory into /var/www/html/rhel5 then copy all the file from /mnt/rhel5 directory and keep into /var/www/html/rhel5 directory

[root@yumsrv ~]# mkdir /var/www/html/rhel5
[root@yumsrv ~]# cp –r /mnt/rhel5/* /var/www/html/rhel5/

Or you can directory copy /mnt/rhel5 directory without creating /var/www/html/rhel5 directory

[root@yumsrv ~]# cp –r /mnt/rhel5 /var/www/html/

Step-3: Unmount and eject the DVD

[root@yumsrv ~]# umount /mnt/rhel5/
[root@yumsrv ~]# eject /dev/block device name

Step-4: Installing createrepo RPM package for creating Repository file for DVD source.

Now go to the mount point directory (var/www/html/rhel5/) and execute the command below for installing the RPM package.

[root@yumsrv ~]# cd /var/www/html/rhel5/Server/
[root@yumsrv Server]# rpm –ivh createrepo-0.4.11-3.el5.noarch.rpm
Warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing…
########################################### [100%]
1:createrepo
########################################### [100%]

Step-5: Creating Repository file.

Now go to the /var/www/html/rhel5/ directory and create repodata file for DVD source.

[root@yumsrv ~]# cd /var/www/html/rhel5/
[root@yumsrv rhel5]# createrepo .

Step-6: Edit yum.conf file.

Now finally tell to yum use this “repo” frile for installing packages. It will automatically done by configuring yum.conf file

[root@yumsrv ~]# vi /etc/yum.conf

[main]
gpgcheck=0
plugins=0

[RHEL5-repository]
name=Red Hat Enterprise Linux Local Repository
baseurl=file:///var/www/html/rhel5
enabled=1
gpgkey=file:///var/www/html/rhel5/RPR-GPG-KEY-redhat-release

Step-7: Create Local debug information.

Now configure the debug information for DVD source by editing rhel-debuginfo.repo file.

[root@yumsrv ~]# cd /etc/yum.repos.d
[root@yumsrv ~]# cp rhel-debuginfo.repo  rhel5.repo
[root@yumsrv yum.repos.d]# vi rhel5.repo

[RHEL5-Debuginfo]
name=Red Hat Enterprise Linux Local Repository Debuginfo
baseurl=file:///var/www/html/rhel5
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-key-redhat-release

Note: Remove or move the rhel-debuginfo.repo file, otherwise yum will try to use this file.

Step-8: Disable RHN Plug-ins.

Now finally disable the RHN plug-ins and tell to yum that just install the packages.

[root@yumsrv ~]# cd /etc/yum/pluginconf.d
[root@yumsrv pluginconf.d]# vi rhnplugin.conf

[main]
enables=0
gpgcheck=0

[rhel-i386-server-5]
enabled=0

Step-9: Testing the yum server.

Now verify that your Yum is working properly by following this command.

[root@yumsrv ~]# yum clean all
[root@yumsrv ~]# yum update
[root@yumsrv ~]# yum list
[root@yumsrv ~]# yum install kernel* gcc* lib* httpd* vsftpd* -y
[root@yumsrv ~]# yum erase kernel* gcc* lib* httpd* vsftpd* -y

So, now you can install & uninstall your all required packages by using yum command with install & erase command.

Configure yum server for Client machine:

If you want to provide client machine to download & install the packages via yum server, then you will have to enable following services below on your yum server. In this case I am describing both of them, but in real world you can configure both of them or one of them.

§  By Enabling HTTP Services
§  By Enabling FTP Services

Enabling HTTP Services in Yum Server

Step-1: Installing http RPM package

[root@yumsrv ~]# yum install httpd* -y

Step-2:  Configuring the httpd.conf file.

Now go to the main configuration file for enabling http services

[root@yumsrv ~]# vi /etc/httpd/conf/httpd.conf

Directives
Discription
Line Number
Orginal File Text
Modified File Text
Listen
Specify the Port Number where apache will listen on
134
80
210.207.201.254:80
ServerAdmin
e-mail address of the server administrator
251
root@localhost
ServerName
Put the host name(FQDN)of web server
265
DocumentRoot
Specify the html file location of the web server
281
“/var/www/html”
“/var/www/html”
NameVirtualHost
Set web Server IP which will contain the virtual host
972
*:80
210.207.201.254:80

** Also go to the end of the configuration file for configuring Virtual host

<VirtualHost 210.207.201.254:80>
     ServerAdmin     root@210.207.210.254
     DocumentRoot    /var/www/html
     ServerName 210.207.201.254
</virtualHost>

Tips: To edit httpd.conf file set Line number & enter Follow the method.

Esc → set number → Enter → Esc → Shift+: → type line number which you want to edit → Enter → press I for insert mode → then edit → Save & Exit.

Step-3:  Editing hosts file

If DNS is not use for http services then you put the host name and IP address of yum server in to the /etc/hosts file in every client machine otherwise packages will be failed to download & install. The configuration file will look like below,

[root@yumsrv ~]# vi /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
210.207.201.254 yumsrv     yumsrv

Step-4:  After configuring http service you have to restart httpd service

[root@yumsrv ~]# service iptables stop
[root@yumsrv ~]# chkconfig iptables off
[root@yumsrv ~]# service network restart
[root@yumsrv ~]# service httpd restart
[root@yumsrv ~]# chkconfig httpd on

HTTP Client side configuration

Step-3:  Editing hosts file

[root@yumsrv ~]# vi /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
210.207.201.254 yumsrv     yumsrv
210.207.201.x   pc1        pc1

Step-1:  Locating repository information

[root@pc1 ~]# vi /etc/yum.conf

[main]
gpgcheck=0
plugins=0

[RHEL5-Repository]
name=Red Hat Enterprise Linux Local Repository
baseurl=http://210.207.201.254/rhel5
enabled=1
gpgcheck=0
gpgkey=http://210.207.201.254/rhel5/RPM-GPG-KEY-redhat-release

Step-2:  Locating debug information

[root@pc1 ~]# cd /etc/yum.repos.d/
[root@pc1 yum.repos.d]# cp rhel-debuginfo.repo  rhel5.repo
[root@pc1 yum.repos.d ~]# vi rhel5.repo

[RHEL5-Debuginfo]
name= Red Hat Enterprise Linux Local Repository Debuginfo
baseurl=http://210.207.201.254/rhel5
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Note: Now remove or move the rhel-debuginfo.repo file, otherwise yum will be try to use this file

Step-3:  Disable RHN plug-ins

[root@pc1 ~]# cd /etc/yum/pluginconf.d
[root@pc1 ~ pluginconf.d]# vi rhnplugin.conf

[main]
enabled=0
gpgcheck=0

[rhel-i386-server-5]
enabled=0

Step-4:  Testing the server

Now verify that your client can download and install packages from yum server by typing the command below.

[root@pc1 ~]# yum clean all
[root@pc1 ~]# yum update
[root@pc1 ~]# yum list
[root@pc1 ~]# yum install kernel* gcc* lib* httpd* vsftpd* -y
[root@pc1 ~]# yum erase kernel* gcc* lib* httpd* vsftpd* -y

So, now you can install & uninstall your all required packages from local http server by using yum command.

Enabling FTP Services in Yum Server

Your client can download and install packages from yum server using FTP services. For providing FTP services you have to create a public directory named “rhel5” into /var/ftp/pub/ directory and put all the packages in it.

Step-1:  Installing the ftp package

[root@yumsrv ~]# yum install vsftpd*

Step-2:  Edit the vsftps.conf file

[root@yumsrv ~]# vi /etc/vsftpd/vsftpd.conf

Directives
Line Number
Orginal File Text
Modified File Text
Anonymous_enable
12
YES
YES

Note: rempve the “#” from line number 27,31,81,81 but do not removw “#” from the line 89 & 91.

[root@yumsrv ~]# service iptables stop
[root@yumsrv ~]# chkconfig iptables off
[root@yumsrv ~]# service network restart
[root@yumsrv ~]# service vsftpd restart
[root@yumsrv ~]# chkconfig vsftpd on

Client side configuration

Follow the “HTTP Client configuration” Just replacehttp://210.207.201.254/rhel5
With ftp://210.207.201.254/pub/rhel5. Also configure the “/etc/hosts” file.

1 comments:

  1. thank you this article.
    I am sharing this article in tuts publication network -> http://tutpub.com/

    ReplyDelete