pgspider griddb 试用
Posted rongfengliang-荣锋亮
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pgspider griddb 试用相关的知识,希望对你有一定的参考价值。
前边有构建一个简单的pgspider griddb fdw 的docker 镜像,以下是一个简单的试用
一些说明
关于pgspider griddb fdw 的构建目前4.3 有bug,使用的是4.2版本的,同时对于java 链接使用member ip,不是广播地址ip
环境准备
- griddb
自己调整的一些参数
start_griddb.sh 文件
#!/bin/bash
chown gsadm.gridstore /var/lib/gridstore/data
IP=`grep $HOSTNAME /etc/hosts | awk \' { print $1 }\'`
cat << EOF > /var/lib/gridstore/conf/gs_cluster.json
{
"dataStore":{
"partitionNum":128,
"storeBlockSize":"64KB"
},
"cluster":{
"clusterName":"defaultCluster",
"replicationNum":1,
"notificationInterval":"5s",
"heartbeatInterval":"5s",
"loadbalanceCheckInterval":"180s",
"notificationMember": [
{
"cluster": {"address":"$IP", "port":10010},
"sync": {"address":"$IP", "port":10020},
"system": {"address":"$IP", "port":10080},
"transaction": {"address":"$IP", "port":10001},
"sql": {"address":"$IP", "port":20001}
}
]
},
"sync":{
"timeoutInterval":"30s"
}
}
EOF
cat << EOF > /var/lib/gridstore/conf/gs_node.json
{
"dataStore":{
"dbPath":"data",
"backupPath":"backup",
"syncTempPath":"sync",
"storeMemoryLimit":"1024MB",
"storeWarmStart":false,
"storeCompressionMode":"NO_COMPRESSION",
"concurrency":2,
"logWriteMode":1,
"persistencyMode":"NORMAL",
"affinityGroupSize":4,
"autoExpire":false
},
"checkpoint":{
"checkpointInterval":"60s",
"checkpointMemoryLimit":"1024MB",
"useParallelMode":false
},
"cluster":{
"servicePort":10010
},
"sync":{
"servicePort":10020
},
"system":{
"servicePort":10040,
"eventLogPath":"log"
},
"transaction":{
"servicePort":10001,
"connectionLimit":5000
},
"trace":{
"default":"LEVEL_ERROR",
"dataStore":"LEVEL_ERROR",
"collection":"LEVEL_ERROR",
"timeSeries":"LEVEL_ERROR",
"chunkManager":"LEVEL_ERROR",
"objectManager":"LEVEL_ERROR",
"checkpointFile":"LEVEL_ERROR",
"checkpointService":"LEVEL_INFO",
"logManager":"LEVEL_WARNING",
"clusterService":"LEVEL_ERROR",
"syncService":"LEVEL_ERROR",
"systemService":"LEVEL_INFO",
"transactionManager":"LEVEL_ERROR",
"transactionService":"LEVEL_ERROR",
"transactionTimeout":"LEVEL_WARNING",
"triggerService":"LEVEL_ERROR",
"sessionTimeout":"LEVEL_WARNING",
"replicationTimeout":"LEVEL_WARNING",
"recoveryManager":"LEVEL_INFO",
"eventEngine":"LEVEL_WARNING",
"clusterOperation":"LEVEL_INFO",
"ioMonitor":"LEVEL_WARNING"
}
}
EOF
gs_passwd admin -p admin
gs_startnode
sleep 5
while gs_stat -u admin/admin | grep RECOV > /dev/null; do
echo Waiting for GridDB to be ready.
sleep 5
done
gs_joincluster -n 1 -u admin/admin
tail -f /var/lib/gridstore/log/gridstore*.log
dokerfile
FROM griddbnet/griddb
COPY start_griddb.sh /start_griddb.sh
- griddb java 镜像
代码在项目目录下,参考链接的github 地址
dockerfile
FROM openjdk:8u242-jdk-stretch
WORKDIR /app
COPY griddb-app.jar /app/griddb-app.jar
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
entrypoint.sh
#!/bin/sh
MEMBER=$MEMBER_ADDR
java -jar /app/griddb-app.jar $MEMBER
- docker-compose 文件
version: "3"
services:
pgspider-griddb:
image: dalongrong/pgspider:griddb-4.2
environment:
- "POSTGRES_PASSWORD=dalong"
ports:
- "5432:5432"
griddb-java:
build:
context: ./
dockerfile: ./Dockerfile-java
environment:
- "MEMBER_ADDR=griddb:10001"
griddb:
build: ./
volumes:
- "./log:/var/lib/gridstore/log"
ports:
- "10001:10001"
- "10010:10010"
- "10020:10020"
- "10030:10030"
- "10040:10040"
- "10050:10050"
- "10080:10080"
- "20001:20001"
使用
- 构建镜像
docker-compose build
- 启动griddb 以及pgspider griddb fdw
docker-compose up -d griddb pgspider-griddb
- 导入数据
通过java 应用导入数据
docker-compose up griddb-java
- 扩展使用
CREATE EXTENSION griddb_fdw;
CREATE SERVER griddb_svr FOREIGN DATA WRAPPER griddb_fdw OPTIONS(notification_member \'griddb:10001\',clustername \'defaultCluster\');
CREATE USER MAPPING FOR public SERVER griddb_svr OPTIONS(username \'admin\', password \'admin\');
IMPORT FOREIGN SCHEMA griddb_schema FROM SERVER griddb_svr INTO public;
select * from col01;
- 效果
说明
以上就是对于已经构建好的docker 镜像的简单使用,后边可以好好系统学习下griddb,一个很不错的面向iot 以及时序数据的系统
参考资料
https://github.com/griddb/c_client
https://github.com/pgspider/griddb_fdw
https://hub.docker.com/repository/docker/dalongrong/pgspider
https://github.com/rongfengliang/pgspider-griddb-fdw-docker
以上是关于pgspider griddb 试用的主要内容,如果未能解决你的问题,请参考以下文章
pgspider tds fdw sql server docker 镜像试用
pgspider cstore fdw docker 镜像试用