Easy JSON database experience with Docker ~ Try the latest version of Couchbase Server

Introduction

Target audience of this article

The following people are assumed as the target audience for this article.

--I want to start development with a database that can store JSON data (especially those who are interested in the following) --I want to query JSON data in a query language like SQL --I want to achieve response performance of milliseconds or less --I want to install a database in the local environment for development / verification

About installation method

As the title says, we will use Docker here. I will try to describe it so that it can be executed without assuming knowledge of Docker, but if you are more familiar with installation by the installer, please download and execute from the following (Mac, Windows, Ubuntu installers are available) ). After that, please refer to this article for initial settings.

COUCHBASE FREE NOSQL DATABASE LIST

About Docker, I will start the explanation from the place where it is installed in the environment.

About Couchbase Server

Couchbase Server has a distributed architecture, but here we build it as a single-node cluster in a local environment. (If you use Docker, you can build it as a cluster consisting of multiple nodes in the local environment. There is nothing particularly difficult for those who are familiar with Docker, but if you are interested, please refer to the reference information document. Please refer)

There are Enterprise Edition and Community Edition in Couchbase Server, but here we will use Enterprise Edition for verification purposes (the link above describes the available range of each edition).

Environment construction procedure

Install with Docker

First run

Execute the following command.

$ docker run -d --name db -p 8091-8094:8091-8094 -p 11210-11211:11210-11211 couchbase

The latest version ("couchbase: latest") will be downloaded from the Couchbase Docker repository and the container will start running.

Access http://localhost:8091.

The following screen will be displayed.

image.png

Installation is complete!

Installation confirmation

... because it's dull, let's check the installed status.

Check the log

db is specified in the --name option of the docker run command.

$ docker logs db
Starting Couchbase Server -- Web UI available at http://<ip>:8091
and logs available in /opt/couchbase/var/lib/couchbase/log

Check the image

$ docker images
REPOSITORY                                                TAG                 IMAGE ID            CREATED             SIZE
couchbase                                                 latest              8f1b63be0df7        3 weeks ago         1.19GB

Check the process

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                                               NAMES
d4bfe9191a55        couchbase           "/entrypoint.sh couc…"   6 minutes ago       Up 6 minutes        8095-8096/tcp, 0.0.0.0:8091-8094->8091-8094/tcp, 11207/tcp, 0.0.0.0:11210-11211->11210-11211/tcp, 18091-18096/tcp   db

It was confirmed that a Docker image named "couchbase" was installed, a container named "db" was created from that image, and it was in a working state. (Finally, we will also look at stopping and restarting this container.)

Couchbase Server Initial Settings

Cluster initial construction

Wizard selection

As you can see in the screen image above, the first choices when accessing the WEB console immediately after installation are "Setup New Cluster" and "Join Existing Cluster". Here, of course, the former is selected.

The following screen will be displayed, so enter it as appropriate. Press Next: Accept Terms.

image.png

Terms and Conditions Click the check box as appropriate. image.png

You can exit with "Finish With Defaults", but let's take a look at "Configure Disk, Memory, Services".

Cluster settings

image.png

image.png

For verification purposes, there is nothing that needs to be changed, so press "Save & Finish" and exit ... but you may see an error like the one below. .. image.png

If you review the screen above, you can see that TOTAL QUOTA exceeds Max Allowed Quota.

image.png

Change the Quota of each service as appropriate and adjust it so that it is less than or equal to Max Allowed Quota. You can also disable a service on this node by unchecking the box for the service you do not need. You cannot enable it later (in which case you need to remove it from the cluster and add it again), but you have the flexibility to design the configuration of the entire cluster. As a verification environment to prepare here, I think that you can disable Search, Analytics, and Eventing unless you have a specific need.

Finally, a screen like this was displayed. image.png

Bucket creation

Click the "Bucket" link to create a bucket, which is the unit of data storage.

The bucket list screen is displayed. Click the "ADD BUCKET" link in the upper right.

image.png

Enter an appropriate name and press the "Add Bucke" button. (The bucket settings can be changed later)

image.png

image.png

I think it looks like this. "Warning" is displayed because the replica setting is enabled by default. Press "Edit" to prevent the alert from being displayed.

Expand Advanced bucket settings and uncheck the Replicas checkbox. image.png

By the way, keep Flush enabled. Click "Save Changes".

image.png

"Warning" has disappeared and a "Flush" button has been added.

image.png

Document added

Let's add a document. Click the Documents link at the top right of the screen above.

A screen like this is displayed. By widening the screen size of the browser sufficiently, the menu on the left will be displayed. Click "ADD DOCUMENT" in the upper right.

image.png

Enter an appropriate document ID. image.png

The default contents when creating a document from the WEB console are displayed, so edit it as appropriate and press "Save". (This is for confirmation of document creation, so no modification is required.) image.png

Document addition confirmed.

image.png

Stop / start container

Stop the container.

$ docker stop db

Check the running container. Also make sure that you cannot access the web console in your browser.

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Check for containers that are not running.

$ docker ps -a
CONTAINER ID        IMAGE                                                         COMMAND                  CREATED             STATUS                          PORTS                                                                                                      NAMES
d4bfe9191a55        couchbase                                                     "/entrypoint.sh couc…"   49 minutes ago      Exited (0) About a minute ago                                                                                                              db

Let's start the container again.

$ docker start db

Make sure you can access the web console.

image.png

Thank you for your hard work!

I don't think I'm using calories so much, but I hope that the resistance when I first come into contact with new technology has been alleviated.

After this, please also refer to the following articles etc.

Next Step: Develop with Couchbase Server

Experience reactive programming with NoSQL (touch the Couchbase Reactive API)

Leveraging NoSQL database for JavaScript development (CEAN stack introduction) ~ Node.js + Couchbase application development step-by-step guide 2

Go + NoSQL (Couchbase) App Development Step-by-Step Guide (1)

Node.js + NoSQL (Couchbase) App Development Step-by-Step Guide (1)

Reference information

Build Couchbase local environment with Docker A case of using the previous version (4.5.1) of Community Edition is introduced. It also explains how to customize Docker.

Deploy a Multi-Node Cluster with Containers How to use Docker mentioned at the beginning of this article to realize a cluster of multiple nodes in a local environment (There is also a way to use Kubernetes to achieve the same thing, but that will be another topic, if it can be published in the future I think)

Frequently used Docker commands Various Docker commands are briefly introduced.

Recommended Posts

Easy JSON database experience with Docker ~ Try the latest version of Couchbase Server
I tried to build the environment of PlantUML Server with Docker
[MySQL] The database server built with docker may not support Japanese ...
Easy installation of Docker with snap (1 command)
[Error] Error during Docker build (solved by pulling the latest version of image)
Easy JUnit test of Elasticsearch 2018 version with embedded-elasticsearch
Manage the version of Ruby itself with rbenv
Set Java version 11 of Docker Minecraft Paper server
Try the free version of Progate [Java II]
Install the latest version of Jenkins on Ubuntu 16
Let's play with Minishift! Easy experience of kubernetes
Try the free version of Progate [Java I]
"Experience" reactive programming with NoSQL (touch the Couchbase Reactive API)
The story of building a Java version of Minecraft server with GCP (and also set a whitelist)
Try WildFly with Docker
Install by specifying the version of Django in the Docker environment
Easy environment construction of MySQL and Redis with Docker and Alfred
[Java] Try editing the elements of the Json string using the library
Update to the latest version without specifying the version with gradle wrapper
[Be careful about changing the version of Xdebug! ] Create a development environment with Xdebug3 + docker + VS Code