Forum Stats

  • 3,734,326 Users
  • 2,246,948 Discussions
  • 7,857,226 Comments

Discussions

Configuring Yum to Support RHEL and CentOS Instances in Oracle Cloud Infrastructure

Introduction

The Oracle Linux Yum Server Getting Started guide provides the instructions on how to connect to the Oracle Linux yum server and obtain software updates via yum for Oracle Linux and compatible Linux distributions such as Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux.

This article shows an example of connecting to the Oracle Linux yum server from a CentOS 7 instance in Oracle Cloud Infrastructure (OCI).

Task Flow

Follow these few simple steps to change from CentOS 7 to Oracle Linux:

  1. Get the RPM-GPG-KEY
  2. Connect to regional yum mirror
  3. Install proper Oracle Linux yum repository
  4. Prepare distro-sync
  5. Configure grub.cfg

centos-to-ol-flowpng

Steps

1.  Get the RPM-GPG-KEY

In order to be able to use the signed Oracle Linux repositories, first we need to import the RPM-GPG-KEY.

$ sudo curl https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -o
/etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

2.  Regional Yum Mirrors in OCI

OCI provides regional yum mirrors. We need to find out which region we are in and save it in a yum variable at /etc/yum/variables/ociregion.

Set the ociregion variable and create temporary Oracle Linux repo. We use the internal meta-data API to find out about the OCI region and then add the region specific Oracle Linux repository from which to install our oraclelinux-release-el7 rpm.

$ ociregion="-$(curl --noproxy --connect-timeout 5 -sL http://169.254.169.254/opc/v1/instance/region)"

$ sudo yum-config-manager --add-repo http://yum${ociregion}.oracle.com/yum${ociregion}-ol7.repo

If you are not in Oracle Cloud Infrastructure you can simply get the public-yum-ol7.repo as follows:


$ sudo yum-config-manager --add-repo http://yum.oracle.com/public-yum-ol7.repo

3.  Install the Modularized Oracle Linux 7 Release Repository

Now we will save the contents of our ociregion variable in /etc/yum/vars/ociregion and install oraclelinux-release-el7

$ sudo sh -c "echo $ociregion>/etc/yum/vars/ociregion"
$ sudo yum install -y oraclelinux-release-el7

Remove the Temporary Repository

Since we now have the proper region specific, modularized Oracle Linux repositories installed, we can remove our initial temporary repository.

$ sudo mv /etc/yum.repos.d/yum-phx-ol7.repo /etc/yum.repos.d/yum-phx-ol7.repo.disabled

4.  Prepare distro-sync

The following steps allow us to synchronize our instance to the Oracle Linux 7 distribution:

$ sudo rpm -e --nodeps centos-release
$ sudo rm -f /etc/yum/protected.d/systemd.conf
$ sudo yum remove -y centos-logos epel-release
$ sudo yum install -y oracle-epel-release-el7 oracle-logos grubby deltarpm

Now we re-install grub2 from the Oracle Linux repository.

$ sudo yum --enablerepo=ol7_latest install -y grub2

Finally, run distro-sync. This generates a lot of output and runs for quite a while.

$ sudo yum --skip-broken distro-sync -y

Update installed packages from the Oracle Linux repository. Packages not updated are taken care of in the last optional step Reinstall Packages from OCI Yum Repositories.

5.  Configure grub Boot

The last step before we reboot, we need to re-build the grub.cfg file. Make sure the files point to the correct location and run grub2-mkconfig.

$ sudo ls -ld /etc/grub2*
$ [ -d /sys/firmware/efi ] && sudo grub2-mkconfig -o /etc/grub2-efi.cfg || sudo grub2-mkconfig -o /etc/grub2.cfg
$ sudo reboot

Optional Steps

Reinstall Packages from OCI Yum Repositories

Some of the installed packages are still pointing to now disabled CentOS repositories. Optionally, we can reinstall those packages from the OL repositories. Some of those packages can not be reinstalled because they are in multiple repositories. We can remove the packages in question, which will remove several dependencies, and then simply add those packages and dependencies back.

$ sudo yum reinstall $(yum list installed | egrep '@(epel|anaconda|updates)' | awk '{print $1}')
$ sudo yum remove libreport centos-indexhtml
$ sudo yum install libreport abrt anaconda firefox
</code>

Change to 'opc' User

The default user for CentOS is 'centos', so login with ssh -i privkey [email protected] The package cloud-init is installed by default from centos. To change to the opc user, edit /etc/cloud/cloud.cfg and change system_info:default_user:name and set it to 'opc'.

$ sudo sed -i.bak 's/name: (centos|cloud-user)/name: opc/g' /etc/cloud/cloud.cfg
$ sudo cloud-init clean && sudo cloud-init init

Learn More about Oracle Linux and Oracle Cloud Infrastructure

Oracle is the only cloud service provider that offers a complete Linux-optimized services stack from a single vendor - applications, middleware, database, management tools, and infrastructure.  The Oracle Linux operating system powers Oracle Cloud, and it is used extensively by thousands of Oracle Cloud customers worldwide.  As a result, you can be assured that when you run Oracle Linux in the Oracle Cloud, you are running on a well-tested and proven secure and reliable foundation.

Oracle Cloud Infrastructure offers high-performance compute capabilities (as physical hardware instances) and storage capacity in a flexible overlay virtual network that is securely accessible from your on-premises network. Oracle provides free trial subscriptions so you can try out and evaluate Oracle Cloud services. Oracle Cloud services are available at several pricing and service levels. Both trial and paid subscriptions are available through https://cloud.oracle.com/.

Oracle Linux is the most cost-effective and integrated operating system for Oracle Cloud Infrastructure, with the best platform experience for Oracle and non-Oracle applications alike. With Oracle Cloud Infrastructure subscriptions, Oracle Linux Premier Support is included at no additional cost. In addition, you now have a single point of contact for cloud infrastructure, operating system, and Oracle software support.

For additional information about Oracle Linux and Oracle Cloud Infrastructure, visit:

Comments

Sign In or Register to comment.