docker TDEngine 集群搭建(3.0.1.5)
使用docker搭建tdengine集群,值得参考
·
1 server端配置
step1 start temp container
docker run -d --name td -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine:3.0.1.5
step2 set hostname
hostnamectl set-hostname taosnode1
hostnamectl
step3 create folder
mkdir -p /home/docker-compose/tdengine/etc/{node1etc,node2etc,node3etc}
step4 copy taos.cfg
docker cp td:/etc/taos/taos.cfg /home/docker-compose/tdengine/etc/node1etc/
docker cp td:/etc/taos/taos.cfg /home/docker-compose/tdengine/etc/node2etc/
docker cp td:/etc/taos/taos.cfg /home/docker-compose/tdengine/etc/node3etc/
docker rm -f td
step5 config taos.cfg
- node1etc
vim /home/docker-compose/tdengine/etc/node1etc/taos.cfg
#内容如下:
# The end point of the first dnode in the cluster to be connected to when `taosd` or `taos` is started
firstEp taosnode1:6030
# The end point of the second dnode to be connected to if the firstEp is not available when `taosd` or `taos` is started
secondEp taosnode1:6030
# The FQDN of the host where `taosd` will be started. It can be IP address
fqdn taosnode1
# The port for external access after `taosd` is started
serverPort 6030
timezone Asia/Shanghai (CST, +0800)
- node2etc
vim /home/docker-compose/tdengine/etc/node2etc/taos.cfg
#内容如下:
# The end point of the first dnode in the cluster to be connected to when `taosd` or `taos` is started
firstEp taosnode1:6030
# The end point of the second dnode to be connected to if the firstEp is not available when `taosd` or `taos` is started
secondEp taosnode2:7030
# The FQDN of the host where `taosd` will be started. It can be IP address
fqdn taosnode2
# The port for external access after `taosd` is started
serverPort 7030
timezone Asia/Shanghai (CST, +0800)
- node3etc
vim /home/docker-compose/tdengine/etc/node3etc/taos.cfg
#内容如下:
# The end point of the first dnode in the cluster to be connected to when `taosd` or `taos` is started
firstEp taosnode1:6030
# The end point of the second dnode to be connected to if the firstEp is not available when `taosd` or `taos` is started
secondEp taosnode2:7030
# The FQDN of the host where `taosd` will be started. It can be IP address
fqdn taosnode3
# The port for external access after `taosd` is started
serverPort 8030
timezone Asia/Shanghai (CST, +0800)
step6 create docker-compose.yml
cd /home/docker-compose/tdengine
touch docker-compose.yml
填充内容如下:
version: "3"
services:
taosnode1:
#开机自启
restart: always
#指定镜像
image: tdengine/tdengine:3.0.1.5
#指定容器hostname
hostname: taosnode1
#容器名称
container_name: taosnode1
#创建容器后默认执行的命令
privileged: true
#容器的映射端口
ports:
- 6020:6020
- 6030-6042:6030-6042/tcp
- 6030-6042:6030-6042/udp
#定义挂载点
volumes:
- ./etc/node1etc/taos.cfg:/etc/taos/taos.cfg:ro
- taosdata-td1:/var/lib/taos/
- taoslog-td1:/var/log/taos/
taosnode2:
restart: always
image: tdengine/tdengine:3.0.1.5
hostname: taosnode2
container_name: taosnode2
privileged: true
ports:
- 7020:7020
- 7030-7042:7030-7042/tcp
- 7030-7042:7030-7042/udp
volumes:
- ./etc/node2etc/taos.cfg:/etc/taos/taos.cfg:ro
- taosdata-td2:/var/lib/taos/
- taoslog-td2:/var/log/taos/
taosnode3:
restart: always
image: tdengine/tdengine:3.0.1.5
hostname: taosnode3
container_name: taosnode3
privileged: true
ports:
- 8020:8020
- 8030-8042:8030-8042/tcp
- 8030-8042:8030-8042/udp
volumes:
- ./etc/node3etc/taos.cfg:/etc/taos/taos.cfg:ro
- taosdata-td3:/var/lib/taos/
- taoslog-td3:/var/log/taos/
volumes:
taosdata-td1:
taoslog-td1:
taosdata-td2:
taoslog-td2:
taosdata-td3:
taoslog-td3:
step7 start service
cd /home/docker-compose/tdengine
docker-compose up -d
step8 add data node
docker-compose exec taosnode1 bash
taos;
create dnode "taosnode2:7030";
create dnode "taosnode3:8030";
show dnodes;
show mnodes;
setp9 服务端hosts配置
vim /etc/hosts
#添加一行
127.0.0.1 taosnode1 taosnode2 taosnode3
2. 客户端配置
9、客户端连接配置
# 在C:\Windows\System32\drivers\etc\hosts文件中localhost name resolution is handled within DNS itself.下添加:
# 10.0.31.2 taosnode1 taosnode2 taosnode3
# 客户端下载地址:https://www.taosdata.com/cn/getting-started/#Quick%20Start
# 客户端下载之后直接安装即可,默认路径C:\TDengine
# 修改C:\TDengine\cfg\taos.cfg,设置firstEp为taosnode1:6030,secondEp为taosnode2:7030
# 设置secondEp主要是为了防止taosnode1节点宕机后无法连接集群
# C:\TDengine中cmd启动客户端,输入taos连接集群
10、vnode的高可用
# create database testdb replica n; 创建数据库并设置副本数,n代表几个副本;
# n可以配置为1-3,但不能超过节点数;
# 当一个vnode group里一半或以上的vnode不工作时,不能对外提供服务;
# 默认replica为1,此时集群不具备vnode高可用,若想高可用,大于等于2;
11、mnode的高可用
# mnode的副本数,由系统配置参数numOfMnodes决定,有效范围1-3,且小于等于集群节点数;
# 当一半或以上mnode不工作时,集群不对外工作;
# 为保证mnode的高可用性,numOfMnodes必须设置为2或3,默认为3;
12、负载均衡
# 触发情况:下面这三种情况将自动触发负载均衡,不须人工干预
# 1、当一个新数据节点添加进集群时;
# 2、当一个数据节点从集群中移除时;
# 3、一个数据节点过热(数据量过大);
13、Arbitrator
# 为什么要用Arbitrator:
# 如果副本数为偶数,当一个vnode group里一半的vnode不工作时,是无法从中选出master的。
# 同理,一个mnode组里一半的mnode不工作时,也是无法选出mnode的master的。
# 因为存在“split brain”的问题;
# Arbitrator的作用
# Arbitrator是一个可执行程序,模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。
# 比如:对于副本数位2的情况,如果一个节点A离线,但另外一个节点B正常,如果没有Arbitrator,那么节点B也不能对外工作,
# 但如果能连接到Arbitrator,那么节点B就能正常工作
更多推荐
已为社区贡献1条内容
所有评论(0)