Friday, August 31, 2012

How to add Oracle essential packages YUM repo

Normally you will need Oracle essential packages for Oracle 11gR2 Database and RAC installation & configuration.

#cd /etc/yum.repos.d

#wget http://public-yum.oracle.com/public-yum-ol6.repo

#yum list

#yum install oracle-rdbms-server-11gR2-preinstall

===============
For Other OS's:
===============

Download and copy the appropriate yum configuration file in place, by running the following commands as root:
Oracle Linux 4, Update 6 or Newer

# cd /etc/yum.repos.d
# mv Oracle-Base.repo Oracle-Base.repo.disabled
# wget http://public-yum.oracle.com/public-yum-el4.repo

Oracle Linux 5

# cd /etc/yum.repos.d
# wget http://public-yum.oracle.com/public-yum-el5.repo

Oracle Linux 6

# cd /etc/yum.repos.d
# wget http://public-yum.oracle.com/public-yum-ol6.repo

Oracle VM 2

# cd /etc/yum.repos.d
# wget http://public-yum.oracle.com/public-yum-ovm2.repo

Enable the appropriate repository by editing the yum configuration file

    Open the yum configuration file in a text editor
    Locate the section in the file for the repository you plan to update from, e.g. [el4_u6_base]
    Change enabled=0 to enabled=1

Begin using yum, for example:

#yum list

How to add remote FTP / HTTP repository to RHEL or CentOS 6/7

To do it, first you need to collect below two details;

  • FTP / HTTP YUM server IP i.e. "10.0.0.1"
  • Packages location on remote YUM server i.e. "/rhel6_64repo/Packages/"

Then create a repo file "rhel6_ftp_remote" in "/etc/yum.repos.d/" folder with below content;


[rhel6_ftp_remote]
name=Remote FTP Repository for RHEL6 $releasever – $basearch
baseurl=ftp://10.0.0.1/rhel6_64repo/Packages/
enabled=1
gpgcheck=0

If you want to add HTTP repo link, then replace "ftp" with "http".

[rhel6_http_remote]
name=Remote HTTP Repository for RHEL6 $releasever – $basearch
baseurl=http://10.0.0.1/rhel6_64repo/Packages/
enabled=1
gpgcheck=0

To add Local repo, read this article.

How to create and add a Local YUM Repository on RHEL or CentOS 7

How to setup local yum repository on RHEL or CentOS 7? 



This tutorial describes how to setup a local Yum repository on CentOS or RHEL 7 system. Later i will show you how you can use this repository to fetch software, security updates and fixes. Local repository is an efficient way to deploy new software's or patches as it will be over LAN where deployment will be fast, saving your internet bill.

I have two CentOS 7 systems here one is YUM repository server and another will be Client which will fetch the updates from repository server over FTP protocol.


Setting up YUM repo server with FTP:

Step 1. Mount CentOS 7 ISO and copy all the RPM packages to a FTP directory:

[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# mkdir /var/ftp/pub/localrepo

[root@localhost ~]# cp -ar /mnt/Packages/* /var/ftp/pub/localrepo/


Step 2. Install vsftpd package and start it's service:

[root@localhost ~]# cd /mnt/Packages/

[root@localhost ~]# rpm -ivh vsftpd-3.0.2-25.el7.x86_64.rpm

[root@localhost ~]# systemctl enable vsftpd

[root@localhost ~]# systemctl start vsftpd


Step 3. Install "createrepo" package and it's dependencies:

[root@localhost ~]# rpm -ivh libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

[root@localhost ~]# rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm

[root@localhost ~]# rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm

[root@localhost ~]# rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm


Step 4. Create repository

[root@localhost ~]# createrepo -v /var/ftp/pub/localrepo/


Step 5. If this repository is going to be on your LAN then disable firewall and SELinux:

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# systemctl disable firewalld

To disable SELinux, edit file /etc/sysconfig/selinux,

SELINUX=disabled

Save, exit and reboot host.


Step 6. [OPTIONAL] Test if repository is working fine on YUM server:

[root@localhost ~]# vi /etc/yum.repos.d/localrepo.repo

[localrepo]
name=Local Repository
baseurl=file:///var/ftp/pub/localrepo
gpgcheck=0
enabled=1

Save and Exit.


[root@localhost repodata]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.net.in
 * extras: centos.mirror.net.in
 * updates: centos.mirror.net.in
localrepo                                             | 2.9 kB     00:00
localrepo/primary_db                                    | 3.2 MB   00:00
repo id                             repo name                          status
base/7/x86_64                       CentOS-7 - Base                    10,019
base-debuginfo/x86_64               CentOS-7 - Debuginfo                6,637
extras/7/x86_64                     CentOS-7 - Extras                     385
localrepo                           Local Repository                    4,021
updates/7/x86_64                    CentOS-7 - Updates                  1,511
repolist: 22,573



Setting up Client to get YUM repo on FTP :


[root@localhost ~]# vi /etc/yum.repos.d/localrepo.repo

[localrepo]
name=Local Repository
baseurl=ftp://192.168.189.1/pub/localrepo
gpgcheck=0
enabled=1


Save and Exit.


[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.net.in
 * extras: centos.mirror.net.in
 * updates: centos.mirror.net.in
localrepo                                             | 2.9 kB     00:00
localrepo/primary_db                                    | 3.2 MB   00:00
repo id                             repo name                          status
base/7/x86_64                       CentOS-7 - Base                    10,019
base-debuginfo/x86_64               CentOS-7 - Debuginfo                6,637
extras/7/x86_64                     CentOS-7 - Extras                     385
localrepo                           Local Repository                    4,021
updates/7/x86_64                    CentOS-7 - Updates                  1,511
repolist: 22,573


Clean the Yum cache and update the repository lists:

[root@localhost ~]# yum clean all
[root@localhost ~]# yum update

Try to install any package:

[root@localhost ~]# yum install ethtool
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package ethtool.x86_64 2:4.8-9.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================
 Package                         Arch                           Version                               Repository                         Size
==============================================================================================================================================
Installing:
 ethtool                         x86_64                         2:4.8-9.el7                           localrepo                         127 k

Transaction Summary
==============================================================================================================================================
Install  1 Package

Total download size: 127 k
Installed size: 346 k
Is this ok [y/d/N]: y
Downloading packages:
ethtool-4.8-9.el7.x86_64.rpm                                                                                           | 127 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:ethtool-4.8-9.el7.x86_64                                                                                                 1/1
  Verifying  : 2:ethtool-4.8-9.el7.x86_64                                                                                                 1/1

Installed:
  ethtool.x86_64 2:4.8-9.el7

Complete!