Install Couchbase on Windows Azure
Install Couchbase on Windows Azure
Join the DZone community and get the full member experience.Join For Free
Learn how to migrate and modernize stateless applications and run them in a Kubernetes cluster.
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!
Installing Couchbase on the VM Instance
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.
Configuring the 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 $server1='192.168.0.36:8091' $server2='192.168.0.37:8091' $server3='192.168.0.38:8091' # set desired cluster user id and password $uid="Administrator" $pwd="TapMap" # 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 ` --cluster-init-username=$uid ` --cluster-init-password=$pwd ` --cluster-init-ramsize=512 # create the bucket 'beernique' with size 256MB couchbase-cli bucket-create -c $server1 ` --bucket=beernique ` --bucket-password=b33rs ` --bucket-type=couchbase ` --bucket-port=11211 ` --bucket-ramsize=256 ` --bucket-replica=2 ` -u $uid ` -p $pwd # add second server to cluster couchbase-cli server-add -c $server1 ` --server-add=$server2 ` -u $uid ` -p $pwd # add final server to cluster (and rebalance) couchbase-cli rebalance -c $server1 ` --server-add=$server3 ` -u $uid ` -p $pwd
The script includes a few items (shaded above) that needed to be initialized for my specific environment:
- $server1, $server2, and $server3 are set to the subnet IPs of each of the VMs in my Couchbase cluster
- $uid is the user id for the Couchbase cluster that will be created
- $pwd is the password associated with $uid
- $env:path includes the location of the couchbase-cli utility, which was installed when running the Couchbase installer on each VM.
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:
- cluster-init sets up the cluster using the address of $server1 that is provided at the top of the script and gives each member of the cluster a RAM configuration of 512MB.
- bucket-create creates a new Couchbase bucket called beernique with a password of b33rs. The bucket will occupy up to half of the Couchbase server RAM allocation on each machine. Additionally, data in the bucket will be replicated to two other servers in the cluster for high availability.
- server-add adds another server to the cluster that was just created.
- rebalance does the same thing as server-add but also rebalances the cluster, so it’s called to add just the final server into the cluster.
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.
Published at DZone with permission of Jim O' Neil , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.