From bed110deea3ea9f963d5de6111d3290be7df41ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=85=83=E6=9C=A8?= Date: Sat, 9 May 2020 13:31:59 +0800 Subject: [PATCH] kvdb --- core | 2 +- database | 1 - deploy/deploy-kvdb/pom.xml | 99 +++++++++++++++++++ .../src/main/resources/assembly.xml | 54 ++++++++++ .../src/main/resources/config/cluster.conf | 11 +++ .../src/main/resources/config/kvdb.conf | 15 +++ .../main/resources/script/kvdb-benchmark.sh | 12 +++ .../src/main/resources/script/kvdb-cli.sh | 12 +++ .../src/main/resources/script/start.sh | 23 +++++ .../src/main/resources/script/stop.sh | 27 +++++ .../src/main/resources/system/dblist | 3 + deploy/deploy-peer/pom.xml | 5 + .../src/main/resources/assembly.xml | 2 + .../src/main/resources/config/init/local.conf | 1 + deploy/pom.xml | 1 + test | 2 +- 16 files changed, 267 insertions(+), 3 deletions(-) delete mode 160000 database create mode 100644 deploy/deploy-kvdb/pom.xml create mode 100644 deploy/deploy-kvdb/src/main/resources/assembly.xml create mode 100644 deploy/deploy-kvdb/src/main/resources/config/cluster.conf create mode 100644 deploy/deploy-kvdb/src/main/resources/config/kvdb.conf create mode 100644 deploy/deploy-kvdb/src/main/resources/script/kvdb-benchmark.sh create mode 100644 deploy/deploy-kvdb/src/main/resources/script/kvdb-cli.sh create mode 100644 deploy/deploy-kvdb/src/main/resources/script/start.sh create mode 100644 deploy/deploy-kvdb/src/main/resources/script/stop.sh create mode 100644 deploy/deploy-kvdb/src/main/resources/system/dblist diff --git a/core b/core index 4da71b24..29b18fe2 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 4da71b241528e0455bf91bb0d08bf29fcdf8e8b4 +Subproject commit 29b18fe218ceb1db51f8926d38d7bd31644a511e diff --git a/database b/database deleted file mode 160000 index 3f785b7e..00000000 --- a/database +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3f785b7e98df44cc7cfd02f83816e64e9acac631 diff --git a/deploy/deploy-kvdb/pom.xml b/deploy/deploy-kvdb/pom.xml new file mode 100644 index 00000000..a1e02938 --- /dev/null +++ b/deploy/deploy-kvdb/pom.xml @@ -0,0 +1,99 @@ + + + + deploy-root + com.jd.blockchain + 1.2.0.RELEASE + + 4.0.0 + + deploy-kvdb + 1.0.0.RELEASE + + + + + com.jd.blockchain + kvdb-protocol + ${version} + + + + com.jd.blockchain + kvdb-engine + ${version} + + + + com.jd.blockchain + kvdb-server + ${version} + + + + com.jd.blockchain + kvdb-cli + ${version} + + + + com.jd.blockchain + kvdb-benchmark + ${version} + + + + com.jd.blockchain + kvdb-client + ${version} + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + make-assembly + package + + single + + + kvdb + + src/main/resources/assembly.xml + + + + + + + + + net.nicoulaj.maven.plugins + checksum-maven-plugin + 1.8 + + + + artifacts + + + + + + SHA-256 + + ${project.basedir}/target/deployment-kvdb-${project.version}.zip + true + ${project.basedir}/target/SHA-256.xml + + + + + \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/assembly.xml b/deploy/deploy-kvdb/src/main/resources/assembly.xml new file mode 100644 index 00000000..34a09ee3 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/assembly.xml @@ -0,0 +1,54 @@ + + + ${project.version} + + zip + + false + + + src/main/resources/script + bin + unix + + + src/main/resources/config + config + unix + + + src/main/resources/system + system + unix + + + + + false + true + libs + + + + + + true + + com.jd.blockchain:kvdb-engine + com.jd.blockchain:kvdb-benchmark + com.jd.blockchain:kvdb-client + com.jd.blockchain:kvdb-protocol + com.jd.blockchain:kvdb-cli + com.jd.blockchain:kvdb-server + + + libs + false + + + + + \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/config/cluster.conf b/deploy/deploy-kvdb/src/main/resources/config/cluster.conf new file mode 100644 index 00000000..9801c753 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/config/cluster.conf @@ -0,0 +1,11 @@ +# 数据库集群的分片数,每一个分片都赋予唯一的编号,分片编号最小为 0,所有分片的编号必须连续递增 +#cluster.test1.partitions=2 +# 数据库集群 ‘’ 的第 1 个分片的数据库实例地址(URL格式); +#cluster.test1.0=kvdb://localhost:7078/test1 +# 数据库集群 ‘’ 的第 2 个分片的数据库实例地址(URL格式); +#cluster.test1.1=kvdb://localhost:7079/test1 + +# 指定多个不同的集群 +#cluster.test2.partitions=2 +#cluster.test2.0=kvdb://localhost:7078/test2 +#cluster.test2.1=kvdb://localhost:7079/test2 \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/config/kvdb.conf b/deploy/deploy-kvdb/src/main/resources/config/kvdb.conf new file mode 100644 index 00000000..1b47c61a --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/config/kvdb.conf @@ -0,0 +1,15 @@ +# 数据库服务的本机监听地址; +server.host=0.0.0.0 + +# 数据库服务的本机监听端口; +server.port=7078 + +# 管理控制台的端口; +# 注:管理控制台总是绑定到环回地址 127.0.0.1,只允许本机访问; +manager.port=7060 + +# 数据库实例默认的根目录 +dbs.rootdir=../dbs + +# 数据库实例默认的本地分区数 +dbs.partitions=4 \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/script/kvdb-benchmark.sh b/deploy/deploy-kvdb/src/main/resources/script/kvdb-benchmark.sh new file mode 100644 index 00000000..b2180397 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/script/kvdb-benchmark.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +HOME=$(cd `dirname $0`;cd ../; pwd) +KVDB=$(ls $HOME/libs | grep kvdb-benchmark) +JVM_SET="-Xmx2g -Xms2g" +LOG_SET="-Dlogging.path="$HOME/logs" -Dlogging.level=error" +PROC_INFO=$HOME/libs/$KVDB +if [ ! -n "$KVDB" ]; then + echo "Can not find kvdb-benchmark !!!" +else + java -jar $LOG_SET $JVM_SET $PROC_INFO $* +fi \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/script/kvdb-cli.sh b/deploy/deploy-kvdb/src/main/resources/script/kvdb-cli.sh new file mode 100644 index 00000000..fd6474a8 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/script/kvdb-cli.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +HOME=$(cd `dirname $0`;cd ../; pwd) +KVDB=$(ls $HOME/libs | grep kvdb-cli) +JVM_SET="-Xmx2g -Xms2g" +LOG_SET="-Dlogging.path="$HOME/logs" -Dlogging.level.root=error" +PROC_INFO=$HOME/libs/$KVDB +if [ ! -n "$KVDB" ]; then + echo "Can not find kvdb-cli !!!" +else + java -jar $LOG_SET $JVM_SET $PROC_INFO $* +fi \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/script/start.sh b/deploy/deploy-kvdb/src/main/resources/script/start.sh new file mode 100644 index 00000000..18fdc9c6 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/script/start.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +HOME=$(cd `dirname $0`;cd ../; pwd) +KVDB=$(ls $HOME/libs | grep kvdb-server) +JVM_SET="-Xmx2g -Xms2g" +PROC_INFO=$HOME/libs/$KVDB" -home "$HOME +LOG_SET="-Dlogging.path="$HOME/logs" -Dlogging.level=error" +#echo $PROC_INFO +#get PID +PID=`ps -ef | grep "$PROC_INFO" | grep -v grep | awk '{print $2}'` +#echo $PID +if [[ ! -z $PID ]] +then + echo "process already exists,please check... If necessary, you should kill the process first." + exit +fi +if [ ! -n "$KVDB" ]; then + echo "Can not find kvdb-server !!!" +else + nohup java -jar $LOG_SET $JVM_SET $PROC_INFO $* >/dev/null 2>&1 & + + echo $! > $HOME/system/pid +fi \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/script/stop.sh b/deploy/deploy-kvdb/src/main/resources/script/stop.sh new file mode 100644 index 00000000..5b654ff7 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/script/stop.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +#启动Home路径 +HOME=$(cd `dirname $0`;cd ../; pwd) + +#进程启动后PID.log所在路径 +PID_LOG=$HOME/system/pid + +#从启动文件中读取PID +if [ -f "$PID_LOG" ]; then + # File exist + echo "Read PID From File:[$PID_LOG] ..." + PID=`sed -n '$p' $PID_LOG` +#启动文件不存在则直接通过PS进行过滤 +else + PID=`ps -ef | grep $HOME/libs/kvdb-server | grep -v grep | awk '{print $2}'` +fi + +#通过Kill命令将进程杀死 +if [ -z "$PID" ]; then + echo "Unable to find kvdb PID. stop aborted." +else + echo "Start to kill PID = $PID ..." + kill -9 $PID + echo "kvdb has been stopped ..." + echo "" > $PID_LOG +fi \ No newline at end of file diff --git a/deploy/deploy-kvdb/src/main/resources/system/dblist b/deploy/deploy-kvdb/src/main/resources/system/dblist new file mode 100644 index 00000000..485d32b3 --- /dev/null +++ b/deploy/deploy-kvdb/src/main/resources/system/dblist @@ -0,0 +1,3 @@ +db.test1.enable=true +db.test2.enable=true +db.test3.enable=true diff --git a/deploy/deploy-peer/pom.xml b/deploy/deploy-peer/pom.xml index 537cfb5d..32d0eebc 100644 --- a/deploy/deploy-peer/pom.xml +++ b/deploy/deploy-peer/pom.xml @@ -50,6 +50,11 @@ storage-rocksdb ${core.version} + + com.jd.blockchain + storage-kvdb + ${core.version} + diff --git a/deploy/deploy-peer/src/main/resources/assembly.xml b/deploy/deploy-peer/src/main/resources/assembly.xml index 18b14057..ce211195 100644 --- a/deploy/deploy-peer/src/main/resources/assembly.xml +++ b/deploy/deploy-peer/src/main/resources/assembly.xml @@ -35,6 +35,7 @@ com.jd.blockchain:storage-service com.jd.blockchain:storage-rocksdb com.jd.blockchain:storage-redis + com.jd.blockchain:storage-kvdb com.jd.blockchain:storage-composite com.jd.blockchain:runtime-modular com.jd.blockchain:runtime-modular-booter @@ -63,6 +64,7 @@ com.jd.blockchain:storage-service com.jd.blockchain:storage-rocksdb com.jd.blockchain:storage-redis + com.jd.blockchain:storage-kvdb com.jd.blockchain:storage-composite com.jd.blockchain:runtime-modular com.jd.blockchain:runtime-modular-booter diff --git a/deploy/deploy-peer/src/main/resources/config/init/local.conf b/deploy/deploy-peer/src/main/resources/config/init/local.conf index 31518046..a1d1412f 100644 --- a/deploy/deploy-peer/src/main/resources/config/init/local.conf +++ b/deploy/deploy-peer/src/main/resources/config/init/local.conf @@ -17,6 +17,7 @@ ledger.binding.out=../ #账本数据库的连接字符 #rocksdb数据库连接格式:rocksdb://{path},例如:rocksdb:///export/App08/peer/rocks.db/rocksdb0.db #redis数据库连接格式:redis://{ip}:{prot}/{db},例如:redis://127.0.0.1:6379/0 +#kvdb数据库连接格式:kvdb://{ip}:{prot}/{db},例如:kvdb://127.0.0.1:7080/test ledger.db.uri= #账本数据库的连接口令 diff --git a/deploy/pom.xml b/deploy/pom.xml index 00b49518..e3bdb271 100644 --- a/deploy/pom.xml +++ b/deploy/pom.xml @@ -20,6 +20,7 @@ ../core deploy-gateway deploy-peer + deploy-kvdb \ No newline at end of file diff --git a/test b/test index 7c348ac2..7f9a7107 160000 --- a/test +++ b/test @@ -1 +1 @@ -Subproject commit 7c348ac2e813bdd77a9b2e00ddc340da26f7ccb6 +Subproject commit 7f9a7107f8c916a688d9b49749ade0334302ca26