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
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.
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).
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.
Installation is complete!
... because it's dull, let's check the installed status.
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
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
couchbase latest 8f1b63be0df7 3 weeks ago 1.19GB
$ 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.)
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.
Terms and Conditions Click the check box as appropriate.
You can exit with "Finish With Defaults", but let's take a look at "Configure Disk, Memory, Services".
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. ..
If you review the screen above, you can see that TOTAL QUOTA exceeds Max Allowed Quota.
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.
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.
Enter an appropriate name and press the "Add Bucke" button. (The bucket settings can be changed later)
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.
By the way, keep Flush enabled. Click "Save Changes".
"Warning" has disappeared and a "Flush" button has been 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.
Enter an appropriate document ID.
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.)
Document addition confirmed.
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.
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.
Experience reactive programming with NoSQL (touch the Couchbase Reactive API)
Go + NoSQL (Couchbase) App Development Step-by-Step Guide (1)
Node.js + NoSQL (Couchbase) App Development Step-by-Step Guide (1)
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