We will carefully introduce how to set up the open source GridDB Community Edition in the CentOS container (virtual environment) on Docker Desktop from the beginning. Also, I will explain his Docker command etc. in detail on the way, so I think that it will be helpful for those who are new to Docker and want to set up his GridDB Community Edition in Docker's CentOS container.
Specifically, install and set up GridDB Community Edition on one MacBook in which Docker for Mac is installed on the host OS macOS and the Docker container of CentOS is built, and start/stop the GridDB server and execute the sample program. Check the operation.
The procedure is almost the same even in the environment of Docker Desktop for Windows.
This time, it is assumed that the Docker Desktop environment has already been built and the CentOS Docker image that has been confirmed to work is prepared on it. If you are preparing from now on, please refer to the following two articles.
"[Introduction] Installation of Docker Desktop for Mac for the first time and setup of virtual environment construction of CentOS --Qiita" "[Introduction] Installation of Docker Desktop for Windows for the first time and setup of virtual environment construction of CentOS --Qiita"
In addition, CentOS 7.9.2009 images is used for CentOS whose operation has been confirmed this time.
Hereafter, the name of the CentOS image that has been confirmed to work is centos: gahoh. Launch a terminal and use the docker images command to view a list of locally saved Docker images. Suppose you have a CentOS Docker image that looks like this:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos gahoh 8beaf0d882f9 53 minutes ago 663MB
centos centos7 8652b9f0cb4c 6 weeks ago 204MB
Build and launch the container from the CentOS Docker image centos: gahoh.
Use the docker run command to build and start the CentOS container from the CentOS image. Execute the docker run command as follows to build and start the container.
$ docker run -it --name="centos" centos:gahoh /bin/bash
#
Here, we build the container from the CentOS Docker image centos: gahoh, start the container at the same time, log in automatically at that time, and connect to the bash shell as it is. Here, the newly created container is named "centos".
The installation of the GridDB Community Edition package is as follows.
(CentOS)
$ sudo rpm -ivh griddb-X.X.X-(X.)linux.x86_64.rpm
(Ubuntu)
$ sudo dpkg -i griddb_X.X.X_amd64.deb
(openSUSE)
$ sudo rpm -ivh griddb-X.X.X-opensuse.x86_64.rpm
※ X.X.X-(X.)Or X.X.X means version.
This time, I will install it directly on CentOS of Docker Desktop for Mac using the RPM package of Assets of Release on the GitHub site. The URL of the RPM package is as follows.
https://github.com/griddb/griddb/releases/download/vX.X.X/griddb-X.X.X(-X)-linux.x86_64.rpm
X.X.X or X.X.X-(X) means version.
This time, the version installed here is v4.5.2. Therefore, the URL of the RPM package used for installation is as follows.
https://github.com/griddb/griddb/releases/download/v4.5.2/griddb-4.5.2-linux.x86_64.rpm
Let's install it. Use the rpm command to install / uninstall the RPM package.
Install with the rpm command.
# rpm -ivh https://github.com/griddb/griddb/releases/download/v4.5.2/griddb-4.5.2-linux.x86_64.rpm
The installation will start.
# rpm -ivh https://github.com/griddb/griddb/releases/download/v4.5.2/griddb-4.5.2-linux.x86_64.rpm
Retrieving https://github.com/griddb/griddb/releases/download/v4.5.2/griddb-4.5.2-linux.x86_64.rpm
Preparing... ################################# [100%]
------------------------------------------------------------
Information:
User gsadm and group gridstore have been registered.
GridDB uses new user and group.
------------------------------------------------------------
Updating / installing...
1:griddb-4.5.2-linux ################################# [100%]
#
This completes the installation.
Installing this RPM package automatically creates a CentOS user gsadm and group gridstore. The user gsadm is used as the admin user to operate GridDB. The environment variables GS_HOME and GS_LOG are automatically set when you log in as user gsadm. In addition, the location of the operation command is set in the environment variable PATH.
Check the directory structure of the installed GridDB node. A GridDB home directory for placing node definition files and database files, and an installation directory for placing installed files are created.
Administrator users are used to execute operational commands and operations for which only administrator privileges are permitted. The admin user gsadm does not have a password, so set one.
# passwd gsadm
Changing password for user gsadm.
New password:(Enter the password)
Retype new password:(Enter the password)
passwd: all authentication tokens updated successfully.
# gpasswd -a gsadm wheel
Adding user gsadm to group wheel
Here, set a password that conforms to the CentOS password policy. For the time being, I chose GridDB4admin.
If the password for the administrative user gsadm is not set, the server cannot be started, so be sure to set a password. Log in as user gsadm and use the gs_passwd command to set the admin user password.
# su - gsadm
$ gs_passwd admin
Password:(Enter the password)
Retype password:(Enter the password)
$
Here, enter the password as admin for the time being.
In order for GridDB to operate after installation, it is necessary to initialize node parameters such as address and cluster name. Here, only his cluster name, which is a required item, is set, and the default values are used for the others. Describe the cluster name of the cluster in the cluster definition file. The cluster definition file is /var/lib/gridstore/conf/gs_cluster.json. Enter the cluster name in the "clusterName": "" part. Here, we use the name myCluster.
$ vi conf/gs_cluster.json
{
"dataStore":{
"partitionNum":128,
"storeBlockSize":"64KB"
},
"cluster":{
"clusterName":"",
"replicationNum":2,
"notificationAddress":"239.0.0.1",
"notificationPort":20000,
"notificationInterval":"5s",
"heartbeatInterval":"5s",
"loadbalanceCheckInterval":"180s"
},
"sync":{
"timeoutInterval":"30s"
},
"transaction":{
"notificationAddress":"239.0.0.1",
"notificationPort":31999,
"notificationInterval":"5s",
"replicationMode":0,
"replicationTimeoutInterval":"10s"
},
"sql":{
"notificationAddress":"239.0.0.1",
"notificationPort":41999,
"notificationInterval":"5s"
}
}
Insert the cluster name myCluster in the "clusterName": "" part and save it.
$ vi conf/gs_cluster.json
{
"dataStore":{
"partitionNum":128,
"storeBlockSize":"64KB"
},
"cluster":{
"clusterName":"myCluster",
"replicationNum":2,
"notificationAddress":"239.0.0.1",
"notificationPort":20000,
"notificationInterval":"5s",
"heartbeatInterval":"5s",
"loadbalanceCheckInterval":"180s"
},
"sync":{
"timeoutInterval":"30s"
},
"transaction":{
"notificationAddress":"239.0.0.1",
"notificationPort":31999,
"notificationInterval":"5s",
"replicationMode":0,
"replicationTimeoutInterval":"10s"
},
"sql":{
"notificationAddress":"239.0.0.1",
"notificationPort":41999,
"notificationInterval":"5s"
}
}
Let's start / stop the GridDB node and start / stop the cluster. There seem to be several ways to start and stop, but here we will use operational commands. The operation command is executed by the gsadm user.
To start the node, use the gs_startnode command of the operation command. For the user authentication option -u, specify the admin user username: admin and password (here admin), and specify the -w option to wait for the node to start.
$ gs_startnode -u admin/admin -w
.
Started node.
To start the cluster, use the gs_joincluster command, which is an operation command. For the user authentication option -u, specify the admin user username admin and password (here admin), and specify the -w option to wait for the cluster to start. Specify the cluster name with the -c option.
$ gs_joincluster -u admin/admin -c myCluster –w
..
Joined node
Use the gs_stat command, which is an operation command, to check the cluster status, such as whether the cluster has started. For the user authentication option -u, specify the user name and password of the admin user admin. Also, in order to check the status of the cluster, it is better to extract only the line with "Status" notation with grep.
$ gs_stat -u admin/admin | egrep Status
"clusterStatus": "MASTER",
"nodeStatus": "ACTIVE",
"partitionStatus": "NORMAL",
If "clusterStatus", "nodeStatus", and "partitionStatus" are displayed as above, the application can access the cluster while it is running normally.
$ cd
$ export CLASSPATH=${CLASSPATH}:/usr/share/java/gridstore.jar:.
$ mkdir gsSample
$ cp /usr/griddb-4.5.2/docs/sample/program/Sample1.java gsSample/.
$ javac gsSample/Sample1.java
$ java gsSample/Sample1 239.0.0.1 31999 myCluster admin admin
Person: name=name02 status=false count=2 lob=[65, 66, 67, 68, 69, 70, 71, 72, 73, 74]
If you don't have the JDK installed, the standard CentOS yum repository has the name java-1.8.0-openjdk. OpenJDK's Java 8 (JDK) development environment package.
# sudo yum -y install java-1.8.0-openjdk-devel
Contrary to the startup flow, safely stop the cluster and then stop each node. When the cluster is stopped, the application cannot access the cluster.
Execute the gs_stopcluster command of the operation command. When you execute the cluster stop command, the application will not be able to access the cluster. For the user authentication option -u, specify the user name and password of the admin user admin, and specify the -w option to wait for the cluster to stop.
$ gs_stopcluster -u admin/admin -w
.
Stopped cluster
Execute the gs_stopnode command of the operation command to stop (shut down) the node. Be sure to stop the cluster before stopping the node. For the user authentication option -u, specify the user name and password of the admin user admin, and specify the -w option to wait for the cluster to stop.
$ gs_stopnode -u admin/admin -w
Stopping node
.
Stopped node
A command called docker commit is provided as a command to save the contents of the work changed in the container as a new image. Using this, he saves the modified container as an image to install and configure GridDB. Once you exit the container, use the docker commit command to overwrite the container named "centos" with an image named "centos: gahoh".
In the future, this will make it easier to use the operating environment of GridDB.
Exit the container.
$ exit
logout
# exit
exit
$
The container centos is now stopped. Use the docker ps command with the -a option to display all containers, including dead containers.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cd115c8ce57b centos:gahoh "/bin/bash" 37 minutes ago Exited (0) 2 minutes ago centos
$
Before that, check the currently acquired image with the docker images command.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos gahoh 8beaf0d882f9 2 hours ago 663MB
centos centos7 8652b9f0cb4c 6 weeks ago 204MB
Use the docker commit command to overwrite "centos" in the CentOS container of the set up operating environment with the image named "centos: gahoh".
$ docker commit centos centos:gahoh
sha256:9d94ca66706c330a7b2c7ee49c8c29ccc528e3ae54cd757085e0e17b21e27ddd
$
For the time being, let's confirm that the image "centos: gahoh" has been updated with the docker images command.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos gahoh 9d94ca66706c 9 seconds ago 709MB
centos centos7 8652b9f0cb4c 6 weeks ago 204MB
$
Now you can see that the container with GridDB installation and environment settings has been overwritten and saved in the image centos: gahoh.
I intend to describe a series of steps in detail while building and checking the operation of GridDB Community Edition in the CentOS container (virtual environment) on Docker Desktop for Mac. If you find any mistakes or concerns about the description, we would appreciate it if you could give us feedback in the edit request or comment.
Recommended Posts