Tag Archives: AWS

[Solved] RHEL 7.6 Use yum Error: Could not contact any CDS load balancers

Problem description

The following error was encountered when executing yum update after booting an EC2 instance from MarketPlace with RHEL 7.6’s AMI:

[ec2-user@ip-172-31-43-28 ~]$ sudo yum update
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos


Could not contact any CDS load balancers: https://rhui3.cn-northwest-1.aws.ce.redhat.com/pulp/content/.

Cause of the problem
According to the official RHEL lifecycle statement: Red Hat Enterprise Linux Life Cycle RHEL 7.6 Extended Update Support Add-on all ended on May 31, 2021, while the RedHat official website states: RHUI 3 Takes Over in AWS, Bringing New DNS Data

Since RHEL 7.6 still uses the rh-amazon-rhui-client with version 2 by default, checking the repo configuration files starting with /etc/yum.repo.d/redhat-rhui, you can see that they all start with the address: https://rhui2-cds01.REGION.aws.ce.redhat.com.

After upgrading to RHUI 3 in July 2020, the hostname and IP address were changed, which means that the original repo cannot be used anymore.

With the transition to RHUI 3, new host names and IP addresses are used. If you have firewall rules, proxy settings etc. that worked with the original RHUI 2 host names or their original IP addresses, you are likely affected, and will need to change these rules or settings to allow the new host names or IP addresses.

Solution:

      1. Start a new instance using the last major release of RHEL 7, I’m using RHEL-7.9_HVM-20211005-x86_64-0-Hourly2-GP2 – ami-0196d703168979cc6
      1. SSH to this instance, use the following command to download the latest version of the rh-amazon-rhui-client.noarch package
sudo yum install --downloadonly --downloaddir=/home/ec2-user/ rh-amazon-rhui-client.noarch

Disconnect the SSH connection, use the SCP command on the local computer to download the installation package locally, and then transfer it to the problematic 7.6 instance


scp -i .\xxx.pem ec2-user@[RHEL 7.9的IP]:/home/ec2-user/rh-amazon-rhui-client-3.0.45-1.el7.noarch.rpm ./Desktop/

scp -i .\xxx.pem .\Desktop\rh-amazon-rhui-client-3.0.45-1.el7.noarch.rpm ec2-user@[RHEL 7.6的IP]:/home/ec2-user/

Connect SSH to the 7.6 instance and execute the following command to update RH Amazon rhui client

# Uninstall the old client and beta versions that came with 7.6
sudo yum remove -y rh-amazon-rhui-client rh-amazon-rhui-client-beta
# Manually install the downloaded new version of the rpm package
sudo rpm -ivh --nodeps ~/rh-amazon-rhui-client-3.0.45-1.el7.noarch.rpm
# Resolve the package dependencies by reinstalling them again via yum
sudo yum reinstall -y rh-amazon-rhui-client
# Refresh the cache and repo information
sudo yum clean all
sudo yum repolist
sudo yum list

fatal error: Python.h: No such file or directory

fatal error: Python.h: No such file or directory

Process: through PIP install a library, an error occurred and the python. H header file could not be found

Solution

Search stackoverflow. My environment is CentOS, so execute sudo Yum install python3 devel and then go to the PIP install library. It’s all OK

For apt (Ubuntu, Debian…):

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

For yum (CentOS, RHEL…):

sudo yum install python-devel    # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

For dnf (Fedora…):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

For zippers (openSUSE):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

For apk (Alpine…):
This is a departure from the normal Alpine naming
scheme, which uses py2- and py3- prefixes

sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

For apt-cyg (Cygwin…):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

Solution to the exception of PEM file logging in EC2

Logging in to EC2 will use

ssh -i <pem flie> ec2-user@<EC2 Public DNS>

To log in. Here are two possible problems and solutions

PEM file permission problem. After typing the SSH command, the following error will be displayed

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'us.pem' are too open.

This can be solved by modifying the PEM file permissions.

chmod 600 us.pem

Request passphrase

After typing the SSH command, the system prompts as follows

Enter passphrase for key '/root/us.pem':

And no matter what text you enter, repeat the above prompt.

It was used in windows

Sublime text after opening the PEM file, copy the content to VI of Linux to generate the PEM file.

After that, we use Notepad of windows to open the PEM file, and then copy it to VI of Linux.