The easiest way to run Couchbase cluster on Google Compute Engine is to run all of the nodes in Docker containers.
Create GCE instance and ssh in
Follow the instructions on Running Docker on Google Compute Engine.
At this point you should be ssh’d into your GCE instance
Increase max number of files limit
If you try to run Couchbase Server at this point, you will get this warning because the file ulimit is too low.
Here’s how to fix it:
- Edit
/etc/default/docker
- Add a new line in the file with:
1
|
|
- Restart the GCE instance in the GCE web admin by going to Compute Engine / VM Instances /
and hitting the “Reboot” button.
Note: in theory it should be possible to just restart docker via sudo service docker restart
, however this didn’t work for me when I tried it, so I ended up restarting the whole GCE instance
Start Couchbase Server
1
|
|
Verify it’s running
Find the Docker instance IP address
On the GCE instance, run:
1
|
|
This should return an ip address, eg 172.17.0.2
Set it as an environment variable so we can use it in later steps:
1
|
|
Run couchbase-cli
To verify that couchbase server is running, use the couchbase-cli
to ask for server info:
1
|
|
If everything is working correctly, this should return a json response, eg:
1 2 3 4 5 6 7 |
|
Start a 3-node cluster
On the GCE instance, run the following commands:
1 2 |
|
The nodes cb2
and cb3
will automatically join the cluster via cb1
. The cluster needs a rebalance to be fully operational. To do so, run the following command:
1
|
|
Connect to admin web UI
The easiest way to manage a Couchbase Server cluster is via the built-in Web Admin UI.
In order to access it, we will need to make some network changes.
Expose port 8091 via firewall rule for your machine
Go to whatismyip.com or equivalent, and find your ip address. Eg, 67.161.66.7
On your workstation with the gcloud
tool installed, run:
1
|
|
This will allow your machine, as well any other machine behind your internet router, to connect to the Couchbase Web UI running on GCE.
To increase security, you should use ipv6 and pass your workstation’s ipv6 hostname in the --source-ranges
parameter.
Find out external ip address of instance
On your workstation with the gcloud
tool installed, run:
1 2 3 |
|
Your external ip is listed under the externalIP column, eg 142.222.178.49
in this example.
Go to admin in web browser
Go to http://142.222.178.49:8091 into your web browser (replacing w/ your external ip)
You should see a screen like this:
Login with the default credentials:
- Username: Administrator
- Password: couchbase
And you should see the Web Admin dashboard:
Increase default bucket size
The default bucket size is set to a very low number by default (128M in my case). To increase this:
- In Web Admin UI, go to Data Buckets / Default / Edit
- Change Per Node RAM Quota to 1024 MB
- Hit “Save” button