Beruflich Dokumente
Kultur Dokumente
on Microsoft Azure
Running Red Hat on Microsoft Azure
Hybrid cloud technologies can help you achieve greater business agility, efficiency, and competitive
advantage by unifying heterogeneous IT environments. As a result, 71% of cloud adopters use hybrid
cloud technologies to move their business forward1. Interoperability and portability across environ-
ments are key to successful hybrid cloud implementations. Workloads must be able to run on multiple
platforms and be moved as needs change. Management should be simple and unified. Application
development needs to span physical, virtual, and private and public cloud infrastructures.
Together, industry leaders Red Hat and Microsoft give you more choice and flexibility for hybrid cloud
deployments. The companies are committed to delivering enterprise-class operating systems, rigorous
security standards, and an integrated support experience. Through their partnership, Red Hat and
Microsoft:
Deliver and support Red Hat technologies on Microsoft Azure, making Red Hat Enterprise Linux
the preferred choice for production-grade Linux on Azure.
Merge the Microsoft .NET and Linux development and application environments.
Deploy applications, workloads, and containers based on Red Hat Enterprise Linux in a Microsoft
Azure cloud environment.
Simply manage your entire hybrid environment and application and container portability from a
single interface.
Easily develop applications that run in both Windows and Linux environments.
The Red Hat and Microsoft partnership offers many customer benefits for both end-users and inde-
pendent software vendors (ISVs).
ENTERPRISE-GRADE SUPPORT
32% of cloud adopters cite a lack of resources and experience to be a challenge in cloud deployment2.
Red Hat and Microsoft deliver comprehensive, integrated, global support across hybrid environments.
Take advantage of a consistent support experience, regardless of whether you run Red Hat products
on premise or in a Microsoft Azure cloud environment. Contact either company for support Red
Hat and Microsoft work together to determine where the issue resides and resolve the problem quick-
ly and efficiently.
Lets have a look now, how to deploy and manage Red Hat-based virtual machines on Azure.
1. Go to Azure Marketplace and deploy validated Red Hat images in several clicks. The process is
very simple, everything is self-explanatory in the Marketplace environment and therefore, we will
not cover these details in this technical guide. This option may be good for you in case you want
to run new VMs on Azure that are not covered by your existing licensing agreement with the Red
Hat. Please note, that in this scenario, in addition to the cost of running Linux-type virtual machine
Azure (called Azure infrastructure costs), you will be charged an extra Red Hat licensing fee.
1. You may bring to Azure your own VMs, that are already licensed directly from Red Hat (as per
Red Hat Cloud Access program). For this you will need to do certain actions to prepare your
VM images to be deployed, managed and updated in Azure environment. This eBook will guide
you through step by step, with a lot of technical details and will provide you with examples of
commands. So, lets get started!
The newer VHDX format is not supported in Azure. You can convert the disk to VHD format by
using Hyper-V Manager or the convert-vhd PowerShell cmdlet.
When youre installing the Linux system, we recommend that you use standard partitions rather
than LVM (often the default for many installations). This will avoid LVM name conflicts with cloned
VMs, particularly if an OS disk ever needs to be attached to another VM for troubleshooting. LVM
or RAID may be used on data disks if preferred.
All of the VHDs must have sizes that are multiples of 1 MB.
When you use qemu-img to convert disk images to VHD format, note that there is a known bug
in qemu-img versions 2.2.1 or later. This bug results in an improperly formatted VHD. The issue is
intended to be fixed in an upcoming release of qemu-img. For now, we recommend that you use
qemu-img version 2.2.0 or earlier.
Note that if the package is not already installed, this command will fail with an error message. This
is expected.
4. Create a file named network in the /etc/sysconfig/ directory that contains the following text:
NETWORKING=yes HOSTNAME=localhost.localdomain
5. Create a file named ifcfg-eth0 in the /etc/sysconfig/network-scripts/ directory that contains the
following text:
6. Move (or remove) udev rules to avoid generating static rules for the Ethernet interface. These rules
cause problems when you clone a virtual machine in Microsoft Azure or Hyper-V:
7. Ensure that the network service will start at boot time by running the following command:
8. Register your Red Hat subscription to enable the installation of packages from the RHEL repository
by running the following command:
9. The WALinuxAgent package WALinuxAgent-<version> has been pushed to the Red Hat extras
repository. Enable the extras repository by running the following command:
10. Modify the kernel boot line in your grub configuration to include additional kernel parameters
for Azure. To do this, open /boot/grub/menu.lst in a text editor and ensure that the default kernel
includes the following parameters:
In addition to the above action, we recommend that you remove the following parameters:
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be
sent to the serial port.
The crashkernel option can be left configured if desired, but note that this parameter will reduce
the amount of available memory in the VM by 128 MB or more. This might be problematic on
smaller VM sizes.
11. Ensure that the SSH server is installed and configured to start at boot time. This is usually the de-
fault. Modify /etc/ssh/sshd_config to include the following line:
ClientAliveInterval 180
12. Install the Azure Linux Agent by running the following command:
Note that installing the WALinuxAgent package will remove the NetworkManager and Network-
Manager-gnome packages if they were not already removed as described in step 2.
13. Do not create swap space on the OS disk. The Azure Linux Agent can automatically configure swap
space by using the local resource disk that is attached to the VM after the VM is provisioned on
Azure. Note that the local resource disk is a temporary disk, and might be emptied when the VM is
deprovisioned. After you install the Azure Linux Agent (see the previous step), modify the follow-
ing parameters in /etc/waagent.conf appropriately:
14. Unregister the subscription (if necessary) by running the following command:
15. Run the following commands to deprovision the virtual machine and prepare it for provisioning on
Azure:
export HISTSIZE=0
logout
16. Click Action > Shut Down in Hyper-V Manager. Your Linux VHD is now ready to be uploaded to
Azure.
NETWORKING=yes HOSTNAME=localhost.localdomain
4. Create a file named ifcfg-eth0 in the /etc/sysconfig/network-scripts/ directory that contains the
following text:
5. Ensure that the network service will start at boot time by running the following command:
6. Register your Red Hat subscription to enable the installation of packages from the RHEL repository
by running the following command:
7. Modify the kernel boot line in your grub configuration to include additional kernel parameters for
Azure. To do this, open /etc/default/grub in a text editor and edit the GRUB_CMDLINE_LINUX
parameter. For example:
This will also ensure that all console messages are sent to the first serial port, which can assist
Azure support with debugging issues. In addition to the above action, we recommend that you
remove the following parameters:
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be
sent to the serial port. The crashkernel option can be left configured if desired, but note that this
parameter will reduce the amount of available memory in the VM by 128 MB or more. This might
be problematic on smaller VM sizes.
8. After you are done editing /etc/default/grub, run the following command to rebuild the grub con-
figuration:
9. Ensure that the SSH server is installed and configured to start at boot time. This is usually the de-
fault. Modify /etc/ssh/sshd_config to include the following line:
ClientAliveInterval 180
10. The WALinuxAgent package WALinuxAgent-<version> has been pushed to the Red Hat extras
repository. Enable the extras repository by running the following command:
11. Install the Azure Linux Agent by running the following command:
13. If you want to unregister the subscription, run the following command:
14. Run the following commands to deprovision the virtual machine and prepare it for provisioning on
Azure:
export HISTSIZE=0
logout
15. Click Action > Shut Down in Hyper-V Manager. Your Linux VHD is now ready to be uploaded to
Azure.
guestfish --rw -a
Change the second field of the root user from !! to the encrypted password.
3. Create a virtual machine in KVM from the qcow2 image, set the disk type to qcow2, and set the
virtual network interface device model to virtio. Then start the virtual machine and sign in as root.
4. Create a file named network in the /etc/sysconfig/ directory that contains the following text:
NETWORKING=yes HOSTNAME=localhost.localdomain
5. Create a file named ifcfg-eth0 in the /etc/sysconfig/network-scripts/ directory that contains the
following text:
mv /lib/udev/rules.d/75-persistent-net-generator.rules /var/lib/waagent/
mv /etc/udev/rules.d/70-persistent-net.rules /var/lib/waagent/
7. Ensure that the network service will start at boot time by running the following command:
chkconfig network on
8. Register your Red Hat subscription to enable the installation of packages from the RHEL repository
by running the following command:
9. Modify the kernel boot line in your grub configuration to include additional kernel parameters
for Azure. To do this, open /boot/grub/menu.lst in a text editor and ensure that the default kernel
includes the following parameters:
This will also ensure that all console messages are sent to the first serial port, which can assist
Azure support with debugging issues. This will disable NUMA due to a bug in the kernel version
that is used by RHEL 6.
In addition to the above action, we recommend that you remove the following parameters:
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be
sent to the serial port. The crashkernel option may be left configured if desired, but note that this
parameter will reduce the amount of available memory in the VM by 128 MB or more. This might
be problematic on smaller VM sizes.
Rebuild initramfs:
# dracut f -v
12. Ensure that the SSH server is installed and configured to start at boot time:
chkconfig sshd on
Restart sshd:
14. Install the Azure Linux Agent by running the following command:
chkconfig waagent on
15. The Azure Linux Agent can automatically configure swap space by using the local resource disk
that is attached to the VM after the VM is provisioned on Azure. Note that the local resource disk
is a temporary disk, and might be emptied when the VM is deprovisioned. After you install the
Azure Linux Agent (see the previous step), modify the following parameters in /etc/waagent.conf
appropriately:
16. Unregister the subscription (if necessary) by running the following command:
subscription-manager unregister
17. Run the following commands to deprovision the virtual machine and prepare it for provisioning on
Azure:
export HISTSIZE=0
logout
18. Shut down the VM in KVM.
19. Convert the qcow2 image to VHD format. First convert the image to raw format:
Make sure that the size of the raw image is aligned with 1 MB. Otherwise, round up the size to
align with 1 MB:
MB=$((1024*1024))
rounded_size=$((($size/$MB + 1)*$MB))
guestfish --rw -a
Change the second field of root user from !! to the encrypted password.
3. Create a virtual machine in KVM from the qcow2 image, set the disk type to qcow2, and set the
virtual network interface device model to virtio. Then start the virtual machine and sign in as root.
4. Create a file named network in the /etc/sysconfig/ directory that contains the following text:
NETWORKING=yes HOSTNAME=localhost.localdomain
5. Create a file named ifcfg-eth0 in the /etc/sysconfig/network-scripts/ directory that contains the
following text:
6. Ensure that the network service will start at boot time by running the following command:
chkconfig network on
7. Register your Red Hat subscription to enable installation of packages from the RHEL repository by
running the following command:
8. Modify the kernel boot line in your grub configuration to include additional kernel parameters for
Azure. To do this, open /etc/default/grub in a text editor and edit the GRUB_CMDLINE_LINUX
parameter. For example:
This will also ensure that all console messages are sent to the first serial port, which can assist
Azure support with debugging issues. In addition to the above action, we recommend that you
remove the following parameters:
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be
sent to the serial port. The crashkernel option can be left configured if desired, but note that this
parameter will reduce the amount of available memory in the VM by 128 MB or more. This might
be problematic on smaller VM sizes.
grub2-mkconfig -o /boot/grub2/grub.cfg
Rebuild initramfs:
dracut f -v
12. Ensure that the SSH server is installed and configured to start at boot time:
Restart sshd:
13. The WALinuxAgent package WALinuxAgent-<version> has been pushed to the Red Hat extras
repository. Enable the extras repository by running the following command:
14. Install the Azure Linux Agent by running the following command:
15. Do not create swap space on the OS disk. The Azure Linux Agent can automatically configure swap
space by using the local resource disk that is attached to the VM after the VM is provisioned on
Azure. Note that the local resource disk is a temporary disk, and might be emptied when the VM is
deprovisioned. After you install the Azure Linux Agent (see the previous step), modify the follow-
ing parameters in /etc/waagent.conf appropriately:
16. Unregister the subscription (if necessary) by running the following command:
subscription-manager unregister
export HISTSIZE=0
logout
18. Shut down the virtual machine in KVM.
Make sure that the size of the raw image is aligned with 1 MB. Otherwise, round up the size to
align with 1 MB:
MB=$((1024*1024))
rounded_size=$((($size/$MB + 1)*$MB))
When you install the Linux operating system, we recommend that you use standard partitions
rather than LVM (often the default for many installations). This will avoid LVM name conflicts with
cloned VMs, particularly if an OS disk ever needs to be attached to another VM for troubleshoot-
ing. LVM or RAID can be used on data disks if preferred.
Do not configure a swap partition on the OS disk. You can configure the Linux agent to create a
swap file on the temporary resource disk. You can find more information about this in the steps
below.
When you create the virtual hard disk, select Store virtual disk as a single file.
Note that if the package is not already installed, this command will fail with an error message. This
is expected.
2. Create a file named network in the /etc/sysconfig/ directory that contains the following text:
NETWORKING=yes HOSTNAME=localhost.localdomain
3. Create a file named ifcfg-eth0 in the /etc/sysconfig/network-scripts/ directory that contains the
following text:
4. Move (or remove) the udev rules to avoid generating static rules for the Ethernet interface. These
rules cause problems when you clone a virtual machine in Microsoft Azure or Hyper-V:
5. Ensure that the network service will start at boot time by running the following command:
6. Register your Red Hat subscription to enable the installation of packages from the RHEL repository
by running the following command:
7. The WALinuxAgent package WALinuxAgent-<version> has been pushed to the Red Hat extras
repository. Enable the extras repository by running the following command:
8. Modify the kernel boot line in your grub configuration to include additional kernel parameters for
Azure. To do this, open /boot/grub/menu.lst in a text editor and ensure that the default kernel
includes the following parameters:
This will also ensure that all console messages are sent to the first serial port, which can assist
Azure support with debugging issues. This will disable NUMA due to a bug in the kernel version
that is used by RHEL 6. In addition to the above action, we recommend that you remove the fol-
lowing parameters:
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be
sent to the serial port. The crashkernel option can be left configured if desired, but note that this
parameter will reduce the amount of available memory in the VM by 128 MB or more. This might
be problematic on smaller VM sizes.
Rebuild initramfs:
# dracut f -v
10. Ensure that the SSH server is installed and configured to start at boot time. This is usually the de-
fault. Modify /etc/ssh/sshd_config to include the following line:
ClientAliveInterval 180
11. Install the Azure Linux Agent by running the following command:
The Azure Linux Agent can automatically configure swap space by using the local resource disk
that is attached to the VM after the VM is provisioned on Azure. Note that the local resource disk
is a temporary disk, and might be emptied when the VM is deprovisioned. After you install the
Azure Linux Agent (see the previous step), modify the following parameters in /etc/waagent.conf
appropriately:
13. Unregister the subscription (if necessary) by running the following command:
14. Run the following commands to deprovision the virtual machine and prepare it for provisioning on
Azure:
export HISTSIZE=0
logout
Make sure that the size of the raw image is aligned with 1 MB. Otherwise, round up the size to
align with 1 MB:
MB=$((1024*1024))
rounded_size=$((($size/$MB + 1)*$MB))
1. Create a file named network in the /etc/sysconfig/ directory that contains the following text:
NETWORKING=yes HOSTNAME=localhost.localdomain
2. Create a file named ifcfg-eth0 in the /etc/sysconfig/network-scripts/ directory that contains the
following text:
3. Ensure that the network service will start at boot time by running the following command:
4. Register your Red Hat subscription to enable the installation of packages from the RHEL repository
by running the following command:
5. Modify the kernel boot line in your grub configuration to include additional kernel parameters for
Azure. To do this, open /etc/default/grub in a text editor and edit the GRUB_CMDLINE_LINUX
parameter. For example:
This will also ensure that all console messages are sent to the first serial port, which can assist
Azure support with debugging issues. In addition to the above action, we recommend that you
remove the following parameters:
Graphical and quiet boot are not useful in a cloud environment where we want all the logs to be
sent to the serial port. The crashkernel option can be left configured if desired, but note that this
parameter will reduce the amount of available memory in the VM by 128 MB or more. This might
be problematic on smaller VM sizes.
Rebuild initramfs:
dracut f -v
8. Ensure that the SSH server is installed and configured to start at boot time. This is usually the de-
fault. Modify /etc/ssh/sshd_config to include the following line:
ClientAliveInterval 180
9. The WALinuxAgent package WALinuxAgent-<version> has been pushed to the Red Hat extras
repository. Enable the extras repository by running the following command:
10. Install the Azure Linux Agent by running the following command:
11. Do not create swap space on the OS disk. The Azure Linux Agent can automatically configure swap
space by using the local resource disk that is attached to the VM after the VM is provisioned on
Azure. Note that the local resource disk is a temporary disk, and might be emptied when the VM is
deprovisioned. After you install the Azure Linux Agent (see the previous step), modify the follow-
ing parameters in /etc/waagent.conf appropriately:
12. If you want to unregister the subscription, run the following command:
13. Run the following commands to deprovision the virtual machine and prepare it for provisioning on
Azure:
export HISTSIZE=0
logout
Make sure that the size of the raw image is aligned with 1 MB. Otherwise, round up the size to
align with 1 MB:
MB=$((1024*1024))
rounded_size=$((($size/$MB + 1)*$MB))
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=us
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp
# Root password
rootpw --plaintext to_be_disabled
# System timezone
timezone Etc/UTC --isUtc --ntpservers 0.rhel.pool.ntp.org,1.rhel.pool.ntp.org,2.rhel.pool.ntp.org,3.
rhel.pool.ntp.org
# Firewall configuration
firewall --disabled
# Enable SELinux
selinux --enforcing
# Dont configure X
skipx
%packages
@base
@console-internet
chrony
sudo
parted
-dracut-config-rescue
%end
%post --log=/var/log/anaconda/post-install.log
#!/bin/bash
# Install WALinuxAgent
yum install -y WALinuxAgent
# Configure network
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
USERCTL=no
PEERDNS=yes
IPV6INIT=no
NM_CONTROLLED=yes
EOF
%end
2. Place the kickstart file in a place that is accessible from the installation system.
3. In Hyper-V Manager, create a new VM. On the Connect Virtual Hard Disk page, select Attach a
virtual hard disk later, and complete the New Virtual Machine Wizard.
4. Open the VM settings: a. Attach a new virtual hard disk to the VM. Make sure to select VHD For-
mat and Fixed Size. b. Attach the installation ISO to the DVD drive. c. Set the BIOS to boot from
CD.
5. Start the VM. When the installation guide appears, press Tab to configure the boot options.
6. Enter inst.ks=<the location of the kickstart file> at the end of the boot options, and press Enter.
7. Wait for the installation to finish. When its finished, the VM will be shut down automatically. Your
Linux VHD is now ready to be uploaded to Azure.
Repro rate:
This issue is intermittent. However, it occurs more frequently during frequent disk I/O operations in
Hyper-V and Azure.
[AZURE.NOTE] This known issue has already been addressed by Red Hat. To install the associated fixes,
run the following command:
# sudo yum update
The Hyper-V driver could not be included in the initial RAM disk when using a non-Hyper-V hypervi-
sor
In some cases, Linux installers might not include the drivers for Hyper-V in the initial RAM disk (initrd
or initramfs) unless it detects that it is running in a Hyper-V environment.
When youre using a different virtualization system (i.e. Virtualbox, Xen, etc.) to prepare your Linux
image, you might need to rebuild initrd to ensure that at least the hv_vmbus and hv_storvsc kernel
modules are available on the initial RAM disk. This is a known issue at least on systems based on the
upstream Red Hat distribution.
To resolve this issue, you need to add Hyper-V modules into initramfs and rebuild it:
Rebuild initramfs:
# dracut f -v
For more details, see the information about rebuilding initramfs.
Next steps
Youre now ready to use your Red Hat Enterprise Linux virtual hard disk to create new virtual machines
in Azure. If this is the first time that youre uploading the .vhd file to Azure, see steps 2 and 3 in Creat-
ing and uploading a virtual hard disk that contains the Linux operating system.
For more details about the hypervisors that are certified to run Red Hat Enterprise Linux, see the Red
Hat website.
The yum repository list, which is managed by RHUI, is configured in your RHEL instance during provi-
sioning. You dont need to do any additional configuration - run yum update after your RHEL instance
is ready to get the latest updates.
Note
Azure RHUI infrastructure has been recently updated (September 2016) and requires changes in the
configuration of your existing RHEL instances for uninterrupted access to the Azure RHUI. Refer to the
RHUI Azure Infrastructure Update section for details.
Date Note
September 22, RHUI servers and install directions available for use. VMs deployed using
2016 the new (September 2016 dated) RHEL PAYG marketplace images will
automatically use the new RHUI servers, but existing VMs are opt-in
November 1, Legacy RHEL PAYG VM images (which use the old Azure RHUI servers)
2016 will be removed from the Azure Marketplace gallery
January 16, 2017 The old Azure RHUI servers will be decommissioned. Update all of your
affected PAYG RHEL VMs by this time to maintain access to Azure RHUI
# Azure Global
13.91.47.76
40.85.190.91
52.187.75.218
52.174.163.213
# Azure US Government
13.72.186.193
# Azure Germany
51.5.243.77
51.4.228.145
For RHEL 7
curl -o azureclient.rpm https://rhui-1.microsoft.com/pulp/repos/microsoft-azure-rhel7/rhui-azure-
rhel7-2.0-2.noarch.rpm
Verify:
rpm -Kv azureclient.rpm
Use the following script as needed to automate the task of updating affected VMs to the new Azure
RHUI servers.
# Download key
curl -o RPM-GPG-KEY-microsoft-azure-release https://download.microsoft.com/download/9/
D/9/9d945f05-541d-494f-9977-289b3ce8e774/microsoft-sign-public.asc
# Validate key
if ! gpg --list-packets --verbose < RPM-GPG-KEY-microsoft-azure-release | grep -q keyid: EB3E94AD-
BE1229CF; then
echo Keyfile azure.asc NOT valid. Exiting.
exit 1
fi
# Install Key
sudo install -o root -g root -m 644 RPM-GPG-KEY-microsoft-azure-release /etc/pki/rpm-gpg
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release
# Verify package
if ! rpm -Kv azureclient.rpm | grep -q key ID be1229cf: OK; then
echo RPM failed validation ($url)
exit 1
fi
# Install package
sudo rpm -U azureclient.rpm
RHUI overview
Red Hat Update Infrastructure offers a highly scalable solution to manage yum repository content for
Red Hat Enterprise Linux cloud instances that are hosted by Red Hat-certified cloud providers. Based
on the upstream Pulp project, RHUI allows cloud providers to locally mirror Red Hat-hosted repository
content, create custom repositories with their own content, and make those repositories available to a
large group of end users through a load-balanced content delivery system.
Note
Access to Azure-hosted RHUI is limited to the VMs within Microsoft Azure Datacenter IP ranges.+
To unregister RHUI and reregister to your update infrastructure follow the below steps.
1. Edit /etc/yum.repos.d/rh-cloud.repo and change all enabled=1 to enabled=0. For example:
3. Then register with the desired infrastructure, such as Red Hat Customer Portal. Follow Red Hat
solution guide on how to register and subscribe a system to the Red Hat Customer Portal.
Access to the Azure-hosted RHUI is included in the RHEL Pay-As-You-Go (PAYG) image price. Unregis-
tering a PAYG RHEL VM from the Azure-hosted RHUI does not convert the virtual machine into Bring-
Your-Own-License (BYOL) type VM and hence you may be incurring double charges if you register the
same VM with another source of updates.
If you consistently need to use an update infrastructure other than Azure-hosted RHUI consider cre-
ating and deploying your own (BYOL-type) images as described in Create and Upload Red Hat-based
virtual machine for Azure article.
Next steps
To create a Red Hat Enterprise Linux VM from Azure Marketplace Pay-As-You-Go image and leverage
Azure-hosted RHUI go to Azure Marketplace. You will be able to use yum update in your RHEL in-
stance without any additional setup.