Showing posts with label Package Management. Show all posts
Showing posts with label Package Management. Show all posts
Pawan Sharma | March 22, 2013 | Be the first to comment!

Configure YUM server to install/update packages on remote server

In the previous post we learn how to create a YUM repository or YUM server on Redhat Enterprise Linux 6. Now if you want to use this YUM server to manage packages on other servers follow below mentioned steps.

1. Create the YUM server as described in previous post.
2. Install vsftpd using yum command.

# yum install vsftpd

3. Make changes in “/etc/vsftpd/vsftpd.conf” as below.

anonymous_enable=YES
anon_root=/mnt

4. Login to the client machine on which you want to install packages.
5. Create a .repo file in “/etc/yum.repos.d/” directory.

# vi /etc/yum.repos.d/RHEL6.repo

[RHEL6]
name= RHEL 6 remote repository
baseurl=file:///yum_server_ip/
enabled=1
gpgcheck=0

6. Run command yum clean all.

# yum clean all

You can now use yum commands to install, remove and query packages.

# yum info httpd

Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify,
               : versionlock
Updating certificate-based repositories.
Loading support for Red Hat kernel ABI
Installed Packages
Name           : httpd
Arch           : x86_64
Version        : 2.2.15
Release        : 15.el6
Size           : 2.9 M
Repo           : installed
From repo      : anaconda-RedHatEnterpriseLinux-201105101844.x86_64
Summary        : Apache HTTP Server
URL            : http://httpd.apache.org/
License        : ASL 2.0
Description    : The Apache HTTP Server is a powerful, efficient, and extensible
               : web server.

Please comment if you have any questions.

Pawan Sharma | March 20, 2013 | Be the first to comment!

Configure YUM server in Redhat Enterprise Linux 6 (RHEL6)

Package management is one of the main objectives of RHCSA certification exam. Also as a system administrator you have to install, remove and update packages. In this post we will learn how to configure YUM server for package management on local machine as well as on remote machines. Yum server gives ease to package management in Linux. Using yum server you can query about installed packages, install or remove packages and upgrade or degrade packages as per your requirements.

The main configuration file for yum server is “/etc/yum.conf”. YUM server gets you out of which we know as “Dependency Hell”. It resolves and installs all dependencies related to a package. YUM server creates a database of packages. In this database it stores information like: all installed packages, all available packages, updates, etc. In this post we will see:

  • How to configure local YUM server for RHEL6 DVD iso.
  • How to create YUM server to update packages through FTP.
  • How to configure YUM clients.

STEPS TO CONFIGURE YUM SERVER.

In this exercise we will use RHEL6 DVD.iso. You can mount and copy contents of DVD on local server or if you don’t have enough space you can mount and directly use it as a repository. For now we will mount RHEL6 DVD.iso and use it as our repository for packages.

1. Mount the RHEL6 DVD.iso on /mnt (you can mount it on any directory of your choice).

# mount -o loop rhel-server-6.2-x86_64-dvd.iso /mnt

2. Create a new file in directory “/etc/yum.repos.d/”.

Note: “/etc/yum.repos.d/” directory is default configuration directory for yum. You have to create a file with extension “.repo” and make below mentioned entries in the file.

# vi /etc/yum.repos.d/RHEL6.repo

[RHEL6]
name= RHEL 6 local repository
baseurl=file:///mnt/
enabled=1
gpgcheck=0

3. Run command yum clean all.

# yum clean all

4. You can now use yum commands to install, remove and query packages.

# yum info httpd

Loaded plugins: aliases, changelog, downloadonly, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify,
             : versionlock
Updating certificate-based repositories.
Loading support for Red Hat kernel ABI
Installed Packages

Name          : httpd
Arch          : x86_64
Version       : 2.2.15
Release       : 15.el6
Size          : 2.9 M
Repo          : installed
From repo     : anaconda-RedHatEnterpriseLinux-201105101844.x86_64
Summary       : Apache HTTP Server
URL           : http://httpd.apache.org/
License       : ASL 2.0
Description   : The Apache HTTP Server is a powerful, efficient, and extensible
              : web server.


In the next post we will learn how to install/update packages on a remote server form yum server.


Pawan Sharma | March 17, 2013 | Be the first to comment!

Package Management in RHEL6: YUM

Package management is one of the main objectives of RHCSA and RHCE exams on RHEL6. It is required to install and configure packages during the certification exam. In previous posts we have discussed installing package using rpm command. In Redhat Enterprise Linux 6 (RHEL6), to install a package we also have to install its dependencies.

This could be a difficult process as some packages have more than 50 dependent packages so we have to find out those dependent packages and install all of them one by one, also there could be dependency for the dependency. In Linux this is called “Dependency Hell”. To make this process easier, we can create a local YUM server or can configure a YUM server on FTP/HTTP to make it as a centralized repository for all servers.

YUM (Yellow Dog updater, modifier) maintains a database regarding the packages. This database contains information about installed packages, available packages, and automatically resolves dependencies while installing packages. The yum database is also known as repository.

What is a repository?

A repository is collection of rpm packages. Repository can also include group of packages. For example RHN includes following RHEL6 repositories:

Red Hat Enterprise Linux Server: This is the main repository, which includes both packages associated with installation of RHEL6 and updated packages.

  • RHN Tools: Repository for managing RHN connections and Kickstart installation.
  • RHN Server Supplementary: Repository of packages other that open source like adobe and java.
  • RHELV2VWIN: Repository to support package to read Microsoft formatted partitions.
  • RHEL Server Optional: Large group of packages other than server package like desktop packages, etc.

Each repository contains a database about the packages in the repository. This database can be found under repodata directory in each repository. This database contains information about each package and its dependencies.

You can also create your own repository of packages. To create a repository, you need createrepo package installed.

In the next post we will see how to configure YUM server and Client. Also we will learn how to create YUM server for RHEL6 DVD iso to update packages on local and remote machines.

Pawan Sharma | December 18, 2012 | Be the first to comment!

How to Upgrade/Update Kernel in Redhat Enterprise Linux 6 (RHEL6)

In this post we will see how to update KERNEL package. As a system administrator you may require to upgrade kernel package. Upgrading kernel package is necessary for adding new features, resolving security related issues, etc. Kernel upgrade can cause problems if other packages depend on current kernel version.

If you are interested in new kernel, never use -U option as this overwrites the existing kernel and it would be hard to revert the changes. The best option to upgrade a kernel is to install new one.

You can install new kernel package using below mentioned command in Redhat Enterprise Linux 6 (RHEL6).



Linux Kernel Architecture.

# rpm -ivh new_kernel.rpm


Above command install new kernel, and related files, along with the old one.

In the below example we will upgrade kernel from 2.6.32-220.el6.x86_64 to 2.6.32-220.2.1.el6.x86_64:

To see the current kernel version:

# uname -r
2.6.32-220.el6.x86_64


Download new kernel package and install:

# rpm -ivh kernel-2.6.32-220.2.1.el6.x86_64.rpm

warning: kernel-2.6.32-220.2.1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

Preparing...               ########################################### [100%
1:kernel                   ########################################### [100%]


To verify the new kernel is installed, list contents of /boot directory:

# ls /boot/

config-2.6.32-220.2.1.el6.x86_64
config-2.6.32-220.el6.x86_64
efi
grub
initramfs-2.6.32-220.2.1.el6.x86_64.img
initramfs-2.6.32-220.el6.x86_64.img
lost+found
symvers-2.6.32-220.2.1.el6.x86_64.gz
symvers-2.6.32-220.el6.x86_64.gz
System.map-2.6.32-220.2.1.el6.x86_64
System.map-2.6.32-220.el6.x86_64
vmlinuz-2.6.32-220.2.1.el6.x86_64
vmlinuz-2.6.32-220.el6.x86_64


After installation of new kernel there will be an entry for new kernel in /etc/grub.conf (/boot/grub/grub.conf).

# cat /etc/grub.conf

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/OSVG-lvroot
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-220.2.1.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-220.2.1.el6.x86_64 ro root=/dev/mapper/OSVG-lvroot rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=OSVG/lvswap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=OSVG/lvroot  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-220.2.1.el6.x86_64.img
        title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)

        root (hd0,0)
        kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/OSVG-lvroot rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=OSVG/lvswap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=OSVG/lvroot  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-220.el6.x86_64.img


As you can see above that default kernel at boot time is 0 which is new kernel.
Reboot the server and check for the new kernel. If new kernel does not work you can change default option to 1, to boot form the old kernel.

After server restart verify the new kernel version.

# uname -r
2.6.32-220.2.1.el6.x86_64

# rpm -qa kernel
kernel-2.6.32-220.el6.x86_64
kernel-2.6.32-220.2.1.el6.x86_64


In the next post we will learn package management through YUM to automatically resolve dependencies.

Pawan Sharma | December 11, 2012 | | Be the first to comment!

Package Management in RHEL6: RPM

One of the major duties of a system administrator is to manage applications/software on the server. System administrator needs to know how to add and remove or get information about packages. In this post we will learn RPM (Redhat Package Manager) commands to manage software on Redhat Enterprise Linux 6. To pass the RHCSA certification exam this RHCSA objective is must. In this post we will learn:

  • What is RPM PACKAGE?
  • How to install .rpm package file in Redhat Enterprise Linux 6(RHEL 6)?
  • How to remove/erase rpm package in RHEL 6?
  • How to query about a package in RHEL 6?
  • How to check signature of rpm package?

In RHEL 6 applications/software comes in the form of package. In general package is a container of files. A package includes binary scripts, configuration files and documentation files. A RPM package name usually includes version and architecture. For example openssh-5.3p1-70.el6.x86_64 in this openssh is package name 5.3p1 is version build 70, x86_64 is architecture.

In Redhat Enterprise Linux 6 software packages have their dependent packages. RPM package installation won’t work if there are dependencies. To install a .rpm package use below mentioned command:

# rpm -i package_name
# rpm -U package_name

The rpm -i option install the package if it is not already installed. The rpm -U option upgrades the package if it is installed or install if already not installed. I will suggest to use -vh option while install/upgrade package this will add verbose mode and hash mark to help monitor the installation process. Also at the time of installation, if some files are to be overwrite, it automatically takes a backup of the original file as .rpmsave extension.

NOTE: Before upgrading any package, take backup of all configuration files related to that package.


EXAMPLE:

In this example we will install gcc package.

# rpm -ivh gcc-4.4.6-3.el6.x86_64.rpm

warning: gcc-4.4.6-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
        cloog-ppl >= 0.15 is needed by gcc-4.4.6-3.el6.x86_64
        cpp = 4.4.6-3.el6 is needed by gcc-4.4.6-3.el6.x86_64
        glibc-devel >= 2.2.90-12 is needed by gcc-4.4.6-3.el6.x86_64

In the above example we can see that there is an error while installing “gcc-4.4.5-6.el6.x86_64.rpm” package and installation got failed. This so due to dependencies, gcc require cpp and libgomp package to install. So we have to install cpp, clog-ppl and glibc-devel package first.

# rpm -ivh cpp-4.4.6-3.el6.x86_64.rpm

warning: cpp-4.4.6-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
        libmpfr.so.1()(64bit) is needed by cpp-4.4.6-3.el6.x86_64

Again package “cpp-4.4.6-3.el6.x86_64.rpm” failed due to dependencies error. In Linux this is called “dependency hell”. To overcome this problem Redhat introduced YUM (Yellow Dog Modifier) which will find and resolve all dependency to install package. We will discuss YUM in some other post.

If a package don’t require any dependency or all dependencies are already installed the package will install.

# rpm -ivh squid-3.1.10-1.el6_1.1.x86_64.rpm

warning: squid-3.1.10-1.el6_1.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...             ########################################### [100%]
1:squid                  ########################################### [100%]

To remove a package use rpm -e command. Here e stands for erase.

# rpm -e squid

To check .rpm package signature user --checksig option:

# rpm --checksig firefox-3.6.24-3.el6_1.x86_64.rpm

firefox-3.6.24-3.el6_1.x86_64.rpm: RSA sha1 ((MD5) PGP) md5 NOT OK (MISSING KEYS: (MD5) PGP#fd431d51)

SOME MORE RPM COMMAND

  • rpm -q package_name: This will query if package is installed or not.

# rpm -q firefox
firefox-3.6.24-3.el6_1.x86_64

# rpm -q squid
package squid is not installed

  • rpm -qa: List all installed packages.

# rpm -qa

postfix-2.6.6-2.2.el6_1.x86_64
rpcbind-0.2.0-8.el6.x86_64
hpijs-3.10.9-3.el6.x86_64
system-config-printer-libs-1.1.16-22.el6.x86_64
filesystem-2.4.30-3.el6.x86_64
mdadm-3.2.2-9.el6.x86_64
…..
………..

  • rpm -ql package_name: List all files from package.
  • rpm -qc package_name: List only configuration files from package.
  • rpm -qf /path/filename: List packages associated with file.
  • rpm -qi package_name: List basic information about the package.

In the next post we will learn more about package management in RHEL 6 using YUM.

If you have any question or query please post comments.