Microsoft Azure

Prerequisites

  • Download and install terraform.

  • Verify by the terraform command, it should print a help message that looks similar to that shown below.

  1. $ terraform
  1. Usage: terraform [--version] [--help] <command> [args]
  2. ...
  3. Common commands:
  4. apply Builds or changes infrastructure
  5. console Interactive console for Terraform interpolations
  6. destroy Destroy Terraform-managed infrastructure
  7. env Workspace management
  8. fmt Rewrites config files to canonical format

1. Create a terraform config file

Create a terraform config file called yugabyte-db-config.tf and add following details to it. The terraform module can be found in the terraform-azure-yugabyte github repository.

  1. provider "azurerm" {
  2. # Provide your Azure Creadentilals
  3. subscription_id = "AZURE_SUBSCRIPTION_ID"
  4. client_id = "AZURE_CLIENT_ID"
  5. client_secret = "AZURE_CLIENT_SECRET"
  6. tenant_id = "AZURE_TENANT_ID"
  7. }
  8. module "yugabyte-db-cluster" {
  9. # The source module used for creating AWS clusters.
  10. source = "github.com/Yugabyte/terraform-azure-yugabyte"
  11. # The name of the cluster to be created, change as per need.
  12. cluster_name = "test-cluster"
  13. # key pair.
  14. ssh_private_key = "SSH_PRIVATE_KEY_HERE"
  15. ssh_public_key = "SSH_PUBLIC_KEY_HERE"
  16. ssh_user = "SSH_USER_NAME_HERE"
  17. # The region name where the nodes should be spawned.
  18. region_name = "YOUR VPC REGION"
  19. # The name of resource group in which all Azure resource will be created.
  20. resource_group = "test-yugabyte"
  21. # Replication factor.
  22. replication_factor = "3"
  23. # The number of nodes in the cluster, this cannot be lower than the replication factor.
  24. node_count = "3"
  25. }

NOTE: To insatll terraform and configure it for Azure, follow steps given here

2. Create a cluster

Init terraform first if you have not already done so.

  1. $ terraform init

Now run the following to create the instances and bring up the cluster.

  1. $ terraform apply

Once the cluster is created, you can go to the URL http://<node ip or dns name>:7000 to view the UI. You can find the node’s ip or dns by running the following:

  1. $ terraform state show azurerm_virtual_machine.Yugabyte-Node[0]

You can access the cluster UI by going to any of the following URLs.

You can check the state of the nodes at any point by running the following command.

  1. $ terraform show

3. Verify resources created

The following resources are created by this module:

  • module.azure-yugabyte.azurerm_virtual_machine.Yugabyte-Node The Azure VM instances.

For cluster named test-cluster, the instances will be named yugabyte-test-cluster-node-1, yugabyte-test-cluster-node-2, yugabyte-test-cluster-node-3.

  • module.azure-yugabyte.azurerm_network_security_group.Yugabyte-SG The security group that allows the various clients to access the YugabyteDB cluster.

For cluster named test-cluster, this security group will be named yugabyte-test-cluster-SG with the ports 7000, 9000, 9042, 7100, 9200 and 6379 open to all other instances in the same security group.

  • module.azure-yugabyte.null_resource.create_yugabyte_universe A local script that configures the newly created instances to form a new YugabyteDB universe.
  • module.azure-yugabyte.azurerm_network_interface.Yugabyte-NIC The Azure network interface for VM instance.

For cluster named test-cluster, the network interface will be named yugabyte-test-cluster-NIC-1, yugabyte-test-cluster-NIC-2, yugabyte-test-cluster-NIC-3.

4. Destroy the cluster (optional)

To destroy what we just created, you can run the following command.

  1. $ terraform destroy

Microsoft Azure - 图1Microsoft Azure - 图2

Prerequisites

  • Create a resource group for our YugabyteDB deployment.

    • Login into your Azure portal.
    • Click Resource groups from the menu of services to access the Resource Groups blade. You will see all the resource groups in your subscription listed in the blade.
    • Click Add (+) to create a new resource group. The Create Resource Group blade appears.
    • Provide the needed information for the new resource group.
    • Click Create. The resource group might take a few seconds to create. Once it is created, you see the resource group on the Azure portal dashboard.
    • Create an SSH key for our user to get access to deployed YugabyteDB VMs.

      • Open Terminal on your local computer.
      • Run the following command
  1. ssh-keygen
  1. -

The utility prompts you to select a location for the keys. By default, the keys are stored in the ~/.ssh directory with the filenames id_rsa for the private key and id_rsa.pub for the public key. Using the default locations allows your SSH client to automatically find your SSH keys when authenticating, so we recommend accepting them by pressing ENTER

  1. Generating a public/private RSA key pair.
  2. Enter file in which to save the key (/home/username/.ssh/id_rsa):
  1. -

Once you select a location for the key, you’ll be prompted to enter an optional passphrase which encrypts the private key file on disk.

  1. Created directory '/home/username/.ssh'.
  2. Enter passphrase (empty for no passphrase):
  3. Enter same passphrase again:
  1. -

After this, you will have a public and private key that you can use to authenticate YugabyteDB VM’s.

  1. Your identification has been saved in /home/username/.ssh/id_rsa.
  2. Your public key has been saved in /home/username/.ssh/id_rsa.pub.
  3. The key fingerprint is:
  4. a9:49:EX:AM:PL:E3:3e:a9:de:4e:77:11:58:b6:90:26 [email protected]
  5. The key's randomart image is:
  6. +--[ RSA 2048]----+
  7. | ..o |
  8. | E o= . |
  9. | o. o |
  10. | .. |
  11. | ..S |
  12. | o o. |
  13. | =o.+. |
  14. |. =++.. |
  15. |o=++. |
  16. +-----------------+

Deploying using Azure Cloud Shell

  • Launch Cloud ShellMicrosoft Azure - 图3

  • Clone this repo.

  1. $ git clone https://github.com/yugabyte/azure-resource-manager.git
  • Change current directory to cloned git repo directory
  1. $ cd azure-resource-manager
  • Use Azure CLI command to create deployments
  1. $ az group deployment create --resource-group <Your-Azure-Resource-Group> --template-file yugabyte_deployment.json --parameters ClusterName='<Your-Cluster-Name>' SshUser='<Your-SSH-USER>' YBVersion='2.0.6.0' SshKeypair='<Your-SSH-USER-PublicKey-File-Contents>'
  • Once the deployment creation is complete, you can describe it as shown below.
  1. $ az group deployment show -g <Your-Azure-Resource-Group> -n <Your-Deployment-Name> --query properties.outputs

In the output, you will get the YugabyteDB admin URL, JDBC URL, YSQL, YCQL and YEDIS connection string. You can use YugabyteDB admin URL to access admin portal.

Deploying using Azure Portal

  • Clone this repo locally.
  1. $ git clone https://github.com/yugabyte/azure-resource-manager.git
  • First create a resource group, to create a new resource group, select Resource groups from the Azure portal.

  • Under newly created Resource groups, select Add.

  • In opened marketplace search for Template deployment (deploy using custom templates) and click on create.

  • Now click on Build your own template in the editor.

  • Click Load file button in specify template section and upload the yugabyte_deployment.json file from cloned repo.

  • Click on the Save button at the bottom of the window.

  • Now provide the required details.

  • Once details are provided, then check the Terms and Condition checkbox and click on the Purchase button.

  • Once deployments get compleated, you can access the YugabyteDB admin from URL you get in the deployment output section.

Refer the AKS deployment instructions in the Kubernetes section.