GridDB Quickstart

Install GridDB

Download and Install

If you prefer videos:

Head over to the GridDB Github Releases page and download the RPM for the the latest version, as of this blog post, it’s version 4.2.0…

I prefer to copy the link and install with RPM:

$ wget \
https://github.com/griddb/griddb_nosql/releases/download/v4.2.0/griddb_nosql-4.2.0-1.linux.x86_64.rpm
$ sudo rpm -Uvh griddb_nosql-4.2.0-1.linux.x86_64.rpm

Edit Conf Files

It’s easiest to edit the configuration files of GridDB as the gsadm user which you can switch to with a combination of the sudo and su commands:

$ sudo su - gsadm

First, gs_cluster.json needs to be edited to set the cluster name, we’ll set it to the default cluster name of “defaultCluster”

{
        "dataStore":{
                "partitionNum":128,
                "storeBlockSize":"64KB"
        },
        "cluster":{
                "clusterName":"defaultCluster",
                "replicationNum":2,
                "notificationAddress":"239.0.0.1",
                "notificationPort":20000,
                "notificationInterval":"5s",
                "heartbeatInterval":"5s",
                "loadbalanceCheckInterval":"180s"
        },
        "transaction":{
                "notificationAddress":"239.0.0.1",
                "notificationPort":31999,
                "notificationInterval":"5s",
                "replicationMode":0,
                "replicationTimeoutInterval":"10s"
        },
        "sync":{
                "timeoutInterval":"30s"
        }
}

The edits to gs_node.json are optional, changing concurrency to the number of CPU cores and storeMemoryLimit to the desired value:

{
        "dataStore":{
                "dbPath":"data",
                "storeMemoryLimit":"4096MB",
                "storeWarmStart":true,
                "concurrency":4,
                "logWriteMode":1,
                "persistencyMode":"NORMAL",
                "affinityGroupSize":4
        },
       ... snip ..
}

Set the password for the default admin user (we’ll use the very-insecure password, “admin”) :

$ gs_passwd admin
Password: admin
Retype password: admin

Start Service

Since GridDB Community Edition doesn’t include an init script, you’ll need to start GridDB manually, first starting the service and then having it connect to other nodes.


$ sudo su - gsadm 
$ gs_startnode 
$ gs_joincluster -u admin/admin

Check GridDB Status

With GridDB running, you can check it’s status with gs_stat:

$ sudo su - gsadm 
$ gs_stat -u admin/admin
{
    "checkpoint": {
        "endTime": 1541699864633,
        "mode": "NORMAL_CHECKPOINT",
        "normalCheckpointOperation": 3,
        "pendingPartition": 0,
        "requestedCheckpointOperation": 0,
        "startTime": 1541699857076
    },
    "cluster": {
        "activeCount": 1,
        "clusterName": "defaultCluster",
        "clusterStatus": "MASTER",
        "designatedCount": 1,
        "loadBalancer": "ACTIVE",
        "master": {
            "address": "192.168.1.77",
            "port": 10040
        },
        "nodeList": [
            {
                "address": "192.168.1.77",
                "port": 10040
            }
        ],
        "nodeStatus": "ACTIVE",
        "notificationMode": "MULTICAST",
        "partitionStatus": "NORMAL",
        "startupTime": "2018-11-08T16:57:31Z",
        "syncCount": 2
    },
    "currentTime": "2018-11-08T18:15:15Z",
    "performance": {
        "backupCount": 0,
        "batchFree": 0,
        "checkpointFileAllocateSize": 262144,
        "checkpointFileSize": 262144,
        "checkpointFileUsageRate": 0,
        "checkpointMemory": 0,
        "checkpointMemoryLimit": 1073741824,
        "checkpointWriteSize": 0,
        "checkpointWriteTime": 0,
        "currentCheckpointWriteBufferSize": 0,
        "currentTime": 1541700915329,
        "numBackground": 0,
        "numConnection": 2,
        "numNoExpireTxn": 0,
        "numSession": 0,
        "numTxn": 0,
        "ownerCount": 128,
        "peakProcessMemory": 68169728,
        "processMemory": 68169728,
        "recoveryReadSize": 262144,
        "recoveryReadTime": 0,
        "storeCompressionMode": "NO_BLOCK_COMPRESSION",
        "storeDetail": {
            "batchFreeMapData": {
                "storeMemory": 0,
                "storeUse": 0,
                "swapRead": 0,
                "swapWrite": 0
            },
            "batchFreeRowData": {
                "storeMemory": 0,
                "storeUse": 0,
                "swapRead": 0,
                "swapWrite": 0
            },
            "mapData": {
                "storeMemory": 0,
                "storeUse": 0,
                "swapRead": 0,
                "swapWrite": 0
            },
            "metaData": {
                "storeMemory": 0,
                "storeUse": 0,
                "swapRead": 0,
                "swapWrite": 0
            },
            "rowData": {
                "storeMemory": 0,
                "storeUse": 0,
                "swapRead": 0,
                "swapWrite": 0
            }
        },
        "storeMemory": 0,
        "storeMemoryLimit": 4294967296,
        "storeTotalUse": 0,
        "swapRead": 0,
        "swapReadSize": 0,
        "swapReadTime": 0,
        "swapWrite": 0,
        "swapWriteSize": 0,
        "swapWriteTime": 0,
        "syncReadSize": 0,
        "syncReadTime": 0,
        "totalBackupLsn": 0,
        "totalLockConflictCount": 0,
        "totalOtherLsn": 0,
        "totalOwnerLsn": 0,
        "totalReadOperation": 0,
        "totalRowRead": 0,
        "totalRowWrite": 0,
        "totalWriteOperation": 0
    },
    "recovery": {
        "progressRate": 1
    },
    "version": "4.0.0-33128 CE"
}

We’re now ready to install client software to connect to GridDB.

Java Connector

Download + Install Java

You have two options for using Java: Oracle JDK 1.8.0 (recommended) or OpenJDK provided in CentOS.
To use Oracle JDK, visit Oracle’s Java SE Development Kit 8 Downloads page; accept the license agreement and copy the link for the Linux X64 RPM.

Then in your terminal:

$ sudo rpm -Uvh [Copy'd Link]

To install OpenJDK if it’s not already installed:

$ sudo yum -y install java-1.8.0-openjdk-devel

Build + Run Sample

$ mkdir ~/gsSample/ 
$ cp /usr/griddb-4.0.0/docs/sample/program/Sample1.java ~/gsSample 
$ cd ~/gsSample 
$ javac Sample1.java 
$ cd .. 
$ java gsSample/Sample 239.0.0.1 31999 defaultCluster admin admin
Person:  name=name02 status=false count=2 lob=[65, 66, 67, 68, 69, 70, 71, 72, 73, 74]

The arguments for the Sample are:
1. 239.0.0.1 : Multicast address of the GridDB Server
2. 31999: Multicast port of the GridDB server.
3. defaultCluster: Your clustername
4. admin: Your username.
5. admin: Your password.

Python Connector

Download + Install Python3

GridDB’s Python Client requires Python3 which isn’t included by default in CentOS. While you can install Python3.4 using EPEL, I prefer using the latest version of Python from IUS.

$ sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm 
$ sudo yum install -y python35u python35u-pip

Download + Install C Client

The Python Client also requires GridDB’s C Client which can be downloaded from the GridDB C client Github Releases page. You can copy the link fo rhte latest release and download and untar it. Once untarred, all thats required is copying the library files to /usr/lib64.

$ wget  \
https://github.com/griddb/c_client/releases/download/v4.0.0/griddb_c_client-4.0.0-linux.x86_64.tar.gz 
$ tar zxvf griddb_c_client-4.0.0-linux.x86_64.tar.gz 
$ cd c_client-4.0.0/ 
$ sudo cp bin/libgridstore.so* /usr/lib64/

Download + Install PyClient

From the GridDB Python Client’s Github Releases page copy the link from the latest release and download and untar it.

$ wget https://github.com/griddb/python_client/archive/0.7.6.tar.gz 
$ tar zxvf 0.7.6.tar.gz 
$ cd python_client-0.7.6/

You’ll need to edit the Makefile to point to the correct Python include directory, in the case of the IUS Python packages, you’ll change -I/usr/include/python3.6 to -I/usr/include/python3.6m and then build the client with make.

$ make

Run Sample

To run the Python sample, you simply copy it beside the GridDB Python files. If you’ve used the Java sample already, you will want to change the container name, changing conInfo = griddb.ContainerInfo("col01", to conInfo = griddb.ContainerInfo("pycol01",.

$ cp sample/sample1.py . 
$ python3 sample1.py  239.0.0.1 31999 defaultCluster admin admin
Person: name=name02 status=False count=2 lob=[65, 66, 67, 68, 69, 70, 71, 72, 73, 74]

Now, if you’re adding GridDB to your own project, simply copy griddb_python.py and _griddb_python.so to directory that contains your Python source files.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.