Product SiteDocumentation Site

7.2. Adding Regions (optional)

Grouping your cloud resources into geographic regions is an optional step when provisioning the cloud. For an overview of regions, see Section 2.1, “About Regions”.

7.2.1. The First Region: The Default Region

If you do not take action to define regions, then all the zones in your cloud will be automatically grouped into a single default region. This region is assigned the region ID of 1. You can change the name or URL of the default region by displaying the region in the CloudStack UI and clicking the Edit button.

7.2.2. Adding a Region

Use these steps to add a second region in addition to the default region.
  1. Each region has its own CloudStack instance. Therefore, the first step of creating a new region is to install the Management Server software, on one or more nodes, in the geographic area where you want to set up the new region. Use the steps in the Installation guide. When you come to the step where you set up the database, use the additional command-line flag -r <region_id> to set a region ID for the new region. The default region is automatically assigned a region ID of 1, so your first additional region might be region 2.
    cloudstack-setup-databases cloud:<dbpassword>@localhost --deploy-as=root:<password> -e <encryption_type> -m <management_server_key> -k <database_key> -r <region_id>
  2. By the end of the installation procedure, the Management Server should have been started. Be sure that the Management Server installation was successful and complete.
  3. Now add the new region to region 1 in CloudStack.
    1. Log in to CloudStack in the first region as root administrator (that is, log in to <region.1.IP.address>:8080/client).
    2. In the left navigation bar, click Regions.
    3. Click Add Region. In the dialog, fill in the following fields:
      • ID. A unique identifying number. Use the same number you set in the database during Management Server installation in the new region; for example, 2.
      • Name. Give the new region a descriptive name.
      • Endpoint. The URL where you can log in to the Management Server in the new region. This has the format <region.2.IP.address>:8080/client.
  4. Now perform the same procedure in reverse. Log in to region 2, and add region 1.
  5. Copy the account, user, and domain tables from the region 1 database to the region 2 database.
    In the following commands, it is assumed that you have set the root password on the database, which is a CloudStack recommended best practice. Substitute your own MySQL root password.
    1. First, run this command to copy the contents of the database:
      # mysqldump -u root -p<mysql_password> -h <region1_db_host> cloud account user domain > region1.sql
    2. Then run this command to put the data onto the region 2 database:
      # mysql -u root -p<mysql_password> -h <region2_db_host> cloud < region1.sql
  6. Remove project accounts. Run these commands on the region 2 database:
    mysql> delete from account where type = 5;
  7. Set the default zone as null:
    mysql> update account set default_zone_id = null;
  8. Restart the Management Servers in region 2.

7.2.3. Adding Third and Subsequent Regions

To add the third region, and subsequent additional regions, the steps are similar to those for adding the second region. However, you must repeat certain steps additional times for each additional region:
  1. Install CloudStack in each additional region. Set the region ID for each region during the database setup step.
    cloudstack-setup-databases cloud:<dbpassword>@localhost --deploy-as=root:<password> -e <encryption_type> -m <management_server_key> -k <database_key> -r <region_id>
  2. Once the Management Server is running, add your new region to all existing regions by repeatedly using the Add Region button in the UI. For example, if you were adding region 3:
    1. Log in to CloudStack in the first region as root administrator (that is, log in to <region.1.IP.address>:8080/client), and add a region with ID 3, the name of region 3, and the endpoint <region.3.IP.address>:8080/client.
    2. Log in to CloudStack in the second region as root administrator (that is, log in to <region.2.IP.address>:8080/client), and add a region with ID 3, the name of region 3, and the endpoint <region.3.IP.address>:8080/client.
  3. Repeat the procedure in reverse to add all existing regions to the new region. For example, for the third region, add the other two existing regions:
    1. Log in to CloudStack in the third region as root administrator (that is, log in to <region.3.IP.address>:8080/client).
    2. Add a region with ID 1, the name of region 1, and the endpoint <region.1.IP.address>:8080/client.
    3. Add a region with ID 2, the name of region 2, and the endpoint <region.2.IP.address>:8080/client.
  4. Copy the account, user, and domain tables from any existing region's database to the new region's database.
    In the following commands, it is assumed that you have set the root password on the database, which is a CloudStack recommended best practice. Substitute your own MySQL root password.
    1. First, run this command to copy the contents of the database:
      # mysqldump -u root -p<mysql_password> -h <region1_db_host> cloud account user domain > region1.sql
    2. Then run this command to put the data onto the new region's database. For example, for region 3:
      # mysql -u root -p<mysql_password> -h <region3_db_host> cloud < region1.sql
  5. Remove project accounts. Run these commands on the region 3 database:
    mysql> delete from account where type = 5;
  6. Set the default zone as null:
    mysql> update account set default_zone_id = null;
  7. Restart the Management Servers in the new region.

7.2.4. Deleting a Region

Log in to each of the other regions, navigate to the one you want to delete, and click Remove Region. For example, to remove the third region in a 3-region cloud:
  1. Log in to <region.1.IP.address>:8080/client.
  2. In the left navigation bar, click Regions.
  3. Click the name of the region you want to delete.
  4. Click the Remove Region button.
  5. Repeat these steps for <region.2.IP.address>:8080/client.