How to Register a Virtual Machine to RedHat Subscription Management

By:   |   Updated: 2021-10-14   |   Comments   |   Related: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | > Virtualization


Problem

Red Hat Subscription Management (RHSM) is a customer-driven, end-to-end solution that provides tools for subscription status and management and integrates with Red Hat's system management tools. Registering a VM to RHSM is mandatory to install python2 on a RHEL machine which is also a basic prerequisite for SQL Server 2019 installation. Read this tutorial to learn how to register your virtual machine on which you have already installed Red Hat Enterprise Linux, but not yet registered to Red Hat subscription management.

Solution

As per the Red Hat official website, RHSM provides status, inventory, organization, and reporting on Red Hat subscriptions Using Subscription Manager from a Red Hat Enterprise Linux system. RHSM (Red Hat Subscription Management) uses secure certificates to improve a customers ability to know what subscriptions they purchased, where and how those subscriptions are being used, refine how software is consumed, and improved portability of the subscription across deployments which are physical, virtual, and cloud-based. During the installation of a Red Hat product, a product certificate is installed on the system. When that system registers to Red Hat Subscription Management, a system certificate is placed on the system, which enables you to:

  • Add product(s) to your system.
  • Attach subscription(s) to a system.
  • Receive updates

Note: If you don’t know how to create additional virtual machine to install RHEL 8.1 then I would recommend you read below articles in sequence.

  1. Install VMware Workstation Pro for SQL Server
  2. Build Virtual Machine using VMware Workstation Pro
  3. Create VMware Virtual Machine for Red Hat Enterprise Linux

Step by Step Process to Register a VM to Red Hat Subscription Management (RHSM)

Before going ahead, let me explain the complete setup I have. I created a VM using VMware Workstation PRO 15.5 and then installed RHEL 8.1 on that VM in order to configure Linux for SQL Server 2019. I was installing SQL Server 2019 on this server and Microsoft suggested to install python2 as part of prerequisite before installing SQL Server 2019. When I tried installing python2 on this RHEL 8 machine, I got the below error:

Updating Subscription Management repositories.
Unable to read consumer identity 
This system is not registered to Red Hat Subscription Management.
Error: There are no enabled repositories in ".etc/yum.repos.d", ".etc/yum/repos.d", "/etc/distro.repos.d".
linux command line

Check Subscription Management Status

Next, I checked the status of Subscription Management by running the below command.

--Check subscription Management Status
#subscription-manager status

The output shows "Unknown", which means this machine is not registered with Red Hat Subscription Management. The value for overall status in below image must be "Current" if this machine is registered. Now I will show the steps to register your VM to Red Hat Subscription Management.

linux command line

Let’s try attaching the installed RHEL 8.1 to Red Hat Subscription Management by running the below command. Remember this is only possible if your system is registered, if you have not registered your system to Red Hat Subscription Management this command will not do anything.

--Try attaching installed RHEL to Red Hat Subscription Manager
#subscription-manager attach --auto

As we have not registered it yet, we get the below output.

linux command line

Cleanup Machine Before Registering with Subscription Management

First, let’s cleanup the machine in case someone has already tried registering this virtual machine. Run the below command to remove subscriptions from this system. I used the –all option because this machine was newly built. Ensure to do testing before using this option on other lower life cycle systems.

--Remove or clean any existing subscriptions
#subscription-manager remove --all

As this is a new machine and there is no subscriptions present, the output shows zero subscriptions were removed from this system. Now we know the system is cleaned.

linux command line

You can also run the below command to unregister from Red Hat Subscription Management.

--Unregister red hat subscriptions
#subscription-manager unregister

The output of the above command is below and shows this system is currently not registered.

linux command line

Now we will run the below command to clean all local data present for subscription management.

--Clean local data for red hat subscriptions
#subscription-manager clean

You can see the output shows "All local data removed" in below image.

linux command line

Run the below yum command to clean the cache.

--Clean yum cache directory
#yum clean all

Again, the output is the same as this system is not registered yet.

linux command line

Remove yum cache directories by running below command.

--remove files from /var/cache/yum
#rm -rf /var/cache/yum/*
linux command line

We are performing various cleaning steps just to ensure our registration process will not fail because of some existing legacy data. If your system is old and you are getting issues during installation or not able to register the subscription, then the recommendation is to clean all possible data before running the register process again.

Register Machine with Red Hat Subscription Management

If your virtual machine is a new system and you have newly configured it with RHEL, then you can ignore all the removal and cleaning steps above and directly jump to the below step to register your virtual machine to Red Hat Subscription Management.  As we have cleaned our system from all aspects, now go ahead and run below command to register your virtual machine to Red Hat Subscription Management.

--Register this VM to red hat subscription manager
#subscription-manager register

You will get a prompt mentioning registering to suscriptions.rhsm.redhat.com website. After this line, you will be prompted to enter username and password as per below screen. I have entered the username and password I had created when I subscribed on the Red Hat website during the setup download. You can also enter your credentials to proceed.

linux command line

Once you entered the username and password press enter to register this system. You will get the below screen after some processing. I have masked the ID with XXX.

The system has been registered with ID: d3XXXX0-495c-4XXX-92d4-bXXXXXXXXX1

The registered system name is: SQLServer-RHEL8

linux command line

Now, our newly created VM has been registered with Red Hat Subscription Management. Next, we will attach the installed RHEL version with the subscription management by running the below command.

--Attach installed RHEL to red hat subscription management
#subscription-manager attach --auto

You can see the output shows that it is now "Subscribed".

linux command line

You can also check and validate this by running below the command.

--Check status for red hat subscription management
#subscription-manager status

You can see the status shows "Current".

linux command line

Now run the below command to see all configured repositories under YUM. This is not a mandatory step although you can run it to check yum configured repositories.

--Check configured repositories under YUM
#yum repolist

You can see all repositories in the output of this command in below screenshot.

linux command line

Now, we can go ahead and install python2 as a prerequisite for SQL Server 2019. Go ahead and run the below command to install it.

---Install python2
#sudo yum install python2

You can see the installation has begun in the image below.

linux command line
Next Steps
  • Now that we have installed a prerequisite for Linux based SQL Server 2019, the next article will cover installing SQL Server 2019 on this machine.


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Manvendra Singh Manvendra Singh has over 5 years of experience with SQL Server and has focused on Database Mirroring, Replication, Log Shipping, etc.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2021-10-14

Comments For This Article

















get free sql tips
agree to terms