Create SSD multi-disk RAID0 virtual machines with arm batch Automation

Source: Internet
Author: User

In the actual production environment at large-scale deployment, sometimes need to be able to batch create multiple Linux virtual machines, and the virtual machine with multiple hard disks, some database environment, such as MySQL and MongoDB, will require more than 10000DE IOPS, then the virtual machine created, It is best to automate the creation of RAID 0 disk arrays to meet high IOPS requirements, plus availability set,nsg,public ip,dns and so on are certainly essential.

For such a complex need, there are a number of options to consider, but each has its merits and demerits, some due to limitations, may not work:

    1. With VMSS, you can quickly expand and shrink automatically, but you don't currently support data disks, so it's not an option
    2. Using the Powershell/azure CLI to write scripts, this may be the only option in the ASM era, but the definition implementations are mixed together, difficult to maintain, and have a lot of problems with performance in ASM, which is not recommended under Arm
    3. In arm mode, the arm template is responsible for defining individual components, which are created using the Azure CLI or PowerShell, which is also recommended in arm mode
    4. For the automated RAID 0 creation under Linux, there is no doubt that Shell scripting is needed, and then the Azure VM's extension can be used

Since the basic strategy is determined, we will first use the arm template to create the virtual machine, on the QuickStart there is no ready-made template can be used directly to create multiple virtual machines, multiple disks, and through a simple parameter file can be specified, so I made a template, support the following features:

    1. Support for specifying multiple virtual machine creation via parameters
    2. Supports public IP, one per virtual machine
    3. NSG Support, default open 22 port to SSH
    4. Supports availability Set, you can specify a name
    5. Support multiple disks, the default is to add two P30 disks, you can simply modify, increase or decrease
    6. Support for custom scripts to automate the creation of RAID 0 disk arrays

The full arm template I have placed under GitHub, if needed can be downloaded using:

Https://github.com/kingliantop/azurelabs/tree/master/AzureChinaARMTemplate/VM-multiple-datadisks-SSD

When creating an arm template, if you want to pass in parameters to decide how many virtual machines to create, you need to be aware of the various mutually exclusive resources, such as NICs, such as IP addresses, because once these resources are assigned to the first virtual machine, they cannot be assigned to the second virtual machine, or they will get an error:

For scripts that automate the creation of RAID 0, the original script (vm-disk-utils-0.1.sh) was designed for Ubuntu:

Https://github.com/Azure/azure-quickstart-templates/tree/master/shared_scripts/ubuntu

My test environment is CentOS6.8, unable to work, I made some modifications and optimizations, detailed instructions see the script description:

https://github.com/kingliantop/azurelabs/blob/master/AzureChinaARMTemplate/VM-multiple-datadisks-SSD/vm-disk-utils-0.2.sh

So how do you use these templates to quickly create a virtual machine?

modifying template parameter Files

    1. First of all, according to your needs, do a basic parameter modification, such as the user name password of the Linux virtual machine you created, how many units you need to create, what version you need to create, and so on, please open the Parameters.json file with four parameters, make some corresponding changes and save, about parameters: " Virtualmachinesnameprefix ", because of the creation of multiple virtual machines, so this name will increase in order, such as you set this parameter to MongoDB, then the virtual machine name will be mongodb-1,mongodb-2 and so on.
    2. If you want to modify some other parameters, such as OS version number, naming rules and so on, you can open Template.json to modify and save
Linux and Mac users

    1. To install the Azure CLI, if you do not know how to install it, refer to the tunneling:

      http://cloudapps.blog.51cto.com/3136598/1842181

    2. Download the template to a local directory.
    3. Method One: I have made a simple deploy.sh for deployment under Linux and Mac and can be used directly
    4. Method Two: Execute the command directly

      #登陆到Azure账号

      Azure Login-u username-p password-e Azurechinacloud

      #创建资源组

      Azure Group Create--name= "Stevenvmgroup"--location= "China North"

      #利用模板创建多个虚拟机并自动化配置RAID 0

      Azure Group Deployment Create--name= "Mydcoschinadeploy"--resource-group= "STEVENACSDCOSGP"--template-file= ". \ Template.json "--parameters-file=". \parameters.json "

Windows users
    1. Install Azure Powershell
    2. Download templates to Local
    3. Method One: Direct use of DEPLOY.PS1
    4. Method Two: Execute the command directly

      #登陆到Azure的中国账号

      Login-azurermaccount-environmentname Azurechinacloud

      #基本参数, the same as the deployment name and resource name

      $VerbosePreference = "Continue"

      $deployName = "Stevenwebscale"

      $RGName = $deployName

      $locName = "China North"

      $templateFile = ". \template.json"

      $templateParameterFile = ". \parameters.json"

      New-azurermresourcegroup-name $RGName-location $locName-force

      New-azurermresourcegroupdeployment-name Myvmdetestgroup-resourcegroupname Myvmdetestgroup-templateparameterfile $ Templateparameterfile-templatefile $templateFile

Graphical interface one-click Deployment

If you really don't like script creation:) You can open my previous GitHub link:

Https://github.com/kingliantop/azurelabs/tree/master/AzureChinaARMTemplate/VM-multiple-datadisks-SSD

Choose Deploy to Azure and deploy directly to your Azure China account with one click:

The Parameters window will appear, choose which resource group to use, how many virtual machines to create, which version, what type of virtual machine, and then OK. Fill out the parameters and create them directly:

According to the actual test, create 10 DS4 virtual machine including nsg,publicip,nic,vnet, each virtual machine Mount 2 P30 disk, and configure RAID 0, to format the disk, the whole process will only need 4 minutes 28 seconds :

You can see 10 virtual machines mysql-0 to mysql-9 all successfully created:

Each virtual machine is successfully created on disk, network, and so on:

Log in to the virtual machine and check the configuration of RAID 0:

    1. You can see that two disks have been formatted and mounted to the/data

    2. Check the configuration under some fstab to see that the current Mount Automation configuration has been added automatically:

      As you can see, by using the arm template, you can quickly create a complex configuration of virtual machines, you can use to see, if there are any problems, you can submit a question to GitHub, I can do as much as possible to modify or optimize.

Create SSD multi-disk RAID0 virtual machines with arm batch Automation

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.