Blog Post

Step by Step: Deploying Couchbase on Windows Azure Virtual Machines

Cihan Biyikoglu of Couchbase Published

Greetings Everyone, 

I am a new recruit but a long time fan of Couchbase. First a quick intro: name is Cihan Biyikoglu and I am product management at Couchbase. Couchbase is my 4th database platform in my career. In previous lives, I worked on SQL Azure & SQL Server, Informix and Illustra before Couchbase. For the last decade, I spent a whole lot of time crafting SaaS, PaaS and IaaS solutions and platforms. Fittingly, I wanted to kick off the first post focusing on getting Couchbase deployed on Windows Azure virtual machines. It is a step by step guide to get your environment running on Azure. Enjoy...

Here are the steps to getting your Couchbase cluster going on Windows Azure: 

  1. Create a VM: I’ll use Windows Server for the example. 
  2. Install Couchbase Server: Open the browser on the VM, download Couchbase Server and install it on the VM. 
    1. To allow communication to the node, open these ports on Windows firewall on your node.
  3. Configure Couchbase: Double-click on the Couchbase icon on your desktop and configure Couchbase (use default options) 

You are done! You have a single node deployment and that is all you need to play with Couchbase Server...

Production Configuration with Couchbase Server on Windows Azure

If you are a little more serious with Couchbase and like to get a production deployment out, read on...For a production deployment you need to do a bit more: Create a Couchbase cluster with more nodes for higher availability and higher throughput. For mission critical apps it is also key to be resilient to regional failures or data center failures, or simply provide lower latencies to users spread around the world. Thus many customers, in production, set up a second Couchbase cluster that is replicating data with Cross DataCenter Replication (XDCR) to get higher availability and/or disaster recovery and/or lower latency for your users in different geographies. 

Lets take a look at how to set up a production grade environment with Couchbase Server on Windows Azure:

  1. Set up Virtual Network: the main function of this is to use private IPs for Couchbase intra cluster communication. Details below as to why this is beneficial.
  2. Capture a VM image: This help avoid having to do 'step 2' above over and over again for each node. 
  3. Create nodes using the VM image
  4. Configure Couchbase cluster
  5. Optionally, Configure XDCR and get geographic distribution, availability and disaster recovery for your production deployment.

Lets get to the details.

#1 Set up Virtual Network: 

There really isn’t anything specific to Couchbase here. Virtual networks give you private IPs you can control and it does give you a shorter path to communicate between Couchbase nodes. You can use public IP addresses to communicate among nodes, but that means your communication has to travel to the edge of the Azure data center. 

  1. Provide a name for your virtual network : CB_VN_WESTUS, Specify a new affinity group name: CBWESTUS
  2. Skip providing DNS Server or Point To Site configuration option
  3. Specify the following Subnet Settings

#2 Capture a VM Image:

Capturing VM Images is a simple shortcut to stamp every node for your Couchbase Server cluster with the Couchbase binaries and firewall configuration. To do this, 

  1. Create a VM on Windows Azure – I’ll use Windows Server for the example here.
    1. Choose Windows Server – just latest greatest
    2. Name your virtual machine: couchbase01. Specify a VM size and admin username and password. 
  2. Open the browser on the VM, download Couchbase Server and install it on the VM (Turn off “IE Enhanced Security Configuration” to prevent warning popups)
  3. To allow communication to the node, open these ports on Windows firewall on your node.
  4. Configure private IP name resolution – this step ensures nodes communicate with each other over the private IPs for network efficiency. Neil (@mknz) tells me there is finally a way to assign statics private IPs in Azure. One way to do this is to create a hosts file with node names and private IPs of all nodes. If you don't do that, it gets a little tricky: You do need to follow a node naming scheme and make sure you create your VMs strictly in order to guarantee node names matches the private IPs assigned to each node. Remember that the private IPs will start from 10.0.0.4 for your first node, 10.0.0.5 for the second node and so on… So the "%windir%/system32/drivers/etc/hosts" file will have the following entries:
10.0.0.4     couchbase01.cloudapp.net
10.0.0.5     couchbase02.cloudapp.net
10.0.0.6     couchbase03.cloudapp.net

  1. Get the image ready for capture: at the command-line run "%windir%\system32\sysprep\sysprep.exe /shutdown /oobe /generalize"
  2. Once the VM shuts down, use the Windows Azure Management Portal to Capture the image. (right next to delete at the bottom pane of the portal)

#3 Create nodes using the VM Image:

We’ll use the VM Image you created to create the nodes you will use for your couchbase deployment.

  1. Create a VM from the Image - 
    1. Name your virtual machine: couchbase01. Specify a VM size and admin username and password. 
    2. Choose Virtual Network: CB_VN_WESTUS
  2. Repeat step 1 to create more nodes.

#5 Mount new disks to get storage capacity.

OS drives come with 30GB capacity and you'll be stuck soon out of storage capacity if you don't mount additional drives. Various VM sizes allow for various number of drives to be mounted. You can also configure multiple drives into a RAID configuration easly. Here are the steps to get there.

#5 Configure Couchbase Cluster

With this step, we’ll initialize the cluster and tie the nodes together. 

  1. Double-click on the Couchbase icon on your desktop and configure Couchbase Server
    1. Remember to use fully qualified hostnames here as well –nodename.cloudapp.net
    2. Remember also to use the mounted drives from step #4 with more storage capacity when choosing the storage location for data and index storage with Couchbase.
  2. Click on "Servers Nodes" on the Couchbase Web Console and click “Add Server” to add the remaining nodes (use fully qualified hostnames here as well –nodename.cloudapp.net) 
  3. When you are done adding node, click “Rebalance” to complete node configuration.

At this point you are ready to create your bucket and start pumping your workload to it.

#5 Create XDCR:

For mission critical apps it is key to be resilient to regional failures or data center failures or simply provide lower latencies to users spread around the world. Thus many customers set up a second Couchbase cluster that is replicating data with Cross DataCenter Replication (XDCR) to get higher availability and/or disaster recovery and/or lower latency for your users in different geographies. XDCR support a whole bunch of topologies for flexible replication schemes and you can learn all about XDCR here. For setting up a simple uni-directional topology, here is what you need to do;

  1. Set up a second cluster: simply pick another region in Azure and repeat steps 1-4 to create another cluster in the region. 
  2. Create your bucket on the second cluster and on your primary cluster configure XDCR using the fully qualified node name for referencing the remote cluster.

Security Note: It is also important to secure the endpoints and Azure provides help here. You can use these with Couchbase Server as well to limit communication from your app to Couchbase or between Couchbase clusters with XDCR.

Ok, This was a quick around-the-block tour of how to set up Couchbase on Windows Azure. Looking forward to all the feedback. 

-cihan biyikoglu