<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>7.2. Adding Regions (optional)</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta name="generator" content="publican 2.8" /><meta name="package" content="Apache_CloudStack-Admin_Guide-4.1.0-it-IT-1-" /><script type="text/javascript" src="../../../../../toc.js"></script><script type="text/javascript">
              addID('Apache_CloudStack');
              
	      addID('Apache_CloudStack.4.1.0');
              
              addID('Apache_CloudStack.4.1.0.books');
	      addID('Apache_CloudStack.4.1.0.Admin_Guide');
              </script><link rel="home" href="index.html" title="Manuale di Amministrazione CloudStack" /><link rel="up" href="provisioning-steps.html" title="Capitolo 7. Steps to Provisioning Your Cloud Infrastructure" /><link rel="prev" href="provisioning-steps-overview.html" title="7.1. Overview of Provisioning Steps" /><link rel="next" href="zone-add.html" title="7.3. Adding a Zone" /></head><body class="toc_embeded "><div id="tocdiv" class="toc"><iframe id="tocframe" class="toc" src="../../../../toc.html">This is an iframe, to view it upgrade your browser or enable iframe display.</iframe></div><p id="title"><a class="left" href="http://cloudstack.apache.org"><img src="Common_Content/images/image_left.png" alt="Product Site" /></a><a class="right" href="http://cloudstack.apache.org/docs"><img src="Common_Content/images/image_right.png" alt="Documentation Site" /></a></p><ul class="docnav"><li class="previous"><a accesskey="p" href="provisioning-steps-overview.html"><strong>Indietro</strong></a></li><li class="next"><a accesskey="n" href="zone-add.html"><strong>Avanti</strong></a></li></ul><div xml:lang="it-IT" class="section" id="region-add" lang="it-IT"><div class="titlepage"><div><div><h2 class="title" id="region-add">7.2. Adding Regions (optional)</h2></div></div></div><div class="para">
		Grouping your cloud resources into geographic regions is an optional step when provisioning the cloud. For an overview of regions, see <a class="xref" href="about-regions.html">Sezione 2.1, «About Regions»</a>.
	</div><div class="section" id="region-first"><div class="titlepage"><div><div><h3 class="title" id="region-first">7.2.1. The First Region: The Default Region</h3></div></div></div><div class="para">
			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.
		</div><div class="para">
			You can change the name or URL of the default region by using the API command updateRegion. For example:
		</div><pre class="programlisting">http://&lt;IP_of_Management_Server&gt;:8080/client/api?command=updateRegion&amp;id=1&amp;name=Northern&amp;endpoint=http://&lt;region_1_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D</pre></div><div class="section" id="region-add-2"><div class="titlepage"><div><div><h3 class="title" id="region-add-2">7.2.2. Adding a Region</h3></div></div></div><div class="para">
			Use these steps to add a second region in addition to the default region.
		</div><div class="orderedlist"><ol><li class="listitem"><div class="para">
					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 <code class="code">-r &lt;region_id&gt;</code> 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.
				</div><pre class="programlisting">cloudstack-setup-databases cloud:&lt;dbpassword&gt;@localhost --deploy-as=root:&lt;password&gt; -e &lt;encryption_type&gt; -m &lt;management_server_key&gt; -k &lt;database_key&gt; -r &lt;region_id&gt;</pre></li><li class="listitem"><div class="para">
					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.
				</div></li><li class="listitem"><div class="para">
					Add region 2 to region 1. Use the API command addRegion. (For information about how to make an API call, see the Developer's Guide.)
				</div><pre class="programlisting">http://&lt;IP_of_region_1_Management_Server&gt;:8080/client/api?command=addRegion&amp;id=2&amp;name=Western&amp;endpoint=http://&lt;region_2_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D</pre></li><li class="listitem"><div class="para">
					Now perform the same command in reverse, adding region 1 to region 2.
				</div><pre class="programlisting">http://&lt;IP_of_region_2_Management_Server&gt;:8080/client/api?command=addRegion&amp;id=1&amp;name=Northern&amp;endpoint=http://&lt;region_1_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D</pre></li><li class="listitem"><div class="para">
					Copy the account, user, and domain tables from the region 1 database to the region 2 database.
				</div><div class="para">
					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.
				</div><div class="orderedlist"><ol class="loweralpha"><li class="listitem"><div class="para">
							First, run this command to copy the contents of the database:
						</div><pre class="programlisting"># mysqldump -u root -p&lt;mysql_password&gt; -h &lt;region1_db_host&gt; cloud account user domain &gt; region1.sql</pre></li><li class="listitem"><div class="para">
							Then run this command to put the data onto the region 2 database:
						</div><pre class="programlisting"># mysql -u root -p&lt;mysql_password&gt; -h &lt;region2_db_host&gt; cloud &lt; region1.sql</pre></li></ol></div></li><li class="listitem"><div class="para">
					Remove project accounts. Run these commands on the region 2 database:
				</div><pre class="programlisting">mysql&gt; delete from account where type = 5;</pre></li><li class="listitem"><div class="para">
					Set the default zone as null:
				</div><pre class="programlisting">mysql&gt; update account set default_zone_id = null;</pre></li><li class="listitem"><div class="para">
					Restart the Management Servers in region 2.
				</div></li></ol></div></div><div class="section" id="region-add-n"><div class="titlepage"><div><div><h3 class="title" id="region-add-n">7.2.3. Adding Third and Subsequent Regions</h3></div></div></div><div class="para">
			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:
		</div><div class="orderedlist"><ol><li class="listitem"><div class="para">
					Install CloudStack in each additional region. Set the region ID for each region during the database setup step.
				</div><pre class="programlisting">cloudstack-setup-databases cloud:&lt;dbpassword&gt;@localhost --deploy-as=root:&lt;password&gt; -e &lt;encryption_type&gt; -m &lt;management_server_key&gt; -k &lt;database_key&gt; -r &lt;region_id&gt;</pre></li><li class="listitem"><div class="para">
					Once the Management Server is running, add your new region to all existing regions by repeatedly calling the API command addRegion. For example, if you were adding region 3:
				</div><pre class="programlisting">http://&lt;IP_of_region_1_Management_Server&gt;:8080/client/api?command=addRegion&amp;id=3&amp;name=Eastern&amp;endpoint=http://&lt;region_3_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D

http://&lt;IP_of_region_2_Management_Server&gt;:8080/client/api?command=addRegion&amp;id=3&amp;name=Eastern&amp;endpoint=http://&lt;region_3_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D</pre></li><li class="listitem"><div class="para">
					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:
				</div><pre class="programlisting">http://&lt;IP_of_region_3_Management_Server&gt;:8080/client/api?command=addRegion&amp;id=1&amp;name=Northern&amp;endpoint=http://&lt;region_1_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D

http://&lt;IP_of_region_3_Management_Server&gt;:8080/client/api?command=addRegion&amp;id=2&amp;name=Western&amp;endpoint=http://&lt;region_2_IP_address_here&gt;:8080/client&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D</pre></li><li class="listitem"><div class="para">
					Copy the account, user, and domain tables from any existing region's database to the new region's database.
				</div><div class="para">
					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.
				</div><div class="orderedlist"><ol class="loweralpha"><li class="listitem"><div class="para">
							First, run this command to copy the contents of the database:
						</div><pre class="programlisting"># mysqldump -u root -p&lt;mysql_password&gt; -h &lt;region1_db_host&gt; cloud account user domain &gt; region1.sql</pre></li><li class="listitem"><div class="para">
							Then run this command to put the data onto the new region's database. For example, for region 3:
						</div><pre class="programlisting"># mysql -u root -p&lt;mysql_password&gt; -h &lt;region3_db_host&gt; cloud &lt; region1.sql</pre></li></ol></div></li><li class="listitem"><div class="para">
					Remove project accounts. Run these commands on the region 2 database:
				</div><pre class="programlisting">mysql&gt; delete from account where type = 5;</pre></li><li class="listitem"><div class="para">
					Set the default zone as null:
				</div><pre class="programlisting">mysql&gt; update account set default_zone_id = null;</pre></li><li class="listitem"><div class="para">
					Restart the Management Servers in the new region.
				</div></li></ol></div></div><div class="section" id="region-delete"><div class="titlepage"><div><div><h3 class="title" id="region-delete">7.2.4. Deleting a Region</h3></div></div></div><div class="para">
			To delete a region, use the API command removeRegion. Repeat the call to remove the region from all other regions. For example, to remove the 3rd region in a three-region cloud:
		</div><pre class="programlisting">http://&lt;IP_of_region_1_Management_Server&gt;:8080/client/api?command=removeRegion&amp;id=3&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D

http://&lt;IP_of_region_2_Management_Server&gt;:8080/client/api?command=removeRegion&amp;id=3&amp;apiKey=miVr6X7u6bN_sdahOBpjNejPgEsT35eXq-jB8CG20YI3yaxXcgpyuaIRmFI_EJTVwZ0nUkkJbPmY3y2bciKwFQ&amp;signature=Lxx1DM40AjcXU%2FcaiK8RAP0O1hU%3D</pre></div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="provisioning-steps-overview.html"><strong>Indietro</strong>7.1. Overview of Provisioning Steps</a></li><li class="up"><a accesskey="u" href="#"><strong>Risali</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Partenza</strong></a></li><li class="next"><a accesskey="n" href="zone-add.html"><strong>Avanti</strong>7.3. Adding a Zone</a></li></ul></body></html>
