3.3. Uploading a RHEL image to AWS by using the command line
To run a RHEL instance on Amazon Web Services (AWS), you must first upload a RHEL image to AWS. To configure and manage a RHEL EC2 instance on AWS, use the awscli2 utility.
3.3.1. Installing AWSCLI2 复制链接链接已复制到粘贴板!
You can use the AWS command line interface awscli2 utility to configure and manage RHEL images and Red Hat high availability (HA) cluster on AWS.
Prerequisites
- You have access to an AWS Access Key ID and an AWS Secret Access Key. For details, see manage access keys.
Procedure
Install
awscli2:# dnf install awscli2
Verification
Verify the installation:
$ aws --version aws-cli/1.19.77 Python/3.6.15 Linux/5.14.16-201.fc34.x86_64 botocore/1.20.77Configure
awscli2for AWS credentials and settings:$ aws configure AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: Default output format [None]:
3.3.2. Converting and pushing an image to Amazon S3 复制链接链接已复制到粘贴板!
You can convert a RHEL image in the qcow2 image format to OVA, VHD, VHDX, VMDK, and raw by using the qemu-img utility, and then upload to the Amazon S3 storage. For details, see supported image formats by AWS.
Prerequisites
- You have created an Amazon S3 bucket by using awscli2 to upload the RHEL image.
Procedure
Run
qemu-imgto convert.qcow2image to.rawimage format:# qemu-img convert -f qcow2 -O raw rhel-10.0-sample.qcow2 rhel-10.0-sample.rawUpload the image to the Amazon S3 bucket:
$ aws s3 cp rhel-10.0-sample.raw s3://<example-s3-bucket-name>
Verification
- Check the AWS S3 Console to confirm successful upload.
By using the awscli2 utility, you can manage a RHEL EC2 VM on AWS through command line. In this case, you can use the vmimport role for managing RHEL EC2 image snapshot. With awscli2, you can also import a RHEL EC2 image snapshot, create an AMI, launch, and connect to a RHEL EC2 instance.
-
Use the
vmimportrole: An alternate to import the RHEL image to the Amazon S3 bucket is by using thevimportrole. See Required permissions for VM Import/Export. - Import RHEL image as a snapshot: You can import RHEL VM image from Amazon S3 as a snapshot to Amazon EC2. For details, see Start an import snapshot task and Monitor an import snapshot task.
- Create and launch a RHEL EC2 instance: You can create a RHEL Amazon Machine Image (AMI) from existing snapshot and launch a RHEL EC2 instance. For details, see create an AMI from snapshot by using awscli2 and launching, listing, and deleting RHEL instance by using awscli2.
-
Configure the private key and connect to the RHEL EC2 instance: You can configure your
<example_key>.pemfile and connect to an RHEL EC2 instance. For details, see Create a key pair using Amazon EC2 and Connect using the AWS CLI.
3.3.4. Attaching Red Hat subscriptions 复制链接链接已复制到粘贴板!
Using the subscription-manager command, you can register and attach your Red Hat subscription to a RHEL instance.
Prerequisites
- You have an active Red Hat account.
Procedure
Register your system:
# subscription-manager registerAttach your subscriptions:
- You can use an activation key to attach subscriptions. See Creating Red Hat Customer Portal Activation Keys for more information.
- Otherwise, you can manually attach a subscription by using the ID of the subscription pool (Pool ID). See Attaching a host-based subscription to hypervisors.
Optional: To collect various system metrics about the instance in the Red Hat Hybrid Cloud Console, you can register the instance with Red Hat Lightspeed.
# insights-client register --display-name <display_name_value>For information about further configuration of Red Hat Lightspeed, see Client Configuration Guide for Red Hat Lightspeed.
You can deploy Red Hat Enterprise Linux (RHEL) virtual machines faster and more effortlessly on Amazon Web Services (AWS). For that, you must set up gold images of RHEL to be automatically registered to the Red Hat Subscription Manager (RHSM).
Prerequisites
You have downloaded the latest RHEL gold image for AWS. For instructions, see Using gold images on AWS.
注意You can only attach an AWS account to a single Red Hat account at a time. Therefore, ensure no other users require access to the AWS account before attaching it to your Red Hat one.
Procedure
Upload the gold image to AWS. For instructions, see one of the following:
- Create VMs by using the uploaded image. If your RHSM settings are correct, they will be automatically subscribed to RHSM.
Verification
In a RHEL VM created using the above instructions, verify the system is registered to RHSM by executing the
subscription-manager identitycommand. On a successfully registered system, this displays the UUID of the system. For example:# subscription-manager identity system identity: fdc46662-c536-43fb-a18a-bbcb283102b7 name: 192.168.122.222 org name: 6340056 org ID: 6340056