Installing Couchbase

Database setup and bucket configuration for the original platform.

These examples document the original platform. Use your own deployment; this website does not provide the former hosted API or account service.

Couchbase

Installing CouchBase

$> mkdir couchbase
$> dpkg-deb -x couchbase-server-enterprise_2.2.0_x86_64_openssl098.deb couchbase
$> cd couchbase/opt/couchbase
$COUCHBASE> ./bin/install/reloc.sh `pwd`

  • run

$COUCHBASE> bin/couchbase-server — -noinput -detached

  • stop

$COUCHBASE> bin/couchbase-server -k

Basic setup

  • set data location

$COUCHBASE> bin/couchbase-cli node-init -c localhost –node-init-data-path=/tmp

  • init server

$COUCHBASE> bin/couchbase-cli cluster-init -c localhost –cluster-init-username=admin –cluster-init-password=password –cluster-init-ramsize=600

Preparing CouchBase for use with servIoTicy

  • create buckets (optional –bucket-port=11222)

$COUCHBASE> bin/couchbase-cli bucket-create -c localhost –bucket=serviobjects –bucket-type=couchbase –bucket-ramsize=200 –bucket-replica=1 –user=admin –password=password
$COUCHBASE> bin/couchbase-cli bucket-create -c localhost –bucket=privatebucket –bucket-type=couchbase –bucket-ramsize=200 –bucket-replica=1 –user=admin –password=password

  • create design document “byUser.ddoc” (content)

{“views”:{“byUser”:{“map”:”function (doc, meta) {\n emit(doc.userId, meta.id);\n } “}}}

  • create byUser view

curl -X PUT -H ‘Content-Type: application/json’ http://admin:password@localhost:8092/serviobjects/_design/user’ -d @byUser.ddoc

Resizing CouchBase cluster

  • Expand cluster (add node) with data rebalancing

couchbase-cli rebalance -c localhost –server-add=<NEW SERVER>:8091 –user=admin –password=password

  • Expand cluster (add node) without data rebalancing

couchbase-cli server-add -c localhost –server-add=<NEW SERVER>:8091 –user=admin –password=password

  • Shrink cluster (remove node) with data rebalancing

couchbase-cli rebalance -c localhost –server-remove=<SERVER TO REMOVE>:8091 –user=admin –password=password

Installation and configuration script
# root directory
mkdir -p couchbase
rm -rf /tmp/couchbase-data
mkdir -p /tmp/couchbase-data

# download CouchBase (2.2.0+ required) (This case is using couchbase for 64-bit Ubuntu 10.04)
wget http://packages.couchbase.com/releases/2.2.0/couchbase-server-enterprise_2.2.0_x86_64_openssl098.deb
dpkg-deb -x couchbase-server-enterprise_2.2.0_x86_64_openssl098.deb couchbase

# Couchbase folder
cd couchbase/opt/couchbase

# For non-root isntallation
bin/install/reloc.sh `pwd`

# Start server
bin/couchbase-server -- -noinput -detached

# Stop server
# bin/couchbase-server -k

# Instance initialization
bin/couchbase-cli node-init -c localhost --node-init-data-path=/tmp/couchbase-data
bin/couchbase-cli cluster-init -c localhost --cluster-init-username=admin --cluster-init-password=password –cluster-init-ramsize=600

#create buckets
bin/couchbase-cli bucket-create -c localhost --bucket=serviceobjects --bucket-type=couchbase --bucket-ramsize=200 --bucket-replica=1 --user=admin --password=password
bin/couchbase-cli bucket-create -c localhost --bucket=privatebucket --bucket-type=couchbase --bucket-ramsize=200 --bucket-replica=1 --user=admin --password=password

#create views for service objects
curl -X PUT -H "Content-Type: application/json" http://admin:password@localhost:8092/serviobjects/_design/user -d @byUser.ddoc
byUser.ddoc
{“views”:{“byUser”:{“map”:”function (doc, meta) {\n emit(doc.userId, meta.id);\n } “}}}