From b6d8b7ed5ff014d7416aa1ff49070ff0276f7bef Mon Sep 17 00:00:00 2001 From: hei <2205160145@qq.com> Date: Sun, 26 Sep 2021 08:39:37 +0000 Subject: [PATCH 1/3] add tools/install.sh. A script to install all OpenMLDB components --- tools/install.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tools/install.sh diff --git a/tools/install.sh b/tools/install.sh new file mode 100644 index 000000000..0491f1372 --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,44 @@ +#!/bin/bash +if ! [ -x "$(command -v java)" ]; then + echo 'Error: java is not installed.' >&2 + #exit 1 +fi + +if ! [ -x "$(command -v wget)" ]; then + echo 'Error: wget is not installed.' >&2 + exit 1 +fi + +echo 'install zookeeper' +FILE=zookeeper-3.4.14.tar.gz +if [ -e "$FILE" ]; then + echo "$FILE exist" +else + wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz + tar -zxvf zookeeper-3.4.14.tar.gz + cd zookeeper-3.4.14 + cp conf/zoo_sample.cfg conf/zoo.cfg + cd .. +fi + +echo 'install nameserver' +FILE=openmldb-0.2.2-linux.tar.gz +if [ -e "$FILE" ]; then + echo "$FILE exist" +else + wget https://github.com/4paradigm/OpenMLDB/releases/download/0.2.2/openmldb-0.2.2-linux.tar.gz + if [ -e "$FILE" ]; then + tar -zxvf openmldb-0.2.2-linux.tar.gz + mv openmldb-0.2.2-linux openmldb-ns-0.2.2 + echo 'install tablet' + tar -zxvf openmldb-0.2.2-linux.tar.gz + mv openmldb-0.2.2-linux openmldb-tablet-2.2.0 + else + echo 'download fail ; try script again' + exit 1 + fi +fi + +echo 'install complete' + + -- Gitee From fdd64d045d67386b9e0abdc21e01db20c7377b63 Mon Sep 17 00:00:00 2001 From: hei <2205160145@qq.com> Date: Sun, 26 Sep 2021 08:40:38 +0000 Subject: [PATCH 2/3] update tools/install.sh. --- tools/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install.sh b/tools/install.sh index 0491f1372..4b39eeb1b 100644 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,7 +1,7 @@ #!/bin/bash if ! [ -x "$(command -v java)" ]; then echo 'Error: java is not installed.' >&2 - #exit 1 + exit 1 fi if ! [ -x "$(command -v wget)" ]; then -- Gitee From 8896fa0621442edf806f0a1350e29064200c65e2 Mon Sep 17 00:00:00 2001 From: GuoChao <2205160145@qq.com> Date: Wed, 29 Sep 2021 22:48:45 +0800 Subject: [PATCH 3/3] add start service --- tools/install.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 4b39eeb1b..bb10bb4ae 100644 --- a/tools/install.sh +++ b/tools/install.sh @@ -14,14 +14,15 @@ FILE=zookeeper-3.4.14.tar.gz if [ -e "$FILE" ]; then echo "$FILE exist" else - wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz + ZK=zookeeper-3.4.14 + wget "https://archive.apache.org/dist/zookeeper/${ZK}/${ZK}.tar.gz" tar -zxvf zookeeper-3.4.14.tar.gz cd zookeeper-3.4.14 cp conf/zoo_sample.cfg conf/zoo.cfg cd .. fi -echo 'install nameserver' +echo 'install nameserver and tabnet' FILE=openmldb-0.2.2-linux.tar.gz if [ -e "$FILE" ]; then echo "$FILE exist" @@ -40,5 +41,86 @@ else fi echo 'install complete' + +echo 'starting zookeeper' +cd zookeeper-3.4.14 +dataDir="./data" +clientPort="6181" +#modify zookeeper config +sed -i "s:dataDir=[a-zA-Z0-9//]*:dataDir=${dataDir}:" conf/zoo.cfg +sed -i "s:clientPort=[0-9]*:clientPort=${clientPort}:" conf/zoo.cfg +PID=`lsof -i :${clientPort}|grep -v "PID" | awk '{print $2}'` +echo $PID +if [ "$PID" != "" ]; then + echo "zk port is unavailable" + exit 1 +fi +bash bin/zkServer.sh start +cd .. +echo 'zookeeper OK' + +echo 'starting nameserver' +cd openmldb-ns-0.2.2 +IP=`hostname -i` +#get available port +ns_port=6527 +PID=`lsof -i :${ns_port}|grep -v "PID" | awk '{print $2}'` +if [ "$PID" != "" ]; then + echo "ns port is unavailable; try to get another port!" + templ=0 + ns_port=0 + while [ "$ns_port" -eq 0 ]; do + temp1=`shuf -i 1024-10000 -n1` + PID=`lsof -i :${temp1}|grep -v "PID" | awk '{print $2}'` + if [ "$PID" != "" ] ; then + echo "try to get another port!" + else + ns_port=$temp1 + fi + done + echo $ns_port +fi +#modify nameserver config +sed -i "s:--endpoint=[a-zA-Z0-9//.:]*:--endpoint=${IP}\:${ns_port}:" conf/nameserver.flags +sed -i "s:--role=[a-zA-Z0-9//.:]*:--role=nameserver:" conf/nameserver.flags +sed -i "s:--zk_cluster=[a-zA-Z0-9//.:]*:--zk_cluster=${IP}\:${clientPort}:" conf/nameserver.flags +sed -i "s:--zk_root_path=[a-zA-Z0-9//.:]*:--zk_root_path=/openmldb_cluster:" conf/nameserver.flags +sed -i "s:--enable_distsql=[a-zA-Z0-9//.:]*:--enable_distsql=true:" conf/nameserver.flags +sh bin/start.sh start nameserver +cd .. +echo 'nameserver Ok' +echo 'starting tabnet' +cd openmldb-tablet-2.2.0 +IP=`hostname -i` +#get available port +ns_port=9527 +PID=`lsof -i :${ns_port}|grep -v "PID" | awk '{print $2}'` +if [ "$PID" != "" ]; then + echo "ns port is unavailable; try to get another port!" + templ=0 + ns_port=0 + while [ "$ns_port" -eq 0 ]; do + temp1=`shuf -i 1024-10000 -n1` + PID=`lsof -i :${temp1}|grep -v "PID" | awk '{print $2}'` + if [ "$PID" != "" ] ; then + echo "try to get another port!" + else + ns_port=$temp1 + fi + done + echo $ns_port +fi +#modify tabnet config +sed -i "s:--endpoint=[a-zA-Z0-9//.:]*:--endpoint=${IP}\:${ns_port}:" conf/tablet.flags +sed -i "s:--role=[a-zA-Z0-9//.:]*:--role=tablet:" conf/tablet.flags +sed -i "s:--zk_cluster=[a-zA-Z0-9//.:]*:--zk_cluster=${IP}\:${clientPort}:" conf/tablet.flags +sed -i "s:--zk_root_path=[a-zA-Z0-9//.:]*:--zk_root_path=/openmldb_cluster:" conf/tablet.flags +sed -i "s:--enable_distsql=[a-zA-Z0-9//.:]*:--enable_distsql=true:" conf/tablet.flags +sh bin/start.sh start tablet +cd .. +echo 'tabnet Ok' + +echo 'employ complete' + -- Gitee