Configuring Agents in Swap space on Windows Azure on Linux VMS

Source: Internet
Author: User
Keywords Azure linux azure swap space configure agent

This article is written by http://www.aliyun.com/zixun/aggregation/13357.html ">azure CAT team Piyush Ranjan (MSFT).

In the previous article, in part 1th of the swap space on Linux VMS on Windows Azure, I described why the Linux VM configured in the Azure IaaS Mirror Library was not configured with swap space by default. This article also provides a series of simple steps for configuring file-based swap space on a resource disk (/mnt/resource). It should be noted, however, that the steps described at the time apply to the configured and running VM. Ideally, people want to automatically configure swap space when the VM is configured, instead of waiting for a bunch of commands to be run manually later.

The trick to automatically configure swap space when configuring a VM is to use the Windows Azure Linux agent (waagent). Most people vaguely know that a proxy is running in a Linux VM, but at the same time it is somewhat too obscure to ignore, although there are detailed documentation on Waagent on the Azure portal. See the Windows Azure Linux Proxy User's Guide. Before delving into the details of waagent and how to use it for the task at hand, it is important to understand that if you have a custom Linux VM of your own and exported it as a reusable mirror for future configuration of the Linux VM, this works fine. The preset waagent feature cannot be changed while using the Linux Raw library mirrors in the Azure library. This is not necessarily a restriction, because in the use case scenario that I think is most useful, I originally used a VM configured with a library image and then customized for the functionality I needed, for example, I wanted standard Java rather than open JDK Java, or I might have compiled Hadoop on a VM, So that mirroring can later be used for multi-node clusters. In this case, it is also easy to configure Waagent to perform other actions that I want to automate through the configuration process.

As described in the Windows Azure Linux Proxy User Guide, you can configure the agent to perform many actions, including:

Resource Disk Management

formatting and installing disk resources

Configure Swap Space

Waagent is already installed in the VM that is configured through the library mirroring, and you only need to edit the configuration file that is located in "/etc/waagent.conf", which is configured as follows:

Change the two lines in the configuration file, as shown in the previous illustration, to enable swapping by setting the following:

Set Resourcedisk.enableswap=y

Set resourcedisk.swapsizemb=5120

Therefore, the whole process is as follows:

Use one of the mirrors in the library to configure the Linux VM in IaaS as usual.

Customize the VM to your liking by installing or removing the software components you need.

Edit the/etc/waagent.conf file to set up the swap-related rows, as shown in the previous illustration. Adjusts the size of the swap file (above is set to 5 GB).

Use the instructions described here to capture a reusable mirror of a VM.

Configure the new Linux VM with the mirror you just exported. These VMs will automatically enable swap space.

Talking about Windows Azure Linux Proxy, it has to say that it provides another interesting feature, that is, to execute any user-specified script through the Role.stateconsumer property in the same profile "/etc/waagent.conf". For example, you can create a shell script "do-cfg.sh" as follows:

Then, set the role.stateconsumer=/home/scripts/do-cfg.sh in the configuration file, or set it to the script path. Waagent then executes the script before sending the "Ready" signal to Azure Fabric before configuring the VM. It passes command-line argument "Ready" to a custom script that can be tested within a script, and performs some custom initialization as shown in the illustration above. Similarly, Waagent executes the same script when the VM shuts down and passes the command-line argument "Shutdown" to a script that can be tested, and some custom cleanup tasks can run in the VM.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.