DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Deploying Couchbase with Chef
Content provided by Couchbase logo

Deploying Couchbase with Chef

Don Pinto user avatar by
Don Pinto
·
Jul. 23, 13 · Interview
Like (0)
Save
Tweet
Share
5.87K Views

This article by Keta Kiganal appears via Don Pinto.

If you are an administrator looking for an automated way to deploy Couchbase at scale, look no further - Chef is a great platform solution. Once setup, it is a very clean solution that can work across any number of physical, virtual, or cloud servers, no matter what the size of the infrastructure. Chef enables you to script your infrastructure deployment using code so that you can automate your provisioning and deployment process without much effort. 

In this blog, we will go over the chef recipes used to install couchbase, setup a cluster of couchbase nodes, add some buckets and finally add xdcr replication between clusters.

Before you start - Make sure you are familiar with the basics of chef server, cookbooks and chef-clients. Chef has a huge stack of templates, recipes, knife plugins which can be very useful to maintain large scale setups. http://wiki.opscode.com has good examples and information on this.

Setup a chef-server, workstation and have some nodes added on as chef-clients. Once the above 3 are setup, you are ready to write your Couchbase Cookbook. A forked version of the opscode cookbook is here https://github.com/ketakigangal/couchbase

Pre-requisites 
Install the following cookbooks before downloading the couchbase cookbook - yum, apt-get, windows, build-essential

Get the Couchbase cookbook
git clone  https://github.com/ketakigangal/couchbase

A quick look into the cookbook resources and available customizations
Based on your system needs, you can add more flexible attributes, resources, templates for the nodes and clusters. Ideally use the data-bags to define your cluster naming, here I have used role to describe very simple implementation of two clusters - “west_cluster” and “east_cluster”, more details ahead.

Attributes
The server.rb and client.rb have the default settings for server and clients. Make sure to reflect the needful couchbase versions, username/password for the server.rb in attributes. For example, the following installs a server 2.0.1-community edition -

default['couchbase']['server']['edition'] = "community"

default['couchbase']['server']['version'] = "2.0.1"

default['couchbase']['server']['username'] = "Administrator"

default['couchbase']['server']['password'] = "password"

Recipes

The server.rb and client.rb contain the logic for installing and setting up the Couchbase-Server and Clients respectively. Additionally the test_buckets.rb has sample code to create buckets and play around with the bucket settings.

The setup_cluster.rb can be used to setup a cluster, note this requires a role “west_cluster” ( say) to be assigned to each of the nodes of the cluster. Prerequisite to running this is to make sure each of the nodes have a couchbase server installed and started.

Similarly setup_xdcr.rb recipe is used to setup xdcr between two clusters. Prerequisite to using this is you already have 2 couchbase clusters setup  with roles “east_cluster” and “west_cluster”.

* Note : For this script to run, you must have nodes assigned with roles “east_cluster”, “west_cluster” for two separate clusters.

Libraries

The resources and providers are defined at a node, cluster, bucket level in this directory.

Upload the Cookbook using -

knife cookbook upload couchbase

Add recipes and roles to the node run_list using -

knife node run_list add fqdn-your-node-name "recipe[couchbase::server]"

knife node run_list add fqdn-your-node-name "recipe[couchbase::setup_cluster]"

knife node run_list add fqdn-your-node-name "recipe[couchbase::test_buckets]"

knife node run_list add role fqdn-your-node-name 'role[west_cluster]'

The above will add server, setup_cluster, test_bucket recipes for execution ( in that order) on the chef-client node. Here, we've assigned a role “west_cluster” to nodes to form a west_cluster.

knife show node fqdn-your-node-name

   “recipe[couchbase::server]",    

 "recipe[couchbase::setup_cluster]",

 "recipe[couchbase::test_buckets]",

 "role[west_cluster]"

Once you have uploaded the cookbook to the chef-server, you can use the chef-client to execute the cookbook/recipes.

Chef-Client

From the chef-client,

   sudo chef-client ( you can used -l debug for debug level log information).  

As output, you will see a similar message like below - 

* couchbase_bucket[modified % modification] action create[2013-07-08T22:57:49-07:00] INFO: Processing couchbase_bucket[modified % modification] action create (couchbase::test_buckets line 77)

[2013-07-08T22:57:49-07:00] INFO: couchbase_bucket[modified % modification] memory_quota_mb changed to 500

[2013-07-08T22:57:49-07:00] INFO: Chef Run complete in 187.264660646 seconds

[2013-07-08T22:57:49-07:00] INFO: Running report handlers

[2013-07-08T22:57:49-07:00] INFO: Report handlers complete

And you are ready to go! 

Steps for running recipe “setup_xdcr.rb”

knife role list

east_cluster

west_cluster

knife node edit fqdn-your-node-name

 "recipe[couchbase::setup_cluster]",

 "recipe[couchbase::test_buckets]",

 "role[east_cluster]"

likewise for the west_cluster.

knife search node "role:west_cluster" -i

2 items found

node1-fqdn

node2-fqdn

Setup xdcr by adding the “setup_xdcr” recipe to the source cluster, say “east_cluster”

knife node edit fqdn-your-node-name

 "recipe[couchbase::setup_xdcr]",

  "role[east_cluster]"

This will create a xdcr remote cluster reference and start the replication  from the “east_cluster” to the “west_cluster”

For large scale clusters, use of data-bags is ideal to define and maintain clusters. Likewise maintaining templates for cluster operations, resource creation will be useful in the initial setup. Enjoy!


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: