Running a single node Couchbase server using docker

Couchbase Server, earlier known as Membase, is an open source, distributed NoSQL document-oriented database with shared-nothing architecture. It exposes a fast easy-to-scale key-value store with a managed cache for sub-millisecond data operations, purpose-built indexers for fast queries and a query engine for executing SQL-like queries.

In the parlance of Eric Brewer’s CAP theorem, Couchbase is a CP type system meaning it provides consistency and partition tolerance. However Couchbase Server can be set up as an AP system with multiple clusters using XDCR (Cross Data Center Replication).

Couchbase Server is specialized to provide low-latency data management for large-scale interactive web, mobile, and IoT applications. Common requirements that Couchbase Server was designed to satisfy include:

  • Flexible data model
  • Powerful query language
  • Scalability
  • Performance
  • Simple administration
  • High Availability
Couchbase Server Connectivity Architecture
Couchbase Server Connectivity Architecture

Step 1:
Ensure docker daemon is running. Otherwise, you’ll get an error: Cannot connect to the Docker daemon. Is the docker daemon running on this host? Here, it’s seen that the ‘default’ docker-machine is running.

Step 2: If the docker-machine isn’t running, you need to start it and configure the shell. Here’s how you can do it:

Step 3: Pull the latest couchbase server tag from docker hub

Step 4: Run the couchbase server’s docker image as a container

Step 5: To ensure couchbase server started up fine, use the following commands:

Step 6: Skip this step if you already know the docker host address or name. Else,

Step 7: Open in browser. You should see Couchbase server setup file. Click on ‘Setup’.

Step 8: You should see a page to configure server. Select ‘Start a New Cluster’. You may want to enable/disable different services available: Data, Index, Query and Full Text. Full Text is on a developer preview as of writing this. You may also want adjust the RAM depending on RAM available to docker container. You may accept the default selection of ‘Standard Global Secondary Indexes’ for Index Storage Setting.

Couchbase full text search is the integration of Bleve with Couchbase Server. It allows creating a fulltext index based on the contents of the JSON documents stored in Couchbase. A normal index is a list of documents and the words they contain (technically, terms are stored, not words, but we’re among friends here). A fulltext index is a type of inverted index: it tells you, for a given word, a list of all the the documents where that word appears.

Step 9: Click on ‘Next’. You will see some sample buckets with data to help explore the power of couchbase server. Select ‘beer-sample’ and ‘travel-sample’ and click on ‘Next’.

Step 10: You will see a page to create default bucket with options for Bucket Settings (Type: Couchbase, Memcached), Node Memory Size, Replicas, Disk I/O Optimization and Flush. You may Skip or click on Next to move to next page.

Two types of data buckets, memcached and Couchbase, enable you to store data either in-memory only or both in-memory and on disk (for added reliability).

Couchbase provides highly-available and dynamically reconfigurable distributed data storage, with persistence and replication services. Couchbase buckets are 100% protocol compatible with, and built in the spirit of, the memcached open source distributed key-value cache.

Memcached provides a directly-addressed, distributed (scale-out), in-memory, key-value cache. Memcached buckets are designed to be used alongside relational database technology. They cache frequently-used data, thereby reducing the number of queries a database server must perform for web servers delivering a web application.

Step 11: You may want to disable any notifications, agree to the terms and click on ‘Next’.

Step 12: You need to enter the password for Administrator account and finish. You should see a page like below:

Step 13: Go to ‘Query’ tab and execute this N1QL query:

You should see the results in JSON format:

N1QL is a declarative query language that extends SQL for JSON. You can query data via native framework and language integration, a fluent API, or the JDBC/ODBC drivers. N1QL enables querying JSON documents without any limitations – sort, filter, transform, group, and combine data with a single query. You can combine data from multiple documents with a JOIN.


Copy Protected by Chetan's WP-Copyprotect.