I ran into the same error message when attempting to create an Amazon Linux 2 instance using the AWS CDK. The CDK currently defaults to Amazon Linux instead of Amazon Linux 2. When you accidentally use an Amazon Linux AMI from 2018, surprise surprise, all sorts of facilities are not available. I posted an easy way to check your version in another answer.
In CDK (and Cloud Formation) make sure to declare your intended generation in your AmazonLinuxImage properties
generation: AmazonLinuxGeneration.AMAZON_LINUX_2
Answer from Derek Bennett on serverfault.comUnable to upgrade Amazon Linux 2 Kernel to 5.15 with amazon-linux-extras
node.js - sudo: amazon-linux-extras: command not found - Stack Overflow
ansible - amazon-linux-extras enable vs install - Stack Overflow
amazon-linux-extras specific version - Stack Overflow
I ran into the same error message when attempting to create an Amazon Linux 2 instance using the AWS CDK. The CDK currently defaults to Amazon Linux instead of Amazon Linux 2. When you accidentally use an Amazon Linux AMI from 2018, surprise surprise, all sorts of facilities are not available. I posted an easy way to check your version in another answer.
In CDK (and Cloud Formation) make sure to declare your intended generation in your AmazonLinuxImage properties
generation: AmazonLinuxGeneration.AMAZON_LINUX_2
It looks like this issue is potentially being caused by YUM priorities. You could try disabling priorities to see if that is the issue. The config file used to disable yum priorities can be found here.
/etc/yum/pluginconf.d/priorities.conf
Change the config to be "enabled = 0" and try again.
You can use the amazon-linux-extras repository to upgrade the kernel
First, run this command to get all available kernel versions
sudo amazon-linux-extras |grep kernel
you will see a response similar to this
_ kernel-5.4 available [ =stable ]
55 kernel-5.10=latest enabled [ =stable ]
62 kernel-5.15 available [ =stable ]
the kernel version marked as enabled is the one installed on your machine
to upgrade to the newer version (for example kernel-5.15), just run this command sudo amazon-linux-extras install kernel-5.15 -y
Now, you need to reboot the server with sudo reboot
After rebooting, run the command uname -r to make sure that the newer version is successfully installed
for more information, please refer to this link
Kernel live patches are available for Amazon Linux 2 with kernel version 4.14.165-131.185 or later. To check your kernel version, run the following command.
[root@actsupport ~]# yum list kernel
If you already have a supported kernel version, skip this step. If you do not have a supported kernel version, run the following commands to update the kernel to the latest version and to reboot the instance.
[root@actsupport ~]# sudo yum install -y kernel
[root@actsupport ~]# reboot
Install the yum plugin for Kernel Live Patching.
[root@actsupport ~]# yum install -y yum-plugin-kernel-livepatch
Enable the yum plugin for Kernel Live Patching.
[root@actsupport ~]# yum kernel-livepatch enable -y
This command also installs the latest version of the kernel live patch RPM from the configured repositories.
To confirm that the yum plugin for kernel live patching has installed successfully, run the following command.
[root@actsupport ~]# rpm -qa | grep kernel-livepatch
When you enable Kernel Live Patching, an empty kernel live patch RPM is automatically applied. If Kernel Live Patching was successfully enabled, this command returns a list that includes the initial empty kernel live patch RPM.
Update and start the kpatch service. This service loads all of the kernel live patches upon initialization or at boot.
[root@actsupport ~]# yum update kpatch-runtime
[root@actsupport ~]# systemctl enable kpatch.service
Configure the Amazon Linux 2 Kernel Live Patching repository, which contains the kernel live patches.
[root@actsupport ~]# amazon-linux-extras enable livepatch
Check the Amazon image version of your EC2 instance.
Command: cat /etc/image-id
If it is Amazon Linux 2023, it does not have extras.
However, most of the packages are already included in the distro.
You can run sudo yum install nginx which will install version 1.22
For Amazon Linux 2023 VM, follow the below steps
sudo yum update
sudo yum install stress
Generate CPU stress: stress --cpu <number-of-threads>
Generate memory stress: stress --vm <number-of-threads> --vm-bytes <memory-size>
Generate I/O stress: stress --io <number-of-threads>
Generate disk stress: stress --hdd <number-of-threads>