欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

TDEngine集群安装

时间:2023-05-03
1、构建镜像 1.1 entrypoint.sh

#!/bin/bashset +eulimit -c unlimitedsysctl -w kernel.core_pattern=/corefile/core-%e-%pif [ "x$TZ" != "x" ]; then ln -sf /usr/share/zoneinfo/$TZ /etc/localtimefiif [ "$TAOS_FQDN" = "" ]; then echo "TAOS_FQDN not set" exit 1fised -i "s#.*fqdn.*#fqdn ${TAOS_FQDN}#" /etc/taos/taos.cfgif [ $? -ne 0 ]; then echo "refreshing fqdn failed" exit 1fiif [ "x$TAOS_FIRST_EP" != "x" ]; then sed -i "s#.*firstEp.*#firstEp ${TAOS_FIRST_EP}#" /etc/taos/taos.cfg if [ $? -ne 0 ]; then echo "refreshing firstEp failed" exit 1 fifiif [ "x$TAOS_SERVER_PORT" != "x" ]; then sed -i "s#.*serverPort.*#serverPort ${TAOS_SERVER_PORT}#" /etc/taos/taos.cfg if [ $? -ne 0 ]; then echo "refreshing serverPort failed" exit 1 fifiCLUSTER=${CLUSTER:=}FIRST_EP_HOST=${TAOS_FIRST_EP%:*}SERVER_PORT=${TAOS_SERVER_PORT:-6030}if [ "$CLUSTER" = "" ]; then # single node $@elif [ "$TAOS_FQDN" = "$FIRST_EP_HOST" ] ; then # master node $@else # follower, wait for master node ready while true do taos -h $FIRST_EP_HOST -n startup > /dev/null if [ $? -eq 0 ]; then taos -h $FIRST_EP_HOST -s "create dnode "$TAOS_FQDN:$SERVER_PORT";" break fi sleep 1s done $@fi

1.2 Dockerfile

通过源码方式构建镜像,同时支持 AMD64 & ARM64 系统

FROM ubuntu:18.04 as builderRUN apt-get update && apt-get install -y gcc cmake build-essential git wget && apt-get clean && cd /usr/local/src && wget https://github.com/taosdata/TDengine/archive/refs/tags/ver-2.4.0.0.tar.gz && tar zxvf ver-2.4.0.0.tar.gz && cd TDengine-ver-2.4.0.0 && mkdir debug && cd debug && cmake .、&& cmake --build 、&& make installWORKDIR /rootFROM ubuntu:18.04LABEL MAINTAINER="eli.he@outlook.com>"COPY ./entrypoint.sh /usr/bin/COPY --from=0 /usr/local/taos /usr/local/taosCOPY --from=0 /etc/taos /etc/taosENV DEBIAN_FRonTEND=noninteractiveRUN apt-get update && apt-get install -y apt-utils locales tzdata curl wget net-tools iproute2 iputils-ping sysstat binutils && locale-gen en_US.UTF-8 && apt-get clean && chmod +x /usr/bin/entrypoint.sh && ln -s /usr/local/taos/bin/taos /usr/bin/taos && ln -s /usr/local/taos/bin/taosd /usr/bin/taosd && ln -s /usr/local/taos/bin/taosdump /usr/bin/taosdump && ln -s /usr/local/taos/bin/taosdemo /usr/bin/taosdemo && ln -s /usr/local/taos/bin/remove.sh /usr/bin/rmtaos && ln -s /usr/local/taos/include/taoserror.h /usr/include/taoserror.h && ln -s /usr/local/taos/include/taos.h /usr/include/taos.h && ln -s /usr/local/taos/driver/libtaos.so.2.4.0.0 /usr/lib/libtaos.so.1 && ln -s /usr/lib/libtaos.so.1 /usr/lib/libtaos.so && mkdir -p /var/lib/taos && mkdir -p /var/log/taos && chmod 777 /var/log/taosENV LC_ALL=en_US.UTF-8ENV LANG=en_US.UTF-8ENV LANGUAGE=en_US.UTF-8WORKDIR /etc/taosEXPOSE 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042CMD ["taosd"]VOLUME [ "/var/lib/taos", "/var/log/taos", "/corefile" ]ENTRYPOINT [ "/usr/bin/entrypoint.sh" ]

1.3 生成镜像

docker build -t tdengine:2.4.0.0 .

2、安装集群 2.1 创建 namespace

$ mkdir ~/taos && cd $_$ cat > taos-namespace.yml <

2.2 创建 ConfigMap

$ cat > taos-configmap.yml <

2.3 创建 PV

暂时使用本地文件系统,可换成 Ceph 等

# 1、所有节点上,挂载相应的存储盘或路径$ mkdir -p /data/tdengine# 2、创建PV$ cat > taos-pv.yml <

2.4 创建 PVC

$ cat > taos-pvc.yml <

2.5 创建 Service (无头服务)

$ cat > taos-headless.yml <

2.6 创建 StatefulSet

$ cat > taos-app.yml <

2.7 创建 Service (外部访问)

cat > taos-external-svc.yml <

3、验证 3.1 kubectl

登录到容器中,执行命令检查集群状态

$ kubectl exec -it tdengine-0 -n taos-cluster -- taos -s "show dnodes;"Welcome to the TDengine shell from Linux, Client Version:2.2.2.0Copyright (c) 2020 by TAOS Data, Inc、All rights reserved.taos> show dnodes; id | end_point | vnodes | cores | status | role | create_time | offline reason |====================================================================================================================================== 1 | tdengine-0.taosd.taos-clust..、| 0 | 2 | ready | any | 2021-11-26 02:42:25.932 | | 2 | tdengine-1.taosd.taos-clust..、| 1 | 2 | ready | any | 2021-11-26 02:42:35.633 | | 3 | tdengine-2.taosd.taos-clust..、| 1 | 2 | ready | any | 2021-11-26 02:42:48.004 | |Query OK, 3 row(s) in set (0.001099s)

3.2 restful

容器外部,使用restful接口访问,注意:容器外,无法之间使用taos客户端连接

$ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 192.168.80.240:36041/rest/sql{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-11-26 02:42:26.936",6,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"],["iec61850","2021-12-01 01:13:56.176",59,1,1,1,10,"365",16,6,100,4096,1,3000,2,0,"ms",0,"ready"]],"rows":2}$ curl -u root:taosdata -d 'show databases;' 192.168.80.240:36041/rest/sql

参考资料:

https://github.com/taosdata/TDengine-Operator 【官方 kubernetes 安装tdengine 方案】

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。