Accidentally turned my RHEL installation into an Oracle one. How do I change it back?
I successfully managed to install an Oracle database on my server (if such I thing should be considered a success). However, the way I did it had the unfortunate side-effect of making lsb_release think my system is Oracle Linux. I could not locate the correct prerequisites easily from the RHEL repos alone. So I added an Oracle repo as per:
https://yum.oracle.com/getting-started.html
/etc/yum.repos.d/ol7-temp.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
and installed the database software. I must have done more inadvetantly as quite some time later I realize that lsb_release now outputs:
>lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: OracleServer
Description: Oracle Linux Server release 7.9
Release: 7.9
And not as it used to.:
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: RedHatEnterpriseWorkServer
Description: Red Hat Enterprise Linux Server release 7.9 (Maipo)
Release: 7.9
Codename: Maipo
I have disabled the repo but I'm not sure how to fix my installation.
RedHat have a convert2rhel
utility but this failed as follows:
[11/11/2020 16:48:03] TASK - [Convert: Subscription Manager - Install] **************************
[11/11/2020 16:48:03] CRITICAL - The /usr/share/convert2rhel/subscription-manager directory does not exist or is empty. Using the subscription-manager is not documented yet. Please use the --disable-submgr option. Read more about the tool usage in the article https://access.redhat.com/articles/2360841.
WARNING - Abnormal exit! Performing rollback ...
Indeed subscription-manager is no longer installed and the RHEL7 servers are missing from /etc/yum.conf.d so yum install subscription-manager
doesn't get it back.
# convert2rhel --disable-submgr
[11/11/2020 17:59:28] CRITICAL - Error: --enablerepo is required if --disable-submgr is passed
No changes were made to the system.
I guess part of the solution is:
- recreate /etc/yum.conf.d/redhat.repo (which is now missing).
- reinstall subscription-manager
- reattach the subscription and see where we are with yum update etc.
Where can I get the redhat.repo file for RHEL7? This URL has the one for RHEL8 https://access.redhat.com/discussions/4547301 How can I clean up the system from there?
I want to avoid a re-install as this is an important server and with covid etc. accessing the real system with DVD is not convenient (not that is was before).
Bonus points if you can tell me what I should have done to install the Oracle database software on my system instead of whatever I actually did.
Tl;Dr;
- restore the redhat repo configuration
- yum downgrade
I got some advice from RedHat which got me half way there:
-
Download the Red Hat Enterprise Linux 7.9 Binary DVD Size 4.22GB
https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.9/x86_64/product-software
-
Create a local repository from ISO.
How to create local repository distributed through apache of Red Hat Enterprise Linux 5/6/7/8 using DVD iso for update or installation? https://access.redhat.com/solutions/7227
-
Reinstall subscription-manager packages.
yum reinstall subscription-manager
-
Register the system.
subscription-manager register subscription-manager attach --auto subscription-manager repos --enable=rhel-7-server-optional-rpms
That got me half way there. I achieved the other half as follows:
rpm -qa --queryformat "%{NAME} %{VERSION}-%{RELEASE}.%{ARCH} = %{VENDOR} \n" | grep -i oracle &> badpackages.txt
cat badpackages.txt | awk '{ print $1; }' | grep -v systemd | xargs yum downgrade -y --skip-broken
This just left systemd as Oracle's version which is protected. I downgraded this using:
cp -p /etc/yum/protected.d/systemd.conf /etc/yum/protected.d/systemd.conf.bak
rm /etc/yum/protected.d/systemd.conf
yum downgrade systemd systemd-libs systemd-sysv libgudev1
My system is now restored.
This is only half the story I had a few missteps along the way such as when I accidentally broke yum by uninstalling libnss (using a script to rpm -e --nodeps the oracle packages and then yum install them - bad idea!). This also broke scp. Fortunately it did not break wget so I could recompile from source. Ouch!
All without rebooting once.