This is the fourth post of a walkthrough to set up a mixed-mode platform- and infrastructure-as-a-service application on Windows Azure using Couchbase and ASP.NET. For more context on the application, please review this introductory post.
For those of you who have been following my series of articles about setting up Couchbase on Windows Azure, I’m now at the most ���Couchbase-specific’ portion of the process. So far, I’ve set up a virtual network and created a cluster of of three virtual machine instances that have been prepped to support Couchbase, and the next step is to install the software on those VMs. If you’re not working with Couchbase specifically, this post is ok to skip!
Recall from a previous post that when creating the Couchbase20-rel4 image for the Virtual Machine Gallery, I had downloaded and saved the Couchbase installation file to the C:\ drive. I specifically did not run in on the base virtual machine image because Couchbase’s installer records the IP address of the current machine as part of the setup process. Executing it on the base virtual machine image would have created an installation that would not work when individual images (with completely different addresses) were created from it. That could be remedied via some Couchbase reconfiguration scripts, but in this particular case, it was just easier to run the installer three times, once on each virtual machine.
Running the setup spawns a familiar sequence of setup screens. The release I installed prompts for an installation directory (which I left at the default), and the rest of the process simply involves clicking through the the various informational screens until the installation has completed.
After clicking Finish on the final dialog, the Couchbase web administration console appears.
Via a few clicks on the web administration console, you can set up the server or add a server to an existing cluster; however, since this VM image is locked down, I’d need to turn off IE’s Enhanced Security Configuration (ESC) to use the browser-based interface to install the product. And I’d need to do that on each of the three virtual machines in the cluster.
As an alternative, I can use the Couchbase command-line interface, with the added bonus that a script can be run once on a single VM yet configure the entire cluster.
To initialize the cluster, I created a PowerShell script on my local machine and just cut-and-pasted that script into a new Notepad file on one of the VMs.
# replace with the IP addresses of the VMS
# after Couchbase has been installed on each VM
# set desired cluster user id and password
# set path to couchbase-cli
$env:path = $env:path + ";C:\program files\Couchbase\Server\bin\"
# create the cluster with RAM size 512MB
couchbase-cli cluster-init -c $server1 `
# create the bucket 'beernique' with size 256MB
couchbase-cli bucket-create -c $server1 `
-u $uid `
# add second server to cluster
couchbase-cli server-add -c $server1 `
-u $uid `
# add final server to cluster (and rebalance)
couchbase-cli rebalance -c $server1 `
-u $uid `
The script includes a few items (shaded above) that needed to be initialized for my specific environment:
The remainder of the script, which doesn't require modification, creates the cluster and initializes a Couchbase bucket to store the data associated with the sample TapMap application. couchbase-cli has a number of subcommands that can be exercised to initialize the Couchbase cluster, each requiring the Couchbase cluster credentials:
I can run the script in any of the three Couchbase VMs, since they are on the same subnet and have visibility to each other via their internal IP addresses. PowerShell is already part of the server VM image, so I simply save the script in a file on the VM and use the PowerShell console to execute it. Note that to do so, I need to set the execution policy to unrestricted, since my temporary script was not signed. After running the script, I do reset the execution policy to the more stringent value of restricted.
And that’s it! When the script completes, the cluster is set up, and I can view its configuration from any machine in that cluster via the URL http://localhost:8091.
There’s no data in Couchbase yet, but I’ll get to that next as I discuss how to install the TapMap application and trigger populating the database with beer and brewery data.