From f340c8ce2e1d6881799407abfd7802852d61251a Mon Sep 17 00:00:00 2001 From: Andrew Leung Date: Wed, 25 Jul 2012 13:28:26 -0400 Subject: [PATCH 1/4] initial import of windows azure document --- .../deploy-mongodb-on-windows-azure.txt | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 draft/tutorial/deploy-mongodb-on-windows-azure.txt diff --git a/draft/tutorial/deploy-mongodb-on-windows-azure.txt b/draft/tutorial/deploy-mongodb-on-windows-azure.txt new file mode 100644 index 00000000000..fbb24eb2a12 --- /dev/null +++ b/draft/tutorial/deploy-mongodb-on-windows-azure.txt @@ -0,0 +1,259 @@ + +============================================= +Deploy a MongoDB Replica Set on Windows Azure +============================================= + +In this tutorial, you will learn to deploy a MongoDB replica set to +CentOS VMs on Windows Azure and access it from outside Azure. The +following are the tasks to achieve this: Sign up for the feature on +the Azure portal Set up affinity group Create and set up the virtual +machines Install and run MongoDB Configure the replica set + +# Signing up + + Sign up for ‘Virtual Machines and Virtual Networks’ preview feature + from the new Azure portal* In the ‘Preview’ portal, go to + Account->Preview Features. + + Sign up for the “Virtual Machines and Virtual Networks” + + .. note:: + + “*” – The VM Role beta program from the old Azure portal (shown + below) is not the same as the preview feature above + +# Set up affinity group + + The affinity group needs to be set up from the old portal. + + # If in the new Azure Management preview portal, click ‘Preview’ at + the top of the screen and then ‘Take me to the previous portal’ + to switch to the old portal + + # Once in the old portal, click ‘Hosted Services, Storage Accounts + & CDN’ + + # Select ‘Affinity Groups’ and then ‘New Affinity Group’ + + # In the “Create a New Affinity Group” dialog, enter an affinity + group name such as “mongoaffinitygroup” and choose a location + + Choose one of the newer Azure data centers such as “West US”, + “East US” or “West Europe” + +# Create and set up the virtual machines + + To create a 3-node MongoDB replica set you will be creating 3 VM + instances. For this step, log in to the new preview portal, or from + the old portal, click ‘Visit the Previous Portal’ at the bottom of + the page + +Create instances + +Instance 1 + +In the portal, click New->Virtual Machine->From Gallery + +On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and click the next arrow to continue + +On the VM Configuration page, specify values for the parameters +Virtual Machine Name - "mongodbrs1" +New User Name – "mongouser". This user will be added to the ‘sudoers’ list file +New Password box – type a strong password that confirms to the Azure specifications +Retype the password to confirm +Size – Choose appropriate size from drop down list. For anything but small test instances, choose a size larger than Medium +Leave ‘Upload SSH key for Authentication’ unchecked +Click the next arrow to continue + +On the VM Mode page, specify values for the required parameters +Select ‘Standalone Virtual Machine’ +DNS – a valid DNS prefix e.g. "mongodbrs" +Storage Account box – choose ‘Use Automatically Generated Storage Account’ +In the ‘Region/Affinity Group/Virtual Network’ box, select the affinity group created previously “mongoaffinitygroup” +Click next arrow to continue + +On the VM Options page select ‘None for Availability Set’ + +Click the check mark to create the VM instance +Instance 2 + +A similar process to creating instance 1. +In the portal, click New->Virtual Machine->From Gallery +On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and then the next arrow to continue +On the VM Configuration page, specify values for the parameters +Virtual Machine Name – "mongodbrs2" +New User Name – "mongouser". This user will be added to the Sudoers list file. For ease of use specify the same user name as for instance 1 +New Password box – type a strong password that confirms to the Azure specifications +Retype the password to confirm +Size – Choose the same instance size as instance 1 +Leave ‘Upload SSH key for Authentication’ unchecked +Click the next arrow to continue +On the VM Mode page, specify values for the required parameters +Select ‘Connect to Existing Virtual Machine’ +In the dropdown choose instance 1 ‘mongodbrs1’ +Storage Account box – choose ‘Use Automatically Generated Storage Account’ +The ‘Region/Affinity Group/Virtual Network’ box should be automatically set to “mongoaffinitygroup” +Click the next arrow to continue + +On the VM Options page select ‘None for Availability Set’ +Click the check mark to create the VM instance +Instance 3 + +A similar process for creating instance 2. Choose ‘mongodbrs3’ to be the Virtual Machine Name in step 3. +Configure endpoints + +Once the virtual machines are connected you need to configure the endpoints to: +Allow remote connection +Allow mongo traffic +Instance 1: + +In the management portal, click virtual machines and click the name of instance 1, ‘mongodbrs1’ +Now click on endpoints +The ssh endpoint should be automatically created. For this endpoint ensure the following are set +Protocol – tcp +Public Port – 22 +Private Port – 22 +Load Balanced – No +Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen +Ensure ‘Add endpoint’ is selected and click the right arrow to go to the next screen + +Specify the endpoint details as below: +Name : MongoDB-Port +Protocol : TCP +Public Port : 27018 +Private Port : 27018 +Click on check mark to create endpoint + +The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB + +Instance 2: + +We need to configure the endpoints for instance 2 similar to instance 1: +In the management portal, click ‘virtual machines’ and click the name of instance 2 +Now click on ‘endpoints’ +The ssh endpoint should be automatically created. Ensure that: +Name – SSH +Protocol – TCP +Private Port – 22 +Load Balanced – No +Now click on Edit Endpoint at the bottom of the screen and set ‘Public Port’ to 23. Click on the ‘check mark’ to update +Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen +Ensure ‘Add Endpoint’ is selected and click the right arrow to go to the next screen +Specify the endpoint details as below: +Name : MongoDB-Port +Protocol : TCP +Public Port : 27019 +Private Port : 27019 +Click on check mark to create endpoint +The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB + +Instance 3: + +Create endpoints for instance 3 similar to instance 2 with the following changes: +In step 4, set public port to 24 +In step 7, set public and private ports to be 27020 +The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB + +Update OS + +Use this optional step to update the operating system on each of your VM instances. Once the machine endpoints have been configured above, you need to log into the machines to update them. More information on this can be found at ‘How to Log on to a Virtual Machine Running Linux’ +Use the username and password you used when creating the virtual machine instances. +Once you are connected to the machine, update the operating system by running: sudo yum update and following the prompts. This could take some time. +Note: When connecting to instances 2 and 3, remember to use ports 23 and 24 and not the default ssh port of 22. + +Set up disks + +Once the instances are updated, you can then attach a data disk to each of the instances. The data disks will be storing the actual mongodb data as part of –dbpath. More information on Azure data disks can be found at Data Disk Concepts. +To set up the data disk follow the steps outlined below for each of the instances you created: +Attach an empty disk to the instance as described in How to: Attach an empty disk +Create a data disk of at least 10 GB +Now initialize the data disk by following the steps described at How to: Initialize a new data disk in Linux +Ensure you use ext4 for the file system and not ext3 +Also once mounted, create a mongodb data directory by: +Log on onto the instance +Then run sudo chown `id -u` /mnt/datadrive/ to make the mongouser the owner of the data directory +Run the following command: mkdir -p /mnt/datadrive/data +4. Install and run MongoDB + +As part of this step, you will be using the official 10gen supplied packages to install, configure and run MongoDB as a service using YUM. You want to install as a service since this would ensure that mongod is started on machine restart also. More information can be found at Install MongoDB on RedHat Enterprise, CentOS, or Fedora Linux doc page. +Install MongoDB + +Repeat the following steps on each instance. +Log onto the instance +Create a /etc/yum.repos.d/10gen.repo file to hold information about your repository using your favorite editor as sudo. Place the following configuration in /etc/yum.repos.d/10gen.repo file: +[10gen] +name=10gen Repository +baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 +gpgcheck=0 +enabled=1 +After saving the new .repo file, issue the following command to update the local package database: sudo yum update +Issue the following command (as root or with sudo) to install the latest stable version of MongoDB and the associated tools: +sudo yum install mongo-10gen mongo-10gen-server + +When this command completes, you have successfully installed MongoDB. + +Configure MongoDB + +The packages installed in the previous step configure MongoDB using the /etc/mongod.conf file in conjunction with the control script. You can find the init script at /etc/rc.d/init.d/mongod. As part of this step you will edit the mongod.conf file to set the appropriate parameters. If the parameters are commented, make sure to uncomment them. +Instance 1 + +Connect to the instance using ssh or PuTTY +As sudo, edit /etc/mongod.conf to set the following parameters: +port = 27018 +dbpath = /mnt/datadrive/data +logpath = /mnt/datadrive/mongod.log +replSet = mongors +Save the config file +Instance 2 + +Connect to the instance using ssh or PuTTY +As sudo, edit /etc/mongod.conf to set the following parameter: +port = 27019 +dbpath = /mnt/datadrive/data +logpath = /mnt/datadrive/mongod.log +replSet = mongors +Save the config file +Instance 3 + +Connect to the instance using ssh or PuTTY +As sudo, edit /etc/mongod.conf to set the following parameter: +port = 27020 +dbpath = /mnt/datadrive/data +logpath = /mnt/datadrive/mongod.log +replSet = mongors +Save the config file +Start MongoDB + +Once the configuration files have been edited, start the database process mongod on each instance by: +Log on onto the instance +Run the following command to start the process: +mongod –config /etc/mongod.conf +This should start the mongod process +Verify that mongod start by tailing the log file using the command +tail –f /mnt/datadrive/mongod.log +The ‘waiting for connections’ message in the log file indicates mongod is up and running and waiting for client connections. This may take a while as mongod preallocates its journal files + +5. Configure the replica set + +At this point in time, you should have mongod running on all 3 of your instances. You can now configure the 3 instances as a replica set by connecting to 1 of the 3 instances from within Azure or from outside. +Connect to the running mongod process using the mongo shell: +If connected to the VM instance type the following command where port is 27018 for instance 1, 27019 for instance 2 and 27020 for instance 3: mongo –port +If connecting to the mongod process in Azure from your local machine use the following command: mongo –host mongodbrs.cloudapp.net –port +In the mongo shell type the following: +> conf = { +_id = “mongors”, +members : [ +{id:0, host:”mongodbrs.cloudapp.net:27018}, +{id:0, host:”mongodbrs.cloudapp.net:27019}, +{id:0, host:”mongodbrs.cloudapp.net:27020}]} +>rs.initiate(conf) + +This will start the initialization of the mongodb replica set +Type the command ‘rs.status()’ to check the status of the replica set. Upon successful initialization, you should see 1 of the 3 instances being the ‘Primary’ of the set and the other 2 being the ‘Secondaries’ + +You have now successfully initiated the replica set +Summary + +In this tutorial you have learned how to create a set of CentOS virtual machines on Windows Azure, deploy MongoDB to them and create a replica set out of them. You can access this set from anywhere using the connection string ‘mongodb://mongodbrs.cloudapp.net:27018, mongodbrs.cloudapp.net:27019, mongodbrs.cloudapp.net:27020/?replicaSet=mongors’. +More information on MongoDB can be found at http://docs.mongodb.org/manual/. +To create and deploy a replica set to Windows Virtual Machines on Azure you can use the MongoDB Installer for Windows Azure. From c3fd5624c4aa3bc3faef39fef0aa661400098a47 Mon Sep 17 00:00:00 2001 From: Andrew Leung Date: Wed, 25 Jul 2012 14:21:59 -0400 Subject: [PATCH 2/4] initial draft of mongodb for centos on azure --- ...loy-mongodb-to-centos-on-windows-azure.txt | 411 ++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100644 draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt diff --git a/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt b/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt new file mode 100644 index 00000000000..bd2c4aca0f7 --- /dev/null +++ b/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt @@ -0,0 +1,411 @@ +=========================================================== +Deploy a MongoDB Replica Set to CentOS VMs on Windows Azure +=========================================================== + +.. default-domain:: mongodb + +In this tutorial, you will learn to deploy a MongoDB replica set to +CentOS VMs on Windows Azure and access it from outside Azure. The +following are the tasks to achieve this: + + #. Sign up for the feature on the Azure portal + #. Set up affinity group + #. Create and set up the virtual machines + #. Install and run MongoDB + #. Configure the replica set + +#. Signing up + + Sign up for ‘Virtual Machines and Virtual Networks’ preview feature + from the new Azure portal* In the ‘Preview’ portal, go to + Account->Preview Features. + + Sign up for the “Virtual Machines and Virtual Networks” + + .. TODO make this a subscript + + .. note:: + + “*” – The VM Role beta program from the old Azure portal (shown + below) is not the same as the preview feature above + +#. Set up affinity group + + The affinity group needs to be set up from the old portal. + + #. If in the new Azure Management preview portal, click ‘Preview’ at + the top of the screen and then ‘Take me to the previous portal’ + to switch to the old portal + + #. Once in the old portal, click ‘Hosted Services, Storage Accounts + & CDN’ + + #. Select ‘Affinity Groups’ and then ‘New Affinity Group’ + + #. In the “Create a New Affinity Group” dialog, enter an affinity + group name such as “mongoaffinitygroup” and choose a location + + * Choose one of the newer Azure data centers such as “West US”, + “East US” or “West Europe” + +#. Create and set up the virtual machines + + To create a 3-node MongoDB replica set you will be creating 3 VM + instances. For this step, log in to the new preview portal, or from + the old portal, click `Visit the Previous Portal` at the bottom of + the page + +Create instances +~~~~~~~~~~~~~~~~ + +Instance 1 +++++++++++ + + #. In the portal, click New->Virtual Machine->From Gallery + + #. On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and + click the next arrow to continue + + #. On the VM Configuration page, specify values for the parameters + + * Virtual Machine Name - ``mongodbrs1`` + * New User Name – ``mongouser``. This user will be added to the + ``sudoers`` list file + * New Password box – type a strong password that confirms to the + Azure specifications + * Retype the password to confirm + * Size – Choose appropriate size from drop down list. For + anything but small test instances, choose a size larger than + Medium + * Leave ``Upload SSH key for Authentication`` unchecked + + Click the next arrow to continue + + #. On the VM Mode page, specify values for the required parameters + + * Select ‘Standalone Virtual Machine’ + * DNS – a valid DNS prefix e.g. "mongodbrs" + * Storage Account box – choose ‘Use Automatically Generated Storage Account’ + * In the ‘Region/Affinity Group/Virtual Network’ box, select the + affinity group created previously “mongoaffinitygroup” + + Click next arrow to continue + + #. On the VM Options page select ``None for Availability Set`` + + #. Click the check mark to create the VM instance + +Instance 2 +++++++++++ + +A similar process to creating instance 1. + + #. In the portal, click New->Virtual Machine->From Gallery + #. On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and then the next arrow to continue + #. On the VM Configuration page, specify values for the parameters + + * Virtual Machine Name – "mongodbrs2" + * New User Name – "mongouser". This user will be added to the Sudoers list file. For ease of use specify the same user name as for instance 1 + * New Password box – type a strong password that confirms to the Azure specifications + * Retype the password to confirm + * Size – Choose the same instance size as instance 1 + * Leave ‘Upload SSH key for Authentication’ unchecked + + Click the next arrow to continue + + #. On the VM Mode page, specify values for the required parameters + + * Select ‘Connect to Existing Virtual Machine’ + * In the dropdown choose instance 1 ‘mongodbrs1’ + * Storage Account box – choose ‘Use Automatically Generated Storage Account’ + * The ‘Region/Affinity Group/Virtual Network’ box should be automatically set to “mongoaffinitygroup” + + Click the next arrow to continue + + #. On the VM Options page select ‘None for Availability Set’ + + #. Click the check mark to create the VM instance + +Instance 3 +++++++++++ + +A similar process for creating instance 2. Choose ‘mongodbrs3’ to be the Virtual Machine Name in step 3. + +Configure endpoints +~~~~~~~~~~~~~~~~~~~ + +Once the virtual machines are connected you need to configure the endpoints to: +* Allow remote connection +* Allow mongo traffic + +Instance 1 +++++++++++ + +#. In the management portal, click virtual machines and click the name of instance 1, ‘mongodbrs1’ +#. Now click on endpoints +#. The ssh endpoint should be automatically created. For this endpoint ensure the following are set + + * Protocol – tcp + * Public Port – 22 + * Private Port – 22 + * Load Balanced – No +#. Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen +#. Ensure ‘Add endpoint’ is selected and click the right arrow to go to the next screen + +#. Specify the endpoint details as below: + + * Name : MongoDB-Port + * Protocol : TCP + * Public Port : 27018 + * Private Port : 27018 + + Click on check mark to create endpoint + +The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB + +Instance 2 +++++++++++ + +We need to configure the endpoints for instance 2 similar to instance 1: + +#. In the management portal, click ‘virtual machines’ and click the name of instance 2 +#. Now click on ‘endpoints’ +#. The ssh endpoint should be automatically created. Ensure that: + + * Name – SSH + * Protocol – TCP + * Private Port – 22 + * Load Balanced – No + +#. Now click on Edit Endpoint at the bottom of the screen and set ‘Public Port’ to 23. Click on the ‘check mark’ to update +#. Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen +#. Ensure ‘Add Endpoint’ is selected and click the right arrow to go to the next screen +#. Specify the endpoint details as below: + + * Name: MongoDB-Port + * Protocol: TCP + * Public Port: 27019 + * Private Port: 27019 + + Click on check mark to create endpoint + +The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB + +Instance 3 +++++++++++ + +Create endpoints for instance 3 similar to instance 2 with the following changes: + +#. In step 4, set public port to 24 +#. In step 7, set public and private ports to be 27020 + +The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB + +Update OS ++++++++++ + +Use this optional step to update the operating system on each of your +VM instances. Once the machine endpoints have been configured above, +you need to log into the machines to update them. More information on +this can be found at ‘How to Log on to a Virtual Machine Running +Linux’ Use the username and password you used when creating the +virtual machine instances. Once you are connected to the machine, +update the operating system by running: sudo yum update and following +the prompts. This could take some time. + +.. note:: + + When connecting to instances 2 and 3, remember to use ports 23 and + 24 and not the default ssh port of 22. + +Set up disks +++++++++++++ + +Once the instances are updated, you can then attach a data disk to +each of the instances. The data disks will be storing the actual +mongodb data as part of –dbpath. More information on Azure data disks +can be found at Data Disk Concepts. To set up the data disk follow +the steps outlined below for each of the instances you created: + + #. Attach an empty disk to the instance as described in How to: Attach + an empty disk + #. Create a data disk of at least 10 GB + #. Now initialize the data disk by following the steps described at + How to: Initialize a new data disk in Linux Ensure you use ext4 for + the file system and not ext3 + #. Also once mounted, create a mongodb data directory by: + #. Log on onto the instance + #. Then run sudo chown `id -u` /mnt/datadrive/ to make the + mongouser the owner of the data directory + #. Run the following command: mkdir -p /mnt/datadrive/data + +#. Install and run MongoDB + +As part of this step, you will be using the official 10gen supplied +packages to install, configure and run MongoDB as a service using +YUM. You want to install as a service since this would ensure that +mongod is started on machine restart also. More information can be +found at Install MongoDB on RedHat Enterprise, CentOS, or Fedora Linux +doc page. + +Install MongoDB ++++++++++++++++ + +Repeat the following steps on each instance. + #. Log onto the instance + #. Create a /etc/yum.repos.d/10gen.repo file to hold information about your repository using your favorite editor as sudo. Place the following configuration in /etc/yum.repos.d/10gen.repo file: + + .. code-block:: shell + + [10gen] + name=10gen Repository + baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 + gpgcheck=0 + enabled=1 + + #. After saving the new .repo file, issue the following command to update the local package database: sudo yum update + #. Issue the following command (as root or with sudo) to install the latest stable version of MongoDB and the associated tools: + + .. code-block:: shell + + sudo yum install mongo-10gen mongo-10gen-server + + #. When this command completes, you have successfully installed MongoDB. + +Configure MongoDB +~~~~~~~~~~~~~~~~~ + +The packages installed in the previous step configure MongoDB using +the /etc/mongod.conf file in conjunction with the control script. You +can find the init script at /etc/rc.d/init.d/mongod. As part of this +step you will edit the mongod.conf file to set the appropriate +parameters. If the parameters are commented, make sure to uncomment +them. + +Instance 1 +++++++++++ + + #. Connect to the instance using ssh or PuTTY + #. As sudo, edit /etc/mongod.conf to set the following parameters: + + .. code-block:: + + port = 27018 + dbpath = /mnt/datadrive/data + logpath = /mnt/datadrive/mongod.log + replSet = mongors + + #. Save the config file + +Instance 2 +++++++++++ + + #. Connect to the instance using ssh or PuTTY + #. As sudo, edit /etc/mongod.conf to set the following parameter: + + .. code-block:: + + port = 27019 + dbpath = /mnt/datadrive/data + logpath = /mnt/datadrive/mongod.log + replSet = mongors + + #. Save the config file + +Instance 3 +++++++++++ + + #. Connect to the instance using ssh or PuTTY + #. As sudo, edit /etc/mongod.conf to set the following parameter: + + .. code-block:: + + port = 27020 + dbpath = /mnt/datadrive/data + logpath = /mnt/datadrive/mongod.log + replSet = mongors + + #. Save the config file + +Start MongoDB +~~~~~~~~~~~~~ + +Once the configuration files have been edited, start the database process mongod on each instance by: + #. Log on onto the instance + #. Run the following command to start the process: + + .. code-block:: shell + + mongod –config /etc/mongod.conf + + #. This should start the mongod process + #. Verify that mongod start by tailing the log file using the + command + + .. code-block:: shell + + tail –f /mnt/datadrive/mongod.log + + #. The ``waiting for connections`` message in the log file indicates + mongod is up and running and waiting for client + connections. This may take a while as mongod preallocates its + journal files + +Configure the replica set +~~~~~~~~~~~~~~~~~~~~~~~~~ + +At this point in time, you should have mongod running on all 3 of your +instances. You can now configure the 3 instances as a replica set by +connecting to 1 of the 3 instances from within Azure or from outside. +Connect to the running mongod process using the mongo shell: + + #. If connected to the VM instance type the following command where + port is 27018 for instance 1, 27019 for instance 2 and 27020 for + instance 3: + + .. code-block:: shell + + mongo –port + + #. If connecting to the mongod process in Azure from your local + machine use the following command: + + .. code-block:: shell + + mongo –host mongodbrs.cloudapp.net –port + + #. In the mongo shell type the following: + + .. code-block:: shell + + > conf = { + _id = “mongors”, + members : [ + {id:0, host:”mongodbrs.cloudapp.net:27018}, + {id:0, host:”mongodbrs.cloudapp.net:27019}, + {id:0, host:”mongodbrs.cloudapp.net:27020}]} + > rs.initiate(conf) + + #. This will start the initialization of the mongodb replica set + #. Type the command ``rs.status()`` to check the status of the + replica set. Upon successful initialization, you should see 1 of + the 3 instances being the `Primary` of the set and the other 2 + being the `Secondaries` + + #. You have now successfully initiated the replica set + +Summary +~~~~~~~ + +In this tutorial you have learned how to create a set of CentOS +virtual machines on Windows Azure, deploy MongoDB to them and create a +replica set out of them. You can access this set from anywhere using +the connection string ``mongodb://mongodbrs.cloudapp.net:27018, +mongodbrs.cloudapp.net:27019, +mongodbrs.cloudapp.net:27020/?replicaSet=mongors``. + +More information on MongoDB can be found at +http://docs.mongodb.org/manual/. + +To create and deploy a replica set to Windows Virtual Machines on +Azure you can use the MongoDB Installer for Windows Azure. From 57028b480f6fd69eb518a8bb21e0f1d487cd8641 Mon Sep 17 00:00:00 2001 From: Andrew Leung Date: Wed, 25 Jul 2012 14:22:31 -0400 Subject: [PATCH 3/4] updating for new file name --- .../deploy-mongodb-on-windows-azure.txt | 259 ------------------ 1 file changed, 259 deletions(-) delete mode 100644 draft/tutorial/deploy-mongodb-on-windows-azure.txt diff --git a/draft/tutorial/deploy-mongodb-on-windows-azure.txt b/draft/tutorial/deploy-mongodb-on-windows-azure.txt deleted file mode 100644 index fbb24eb2a12..00000000000 --- a/draft/tutorial/deploy-mongodb-on-windows-azure.txt +++ /dev/null @@ -1,259 +0,0 @@ - -============================================= -Deploy a MongoDB Replica Set on Windows Azure -============================================= - -In this tutorial, you will learn to deploy a MongoDB replica set to -CentOS VMs on Windows Azure and access it from outside Azure. The -following are the tasks to achieve this: Sign up for the feature on -the Azure portal Set up affinity group Create and set up the virtual -machines Install and run MongoDB Configure the replica set - -# Signing up - - Sign up for ‘Virtual Machines and Virtual Networks’ preview feature - from the new Azure portal* In the ‘Preview’ portal, go to - Account->Preview Features. - - Sign up for the “Virtual Machines and Virtual Networks” - - .. note:: - - “*” – The VM Role beta program from the old Azure portal (shown - below) is not the same as the preview feature above - -# Set up affinity group - - The affinity group needs to be set up from the old portal. - - # If in the new Azure Management preview portal, click ‘Preview’ at - the top of the screen and then ‘Take me to the previous portal’ - to switch to the old portal - - # Once in the old portal, click ‘Hosted Services, Storage Accounts - & CDN’ - - # Select ‘Affinity Groups’ and then ‘New Affinity Group’ - - # In the “Create a New Affinity Group” dialog, enter an affinity - group name such as “mongoaffinitygroup” and choose a location - - Choose one of the newer Azure data centers such as “West US”, - “East US” or “West Europe” - -# Create and set up the virtual machines - - To create a 3-node MongoDB replica set you will be creating 3 VM - instances. For this step, log in to the new preview portal, or from - the old portal, click ‘Visit the Previous Portal’ at the bottom of - the page - -Create instances - -Instance 1 - -In the portal, click New->Virtual Machine->From Gallery - -On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and click the next arrow to continue - -On the VM Configuration page, specify values for the parameters -Virtual Machine Name - "mongodbrs1" -New User Name – "mongouser". This user will be added to the ‘sudoers’ list file -New Password box – type a strong password that confirms to the Azure specifications -Retype the password to confirm -Size – Choose appropriate size from drop down list. For anything but small test instances, choose a size larger than Medium -Leave ‘Upload SSH key for Authentication’ unchecked -Click the next arrow to continue - -On the VM Mode page, specify values for the required parameters -Select ‘Standalone Virtual Machine’ -DNS – a valid DNS prefix e.g. "mongodbrs" -Storage Account box – choose ‘Use Automatically Generated Storage Account’ -In the ‘Region/Affinity Group/Virtual Network’ box, select the affinity group created previously “mongoaffinitygroup” -Click next arrow to continue - -On the VM Options page select ‘None for Availability Set’ - -Click the check mark to create the VM instance -Instance 2 - -A similar process to creating instance 1. -In the portal, click New->Virtual Machine->From Gallery -On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and then the next arrow to continue -On the VM Configuration page, specify values for the parameters -Virtual Machine Name – "mongodbrs2" -New User Name – "mongouser". This user will be added to the Sudoers list file. For ease of use specify the same user name as for instance 1 -New Password box – type a strong password that confirms to the Azure specifications -Retype the password to confirm -Size – Choose the same instance size as instance 1 -Leave ‘Upload SSH key for Authentication’ unchecked -Click the next arrow to continue -On the VM Mode page, specify values for the required parameters -Select ‘Connect to Existing Virtual Machine’ -In the dropdown choose instance 1 ‘mongodbrs1’ -Storage Account box – choose ‘Use Automatically Generated Storage Account’ -The ‘Region/Affinity Group/Virtual Network’ box should be automatically set to “mongoaffinitygroup” -Click the next arrow to continue - -On the VM Options page select ‘None for Availability Set’ -Click the check mark to create the VM instance -Instance 3 - -A similar process for creating instance 2. Choose ‘mongodbrs3’ to be the Virtual Machine Name in step 3. -Configure endpoints - -Once the virtual machines are connected you need to configure the endpoints to: -Allow remote connection -Allow mongo traffic -Instance 1: - -In the management portal, click virtual machines and click the name of instance 1, ‘mongodbrs1’ -Now click on endpoints -The ssh endpoint should be automatically created. For this endpoint ensure the following are set -Protocol – tcp -Public Port – 22 -Private Port – 22 -Load Balanced – No -Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen -Ensure ‘Add endpoint’ is selected and click the right arrow to go to the next screen - -Specify the endpoint details as below: -Name : MongoDB-Port -Protocol : TCP -Public Port : 27018 -Private Port : 27018 -Click on check mark to create endpoint - -The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB - -Instance 2: - -We need to configure the endpoints for instance 2 similar to instance 1: -In the management portal, click ‘virtual machines’ and click the name of instance 2 -Now click on ‘endpoints’ -The ssh endpoint should be automatically created. Ensure that: -Name – SSH -Protocol – TCP -Private Port – 22 -Load Balanced – No -Now click on Edit Endpoint at the bottom of the screen and set ‘Public Port’ to 23. Click on the ‘check mark’ to update -Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen -Ensure ‘Add Endpoint’ is selected and click the right arrow to go to the next screen -Specify the endpoint details as below: -Name : MongoDB-Port -Protocol : TCP -Public Port : 27019 -Private Port : 27019 -Click on check mark to create endpoint -The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB - -Instance 3: - -Create endpoints for instance 3 similar to instance 2 with the following changes: -In step 4, set public port to 24 -In step 7, set public and private ports to be 27020 -The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB - -Update OS - -Use this optional step to update the operating system on each of your VM instances. Once the machine endpoints have been configured above, you need to log into the machines to update them. More information on this can be found at ‘How to Log on to a Virtual Machine Running Linux’ -Use the username and password you used when creating the virtual machine instances. -Once you are connected to the machine, update the operating system by running: sudo yum update and following the prompts. This could take some time. -Note: When connecting to instances 2 and 3, remember to use ports 23 and 24 and not the default ssh port of 22. - -Set up disks - -Once the instances are updated, you can then attach a data disk to each of the instances. The data disks will be storing the actual mongodb data as part of –dbpath. More information on Azure data disks can be found at Data Disk Concepts. -To set up the data disk follow the steps outlined below for each of the instances you created: -Attach an empty disk to the instance as described in How to: Attach an empty disk -Create a data disk of at least 10 GB -Now initialize the data disk by following the steps described at How to: Initialize a new data disk in Linux -Ensure you use ext4 for the file system and not ext3 -Also once mounted, create a mongodb data directory by: -Log on onto the instance -Then run sudo chown `id -u` /mnt/datadrive/ to make the mongouser the owner of the data directory -Run the following command: mkdir -p /mnt/datadrive/data -4. Install and run MongoDB - -As part of this step, you will be using the official 10gen supplied packages to install, configure and run MongoDB as a service using YUM. You want to install as a service since this would ensure that mongod is started on machine restart also. More information can be found at Install MongoDB on RedHat Enterprise, CentOS, or Fedora Linux doc page. -Install MongoDB - -Repeat the following steps on each instance. -Log onto the instance -Create a /etc/yum.repos.d/10gen.repo file to hold information about your repository using your favorite editor as sudo. Place the following configuration in /etc/yum.repos.d/10gen.repo file: -[10gen] -name=10gen Repository -baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 -gpgcheck=0 -enabled=1 -After saving the new .repo file, issue the following command to update the local package database: sudo yum update -Issue the following command (as root or with sudo) to install the latest stable version of MongoDB and the associated tools: -sudo yum install mongo-10gen mongo-10gen-server - -When this command completes, you have successfully installed MongoDB. - -Configure MongoDB - -The packages installed in the previous step configure MongoDB using the /etc/mongod.conf file in conjunction with the control script. You can find the init script at /etc/rc.d/init.d/mongod. As part of this step you will edit the mongod.conf file to set the appropriate parameters. If the parameters are commented, make sure to uncomment them. -Instance 1 - -Connect to the instance using ssh or PuTTY -As sudo, edit /etc/mongod.conf to set the following parameters: -port = 27018 -dbpath = /mnt/datadrive/data -logpath = /mnt/datadrive/mongod.log -replSet = mongors -Save the config file -Instance 2 - -Connect to the instance using ssh or PuTTY -As sudo, edit /etc/mongod.conf to set the following parameter: -port = 27019 -dbpath = /mnt/datadrive/data -logpath = /mnt/datadrive/mongod.log -replSet = mongors -Save the config file -Instance 3 - -Connect to the instance using ssh or PuTTY -As sudo, edit /etc/mongod.conf to set the following parameter: -port = 27020 -dbpath = /mnt/datadrive/data -logpath = /mnt/datadrive/mongod.log -replSet = mongors -Save the config file -Start MongoDB - -Once the configuration files have been edited, start the database process mongod on each instance by: -Log on onto the instance -Run the following command to start the process: -mongod –config /etc/mongod.conf -This should start the mongod process -Verify that mongod start by tailing the log file using the command -tail –f /mnt/datadrive/mongod.log -The ‘waiting for connections’ message in the log file indicates mongod is up and running and waiting for client connections. This may take a while as mongod preallocates its journal files - -5. Configure the replica set - -At this point in time, you should have mongod running on all 3 of your instances. You can now configure the 3 instances as a replica set by connecting to 1 of the 3 instances from within Azure or from outside. -Connect to the running mongod process using the mongo shell: -If connected to the VM instance type the following command where port is 27018 for instance 1, 27019 for instance 2 and 27020 for instance 3: mongo –port -If connecting to the mongod process in Azure from your local machine use the following command: mongo –host mongodbrs.cloudapp.net –port -In the mongo shell type the following: -> conf = { -_id = “mongors”, -members : [ -{id:0, host:”mongodbrs.cloudapp.net:27018}, -{id:0, host:”mongodbrs.cloudapp.net:27019}, -{id:0, host:”mongodbrs.cloudapp.net:27020}]} ->rs.initiate(conf) - -This will start the initialization of the mongodb replica set -Type the command ‘rs.status()’ to check the status of the replica set. Upon successful initialization, you should see 1 of the 3 instances being the ‘Primary’ of the set and the other 2 being the ‘Secondaries’ - -You have now successfully initiated the replica set -Summary - -In this tutorial you have learned how to create a set of CentOS virtual machines on Windows Azure, deploy MongoDB to them and create a replica set out of them. You can access this set from anywhere using the connection string ‘mongodb://mongodbrs.cloudapp.net:27018, mongodbrs.cloudapp.net:27019, mongodbrs.cloudapp.net:27020/?replicaSet=mongors’. -More information on MongoDB can be found at http://docs.mongodb.org/manual/. -To create and deploy a replica set to Windows Virtual Machines on Azure you can use the MongoDB Installer for Windows Azure. From 6adc5bb577596714d585ad44b326f2098de81131 Mon Sep 17 00:00:00 2001 From: Andrew Leung Date: Wed, 25 Jul 2012 16:44:16 -0400 Subject: [PATCH 4/4] initial draft of document. --- ...loy-mongodb-to-centos-on-windows-azure.txt | 402 +++++++++++------- 1 file changed, 246 insertions(+), 156 deletions(-) diff --git a/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt b/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt index bd2c4aca0f7..b60f28cd30c 100644 --- a/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt +++ b/draft/tutorial/deploy-mongodb-to-centos-on-windows-azure.txt @@ -14,185 +14,224 @@ following are the tasks to achieve this: #. Install and run MongoDB #. Configure the replica set -#. Signing up +Signing up +========== - Sign up for ‘Virtual Machines and Virtual Networks’ preview feature - from the new Azure portal* In the ‘Preview’ portal, go to - Account->Preview Features. +Sign up for ``Virtual Machines and Virtual Networks`` preview feature +from the new Azure portal* In the ``Preview`` portal, go to +Account->Preview Features. - Sign up for the “Virtual Machines and Virtual Networks” +.. image:: img/image06.png - .. TODO make this a subscript +Sign up for the “Virtual Machines and Virtual Networks” - .. note:: +.. image:: img/image07.png - “*” – The VM Role beta program from the old Azure portal (shown - below) is not the same as the preview feature above +.. TODO make this a subscript + +.. note:: + + “*” – The VM Role beta program from the old Azure portal (shown + below) is not the same as the preview feature above + + .. image:: img/image08.png -#. Set up affinity group +Set up affinity group +===================== - The affinity group needs to be set up from the old portal. +The affinity group needs to be set up from the old portal. - #. If in the new Azure Management preview portal, click ‘Preview’ at - the top of the screen and then ‘Take me to the previous portal’ - to switch to the old portal +#. If in the new Azure Management preview portal, click ‘Preview’ at + the top of the screen and then ‘Take me to the previous portal’ to + switch to the old portal - #. Once in the old portal, click ‘Hosted Services, Storage Accounts - & CDN’ + .. image:: img/image10.png - #. Select ‘Affinity Groups’ and then ‘New Affinity Group’ +#. Once in the old portal, click ‘Hosted Services, Storage Accounts + & CDN’ - #. In the “Create a New Affinity Group” dialog, enter an affinity - group name such as “mongoaffinitygroup” and choose a location +#. Select ‘Affinity Groups’ and then ‘New Affinity Group’ - * Choose one of the newer Azure data centers such as “West US”, - “East US” or “West Europe” +#. In the “Create a New Affinity Group” dialog, enter an affinity + group name such as “mongoaffinitygroup” and choose a location -#. Create and set up the virtual machines + - Choose one of the newer Azure data centers such as “West US”, + “East US” or “West Europe” - To create a 3-node MongoDB replica set you will be creating 3 VM - instances. For this step, log in to the new preview portal, or from - the old portal, click `Visit the Previous Portal` at the bottom of - the page + .. image:: img/image11.png + +Create and set up the virtual machines +====================================== + +To create a 3-node MongoDB replica set you will be creating 3 VM +instances. For this step, log in to the new preview portal, or from +the old portal, click ``Visit the Previous Portal`` at the bottom of the +page Create instances -~~~~~~~~~~~~~~~~ +---------------- Instance 1 -++++++++++ +~~~~~~~~~~ + +#. In the portal, click New->Virtual Machine->From Gallery - #. In the portal, click New->Virtual Machine->From Gallery + .. image:: img/image01.png - #. On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and - click the next arrow to continue +#. On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and + click the next arrow to continue - #. On the VM Configuration page, specify values for the parameters + .. image:: img/image00.png - * Virtual Machine Name - ``mongodbrs1`` - * New User Name – ``mongouser``. This user will be added to the - ``sudoers`` list file - * New Password box – type a strong password that confirms to the - Azure specifications - * Retype the password to confirm - * Size – Choose appropriate size from drop down list. For - anything but small test instances, choose a size larger than - Medium - * Leave ``Upload SSH key for Authentication`` unchecked +#. On the VM Configuration page, specify values for the parameters - Click the next arrow to continue + - Virtual Machine Name - ``mongodbrs1`` + - New User Name – ``mongouser``. This user will be added to the + ``sudoers`` list file + - New Password box – type a strong password that confirms to the + Azure specifications + - Retype the password to confirm + - Size – Choose appropriate size from drop down list. For anything + but small test instances, choose a size larger than Medium + - Leave ``Upload SSH key for Authentication`` unchecked - #. On the VM Mode page, specify values for the required parameters + Click the next arrow to continue - * Select ‘Standalone Virtual Machine’ - * DNS – a valid DNS prefix e.g. "mongodbrs" - * Storage Account box – choose ‘Use Automatically Generated Storage Account’ - * In the ‘Region/Affinity Group/Virtual Network’ box, select the - affinity group created previously “mongoaffinitygroup” + .. image:: img/image03.png - Click next arrow to continue +#. On the VM Mode page, specify values for the required parameters - #. On the VM Options page select ``None for Availability Set`` + - Select ‘Standalone Virtual Machine’ + - DNS – a valid DNS prefix e.g. "mongodbrs" + - Storage Account box – choose ‘Use Automatically Generated Storage Account’ + - In the ‘Region/Affinity Group/Virtual Network’ box, select the + affinity group created previously “mongoaffinitygroup” - #. Click the check mark to create the VM instance + Click next arrow to continue + + .. image:: img/image02.png + +#. On the VM Options page select ``None for Availability Set`` + + .. image:: img/image04.png + +#. Click the check mark to create the VM instance Instance 2 -++++++++++ +~~~~~~~~~~ A similar process to creating instance 1. - #. In the portal, click New->Virtual Machine->From Gallery - #. On the VM OS Selection page, choose ‘OpenLogic CentOS 6.2’ and then the next arrow to continue - #. On the VM Configuration page, specify values for the parameters +#. In the portal, click New->Virtual Machine->From Gallery +#. On the VM OS Selection page, choose ``OpenLogic CentOS 6.2`` and then the next arrow to continue +#. On the VM Configuration page, specify values for the parameters + + - Virtual Machine Name – ``mongodbrs2`` + - New User Name – ``mongouser``. This user will be added to the + Sudoers list file. For ease of use specify the same user name + as for instance 1 + - New Password box – type a strong password that confirms to the Azure specifications + - Retype the password to confirm + - Size – Choose the same instance size as instance 1 + - Leave ``Upload SSH key for Authentication`` unchecked - * Virtual Machine Name – "mongodbrs2" - * New User Name – "mongouser". This user will be added to the Sudoers list file. For ease of use specify the same user name as for instance 1 - * New Password box – type a strong password that confirms to the Azure specifications - * Retype the password to confirm - * Size – Choose the same instance size as instance 1 - * Leave ‘Upload SSH key for Authentication’ unchecked + Click the next arrow to continue - Click the next arrow to continue +#. On the VM Mode page, specify values for the required parameters - #. On the VM Mode page, specify values for the required parameters + - Select ``Connect to Existing Virtual Machine`` + - In the dropdown choose instance 1 ``mongodbrs1`` + - Storage Account box – choose ``Use Automatically Generated Storage Account`` + - The ``Region/Affinity Group/Virtual Network`` box should be automatically set to ``mongoaffinitygroup`` - * Select ‘Connect to Existing Virtual Machine’ - * In the dropdown choose instance 1 ‘mongodbrs1’ - * Storage Account box – choose ‘Use Automatically Generated Storage Account’ - * The ‘Region/Affinity Group/Virtual Network’ box should be automatically set to “mongoaffinitygroup” + Click the next arrow to continue - Click the next arrow to continue + .. image:: img/image12.png - #. On the VM Options page select ‘None for Availability Set’ +#. On the VM Options page select ‘None for Availability Set’ - #. Click the check mark to create the VM instance +#. Click the check mark to create the VM instance Instance 3 -++++++++++ +~~~~~~~~~~ -A similar process for creating instance 2. Choose ‘mongodbrs3’ to be the Virtual Machine Name in step 3. +A similar process for creating instance 2. Choose ``mongodbrs3`` to be the Virtual Machine Name in step 3. Configure endpoints -~~~~~~~~~~~~~~~~~~~ +------------------- Once the virtual machines are connected you need to configure the endpoints to: -* Allow remote connection -* Allow mongo traffic + +- Allow remote connection +- Allow mongo traffic Instance 1 -++++++++++ +~~~~~~~~~~ -#. In the management portal, click virtual machines and click the name of instance 1, ‘mongodbrs1’ +#. In the management portal, click virtual machines and click the name of instance 1, ``mongodbrs1`` #. Now click on endpoints #. The ssh endpoint should be automatically created. For this endpoint ensure the following are set - * Protocol – tcp - * Public Port – 22 - * Private Port – 22 - * Load Balanced – No -#. Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen -#. Ensure ‘Add endpoint’ is selected and click the right arrow to go to the next screen + - Protocol – tcp + - Public Port – 22 + - Private Port – 22 + - Load Balanced – No + +#. Create a new endpoint for MongoDB by clicking on ``Add Endpoint`` at the bottom of the screen +#. Ensure ``Add endpoint`` is selected and click the right arrow to go to the next screen + + .. image:: img/image13.png #. Specify the endpoint details as below: - * Name : MongoDB-Port - * Protocol : TCP - * Public Port : 27018 - * Private Port : 27018 + - Name : MongoDB-Port + - Protocol : TCP + - Public Port : 27018 + - Private Port : 27018 Click on check mark to create endpoint + .. image:: img/image14.png + The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB +.. image:: img/image15.png + Instance 2 -++++++++++ +~~~~~~~~~~ We need to configure the endpoints for instance 2 similar to instance 1: -#. In the management portal, click ‘virtual machines’ and click the name of instance 2 -#. Now click on ‘endpoints’ +#. In the management portal, click ``virtual machines`` and click the name of instance 2 +#. Now click on ``endpoints`` #. The ssh endpoint should be automatically created. Ensure that: - * Name – SSH - * Protocol – TCP - * Private Port – 22 - * Load Balanced – No - -#. Now click on Edit Endpoint at the bottom of the screen and set ‘Public Port’ to 23. Click on the ‘check mark’ to update -#. Create a new endpoint for MongoDB by clicking on ‘Add Endpoint’ at the bottom of the screen -#. Ensure ‘Add Endpoint’ is selected and click the right arrow to go to the next screen + - Name – SSH + - Protocol – TCP + - Private Port – 22 + - Load Balanced – No + +#. Now click on Edit Endpoint at the bottom of the screen and set + ``Public Port`` to 23. Click on the ``check mark`` to update +#. Create a new endpoint for MongoDB by clicking on ``Add Endpoint`` + at the bottom of the screen +#. Ensure ``Add Endpoint`` is selected and click the right arrow to go + to the next screen #. Specify the endpoint details as below: - * Name: MongoDB-Port - * Protocol: TCP - * Public Port: 27019 - * Private Port: 27019 + - Name: MongoDB-Port + - Protocol: TCP + - Public Port: 27019 + - Private Port: 27019 Click on check mark to create endpoint The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB +.. image:: img/image18.png + Instance 3 -++++++++++ +~~~~~~~~~~ Create endpoints for instance 3 similar to instance 2 with the following changes: @@ -201,79 +240,121 @@ Create endpoints for instance 3 similar to instance 2 with the following changes The instance now should have 2 endpoints, 1 for SSH and 1 for MongoDB +.. image:: img/image19.png + Update OS -+++++++++ +~~~~~~~~~ Use this optional step to update the operating system on each of your VM instances. Once the machine endpoints have been configured above, you need to log into the machines to update them. More information on -this can be found at ‘How to Log on to a Virtual Machine Running -Linux’ Use the username and password you used when creating the -virtual machine instances. Once you are connected to the machine, -update the operating system by running: sudo yum update and following -the prompts. This could take some time. +this can be found at `How to Log on to a Virtual Machine Running Linux +`_ +Use the username and password you used when creating the virtual +machine instances. Once you are connected to the machine, update the +operating system by running: + +.. code-block:: sh + + sudo yum update + +and following the prompts. This could take some time. .. note:: When connecting to instances 2 and 3, remember to use ports 23 and 24 and not the default ssh port of 22. +.. image:: img/image20.png + Set up disks -++++++++++++ +~~~~~~~~~~~~ Once the instances are updated, you can then attach a data disk to each of the instances. The data disks will be storing the actual mongodb data as part of –dbpath. More information on Azure data disks -can be found at Data Disk Concepts. To set up the data disk follow -the steps outlined below for each of the instances you created: +can be found at `Data Disk Concepts +`_. +To set up the data disk follow the steps outlined below for each of +the instances you created: + + #. Attach an empty disk to the instance as described in How to: + `Attach an empty + disk `_ + + .. note:: + + Create a data disk of at least 10 GB - #. Attach an empty disk to the instance as described in How to: Attach - an empty disk - #. Create a data disk of at least 10 GB #. Now initialize the data disk by following the steps described at - How to: Initialize a new data disk in Linux Ensure you use ext4 for - the file system and not ext3 + `How to: Initialize a new data disk in Linux + `_ + + .. note:: + + Ensure you use ext4 for the file system and not ext3 + #. Also once mounted, create a mongodb data directory by: + #. Log on onto the instance - #. Then run sudo chown `id -u` /mnt/datadrive/ to make the - mongouser the owner of the data directory - #. Run the following command: mkdir -p /mnt/datadrive/data + #. Run the following code to make the mongouser the owner of the data directory + + .. code-block:: sh -#. Install and run MongoDB + sudo chown `id -u` /mnt/datadrive/ + + #. Run the following command: + + .. code-block:: sh + + mkdir -p /mnt/datadrive/data + +Install and run MongoDB +======================= As part of this step, you will be using the official 10gen supplied packages to install, configure and run MongoDB as a service using YUM. You want to install as a service since this would ensure that mongod is started on machine restart also. More information can be -found at Install MongoDB on RedHat Enterprise, CentOS, or Fedora Linux +found at `Install MongoDB on RedHat Enterprise, CentOS, or Fedora +Linux +`_ doc page. Install MongoDB -+++++++++++++++ +--------------- Repeat the following steps on each instance. #. Log onto the instance - #. Create a /etc/yum.repos.d/10gen.repo file to hold information about your repository using your favorite editor as sudo. Place the following configuration in /etc/yum.repos.d/10gen.repo file: + #. Create a ``/etc/yum.repos.d/10gen.repo`` file to hold information + about your repository using your favorite editor as sudo. Place + the following configuration in ``/etc/yum.repos.d/10gen.repo`` file: + + .. code-block:: sh - .. code-block:: shell + [10gen] + name=10gen Repository + baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 + gpgcheck=0 + enabled=1 - [10gen] - name=10gen Repository - baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 - gpgcheck=0 - enabled=1 + #. After saving the new .repo file, issue the following command to + update the local package database: sudo yum update + #. Issue the following command (as root or with sudo) to install + the latest stable version of MongoDB and the associated tools: - #. After saving the new .repo file, issue the following command to update the local package database: sudo yum update - #. Issue the following command (as root or with sudo) to install the latest stable version of MongoDB and the associated tools: + .. code-block:: sh - .. code-block:: shell + sudo yum install mongo-10gen mongo-10gen-server - sudo yum install mongo-10gen mongo-10gen-server + .. image:: img/image21.png #. When this command completes, you have successfully installed MongoDB. + .. image:: img/image16.png + Configure MongoDB -~~~~~~~~~~~~~~~~~ +----------------- The packages installed in the previous step configure MongoDB using the /etc/mongod.conf file in conjunction with the control script. You @@ -283,12 +364,12 @@ parameters. If the parameters are commented, make sure to uncomment them. Instance 1 -++++++++++ +~~~~~~~~~~ #. Connect to the instance using ssh or PuTTY #. As sudo, edit /etc/mongod.conf to set the following parameters: - .. code-block:: + .. code-block:: sh port = 27018 dbpath = /mnt/datadrive/data @@ -298,12 +379,12 @@ Instance 1 #. Save the config file Instance 2 -++++++++++ +~~~~~~~~~~ #. Connect to the instance using ssh or PuTTY #. As sudo, edit /etc/mongod.conf to set the following parameter: - .. code-block:: + .. code-block:: sh port = 27019 dbpath = /mnt/datadrive/data @@ -313,12 +394,12 @@ Instance 2 #. Save the config file Instance 3 -++++++++++ +~~~~~~~~~~ #. Connect to the instance using ssh or PuTTY #. As sudo, edit /etc/mongod.conf to set the following parameter: - .. code-block:: + .. code-block:: sh port = 27020 dbpath = /mnt/datadrive/data @@ -328,13 +409,15 @@ Instance 3 #. Save the config file Start MongoDB -~~~~~~~~~~~~~ +------------- + +Once the configuration files have been edited, start the database +process mongod on each instance by: -Once the configuration files have been edited, start the database process mongod on each instance by: #. Log on onto the instance #. Run the following command to start the process: - .. code-block:: shell + .. code-block:: sh mongod –config /etc/mongod.conf @@ -342,7 +425,7 @@ Once the configuration files have been edited, start the database process mongod #. Verify that mongod start by tailing the log file using the command - .. code-block:: shell + .. code-block:: sh tail –f /mnt/datadrive/mongod.log @@ -351,32 +434,34 @@ Once the configuration files have been edited, start the database process mongod connections. This may take a while as mongod preallocates its journal files + .. image:: img/image17.png + Configure the replica set -~~~~~~~~~~~~~~~~~~~~~~~~~ +========================= At this point in time, you should have mongod running on all 3 of your instances. You can now configure the 3 instances as a replica set by connecting to 1 of the 3 instances from within Azure or from outside. -Connect to the running mongod process using the mongo shell: +Connect to the running mongod process using the :program:`mongo` shell: #. If connected to the VM instance type the following command where port is 27018 for instance 1, 27019 for instance 2 and 27020 for instance 3: - .. code-block:: shell + .. code-block:: sh mongo –port #. If connecting to the mongod process in Azure from your local machine use the following command: - .. code-block:: shell + .. code-block:: sh mongo –host mongodbrs.cloudapp.net –port - #. In the mongo shell type the following: + #. In the :program:`mongo` shell type the following: - .. code-block:: shell + .. code-block:: sh > conf = { _id = “mongors”, @@ -386,16 +471,20 @@ Connect to the running mongod process using the mongo shell: {id:0, host:”mongodbrs.cloudapp.net:27020}]} > rs.initiate(conf) + .. image:: img/image09.png + #. This will start the initialization of the mongodb replica set #. Type the command ``rs.status()`` to check the status of the replica set. Upon successful initialization, you should see 1 of - the 3 instances being the `Primary` of the set and the other 2 - being the `Secondaries` + the 3 instances being the ``Primary`` of the set and the other 2 + being the ``Secondaries``. + + .. image:: img/image05.png #. You have now successfully initiated the replica set Summary -~~~~~~~ +======= In this tutorial you have learned how to create a set of CentOS virtual machines on Windows Azure, deploy MongoDB to them and create a @@ -408,4 +497,5 @@ More information on MongoDB can be found at http://docs.mongodb.org/manual/. To create and deploy a replica set to Windows Virtual Machines on -Azure you can use the MongoDB Installer for Windows Azure. +Azure you can use the `MongoDB Installer for Windows Azure +`_.