Creating a new cluster

Clusters are created by setting up a cluster with an initial Couchbase Server node.

Syntax

Curl example syntax:

// Initialize Node
curl -u Administrator:password -v -X POST http://[localhost]:8091/nodes/self/controller/settings
  -d path=[location]
  -d index_path=[location]
  -d cbas_path=[location]

// Rename Node
curl -u Administrator:password -v -X POST http://[localhost]:8091/node/controller/rename
  -d hostname=[localhost]

// Setup Services
curl -u Administrator:password -v -X POST http://[localhost]:8091/node/controller/setupServices
  -d services=[data | index | n1ql | fts]

// Setup Administrator username and password
curl -u Administrator:password -v -X POST http://[localhost]:8091/settings/web
  -d password=[password]
  -d username=[admin-name]
  -d port=8091

// Setup Bucket
curl -u Administrator:password -v -X POST http://[localhost]:8091/pools/default/buckets
  -d flushEnabled=[1 | 0]
  -d replicaNumber=[0 - n]
  -d evictionPolicy=[valueOnly | full]
  -d ramQuotaMB=[value]
  -d bucketType=[membase | couchbase]
  -d name=[bucket-name]

Description

Whether adding a node to an existing cluster or starting a new cluster, the node’s disk path must be configured. The next steps depends on whether a new cluster is created or a node is added to an existing cluster. When creating a new cluster, secure it by providing an administrative username and password. When adding a node to an existing cluster, obtain the URI and credentials to use the REST API with that cluster.

The following is the procedure for creating a new cluster:

  1. Initialize the node

  2. Rename the node

  3. Set up the Couchbase Server services

  4. Establish the administrator name and password

  5. Setup bucket parameters

HTTP method and URI

The following HTTP method and URI endpoints are used for this provisioning procedure:

POST /nodes/self/controller/settings
POST /node/controller/rename
POST /node/controller/setupServices
POST /settings/web
POST /pools/default/buckets

Examples

Curl examples:

// Initialize Node
curl  -u Administrator:password -v -X POST http://192.168.42.101:8091/nodes/self/controller/settings \
  -d 'path=%2Fopt%2Fcouchbase%2Fvar%2Flib%2Fcouchbase%2Fdata& \
  index_path=%2Fopt%2Fcouchbase%2Fvar%2Flib%2Fcouchbase%2Fdata& \
  cbas_path=%2Fmnt%2Fd1&cbas_path=%2Fmnt%2Fd2&cbas_path=%2Fmnt%2Fd3'

// Rename Node
curl  -u Administrator:password -v -X POST http://192.168.42.101:8091/node/controller/rename \
  -d 'hostname=127.0.0.1'

// Setup Services
curl  -u Administrator:password -v -X POST http://192.168.42.101:8091/node/controller/setupServices \
  -d 'services=kv%2Cn1ql%2Cindex%2Cfts'

// Setup Administrator username and password
curl  -u Administrator:password -v -X POST http://192.168.42.101:8091/settings/web \
  -d 'password=password&username=Administrator&port=SAME'

// Setup Bucket
curl  -u Administrator:password -v -X POST http://192.168.42.101:8091/pools/default/buckets \
  -d 'flushEnabled=1&threadsNumber=3&replicaIndex=0&replicaNumber=0& \
  evictionPolicy=valueOnly&ramQuotaMB=597&bucketType=membase&name=default'

Note: Service name for query service is different in REST APIs and CLI. REST API uses "n1ql" as the service name while CLI uses "query" in the services settings.