云原生TDengine-v3.0部署手册
- 一、管理namespace
- 1.1 创建namespace
- 1.2 namespaces列表
- 二、配置3份yaml文件
- 2.1 tdengine3-storage-class.yaml
- 2.2 taosd-service.yaml
- 2.3 taosd-tdengine.yaml
- 三、服务部署
- 3.1 部署StorageClass
- 3.2 部署Service
- 3.3 部署StatefulSet
- 3.4 查看启动日志
- 四、TDengine功能验证
- 4.1 验证:创建、查询
- 4.2 三副本节点功能验证
一、管理namespace
1.1 创建namespace
kubectl create namespace taos
1.2 namespaces列表
kubectl get namespaces -o wide
二、配置3份yaml文件
2.1 tdengine3-storage-class.yaml
创建name
=tdengine3-storage-class
、namespace
=taos
的存储类名
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: tdengine3-storage-class
namespace: taos
provisioner: diskplugin.csi.alibabacloud.com
2.2 taosd-service.yaml
创建name
=taosd
、 namespace
=taos
、app
=tdengine
的Service
---
apiVersion: v1
kind: Service
metadata:
name: "taosd"
namespace: "taos"
labels:
app: "tdengine"
spec:
ports:
- name: tcp6030
protocol: "TCP"
port: 6030
- name: tcp6041
protocol: "TCP"
port: 6041
selector:
app: "tdengine"
2.3 taosd-tdengine.yaml
创建StatefulSet服务,需要关注以下参数与上述步骤设置的参数一致
- name: “tdengine”
- namespace: “taos”
- storage: “20Gi”(磁盘alicloud-disk-efficiency最低20Gi才能分配成功)
- storageClassName: “tdengine3-storage-class”
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: "tdengine"
namespace: "taos"
labels:
app: "tdengine"
spec:
serviceName: "taosd"
replicas: 3
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
app: "tdengine"
template:
metadata:
name: "tdengine"
labels:
app: "tdengine"
spec:
containers:
- name: "tdengine"
image: "tdengine/tdengine:3.0.0.0"
imagePullPolicy: "IfNotPresent"
ports:
- name: tcp6030
protocol: "TCP"
containerPort: 6030
- name: tcp6041
protocol: "TCP"
containerPort: 6041
env:
# POD_NAME for FQDN config
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
# SERVICE_NAME and NAMESPACE for fqdn resolve
- name: SERVICE_NAME
value: "taosd"
- name: STS_NAME
value: "tdengine"
- name: STS_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# TZ for timezone settings, we recommend to always set it.
- name: TZ
value: "Asia/Shanghai"
# TAOS_ prefix will configured in taos.cfg, strip prefix and camelCase.
- name: TAOS_SERVER_PORT
value: "6030"
# Must set if you want a cluster.
- name: TAOS_FIRST_EP
value: "$(STS_NAME)-0.$(SERVICE_NAME).$(STS_NAMESPACE).svc.cluster.local:$(TAOS_SERVER_PORT)"
# TAOS_FQND should always be set in k8s env.
- name: TAOS_FQDN
value: "$(POD_NAME).$(SERVICE_NAME).$(STS_NAMESPACE).svc.cluster.local"
volumeMounts:
- name: taosdata
mountPath: /var/lib/taos
readinessProbe:
exec:
command:
- taos-check
initialDelaySeconds: 5
timeoutSeconds: 5000
livenessProbe:
exec:
command:
- taos-check
initialDelaySeconds: 15
periodSeconds: 20
volumeClaimTemplates:
- metadata:
name: taosdata
spec:
accessModes:
- "ReadWriteOnce"
storageClassName: "tdengine3-storage-class"
resources:
requests:
storage: "20Gi"
三、服务部署
3.1 部署StorageClass
Kubectl apply -f tdengine3-storage-class.yaml
3.2 部署Service
kubectl apply -f taosd-service.yaml
3.3 部署StatefulSet
kubectl apply -f tdengine.yaml
3.4 查看启动日志
kubectl exec -it tdengine-0 -- tail -f /var/log/taos/taosdlog.0
四、TDengine功能验证
4.1 验证:创建、查询
taos> show dnodes;
id | endpoint | vnodes | support_vnodes | status | create_time | note |
=================================================================================================================================================
1 | tdengine-0.taosd.tdengine.s... | 0 | 4 | ready | 2023-07-08 15:47:02.133 | |
2 | tdengine-1.taosd.tdengine.s... | 0 | 4 | ready | 2023-07-08 15:48:27.335 | |
3 | tdengine-2.taosd.tdengine.s... | 0 | 4 | ready | 2023-07-08 15:50:36.168 | |
Query OK, 3 rows in database (0.006285s)
taos> create database if not exists test replica 3;
Query OK, 0 of 0 rows affected (6.147246s)
taos> create table if not exists t1(ts timestamp, n int);
Query OK, 0 of 0 rows affected (0.014969s)
taos> insert into t1 values(now, 1)(now+1s, 2);
Query OK, 2 of 2 rows affected (0.016294s)
taos> select * from t1;
ts | n |
========================================
2023-07-08 17:37:11.969 | 1 |
2023-07-08 17:37:12.969 | 2 |
2023-07-08 17:37:13.452 | 1 |
2023-07-08 17:37:14.170 | 1 |
2023-07-08 17:37:14.452 | 2 |
2023-07-08 17:37:14.775 | 1 |
2023-07-08 17:37:15.170 | 2 |
2023-07-08 17:37:15.397 | 1 |
2023-07-08 17:37:15.775 | 2 |
2023-07-08 17:37:15.870 | 1 |
2023-07-08 17:37:16.220 | 1 |
2023-07-08 17:37:16.397 | 2 |
2023-07-08 17:37:16.546 | 1 |
2023-07-08 17:37:16.828 | 1 |
2023-07-08 17:37:16.870 | 2 |
2023-07-08 17:37:17.154 | 1 |
2023-07-08 17:37:17.220 | 2 |
2023-07-08 17:37:17.546 | 2 |
2023-07-08 17:37:17.828 | 2 |
2023-07-08 17:37:18.154 | 2 |
Query OK, 20 rows in database (0.008757s)
4.2 三副本节点功能验证
当在三副本的集群中创建二副本的数据库会有错误提示:
taos> create database if not exists test_0 replica 2;
DB error: Invalid option replications: 2, only 1, 3 allowed (0.000204s)