TDengine High Availability Deployment¶
1. Introduction¶
TDengine is a high-performance, distributed, SQL-supported time-series Database. Its core code, including clustering features, is fully open-sourced (open-source license, AGPL v3.0). TDengine is widely used in IoT, industrial internet, connected vehicles, IT operations, finance, and other fields. In addition to its core time-series database functionality, TDengine also provides caching, data subscription, stream computing, and other features required for big data platforms, minimizing the complexity of development and operations.
2. Prerequisites¶
- A Kubernetes cluster is deployed.
- The OpenEBS storage plugin driver is deployed.
root@k8s-node01 ]# kubectl get pods -n kube-system|grep openebs
openebs-localpv-provisioner-6b56b5567c-k5r9l 1/1 Running 0 23h
openebs-ndm-jqxtr 1/1 Running 0 23h
openebs-ndm-operator-5df6ffc98-cplgp 1/1 Running 0 23h
openebs-ndm-qtjxm 1/1 Running 0 23h
openebs-ndm-vlcrv 1/1 Running 0 23h
3. Installation Preparation¶
Since TDengine is resource-intensive and requires exclusive cluster resources, you need to configure cluster scheduling in advance.
4. Cluster Label Configuration¶
Run the command to label the cluster:
# Based on the cluster plan, label the Kubernetes nodes where TDengine will be deployed. It is recommended to use three nodes.
# xxx represents the actual node(s) in the cluster. Separate multiple nodes with spaces.
kubectl label nodes xxx tdengine=true
Verify the labeling:
5. Cluster Taint Configuration¶
Run the command to configure cluster taints.
Tips
If dedicated nodes for TDengine service are not planned, tainting nodes is not required and this step can be skipped.
6. Configure StorageClass¶
Configure a dedicated StorageClass for TDengine.
# Copy the following YAML content to the Kubernetes cluster, save it as sc-td.yaml, and modify it according to the actual situation before deploying.
apiVersion: storage.k8s.io/v1
allowVolumeExpansion: true
kind: StorageClass
metadata:
annotations:
cas.openebs.io/config: |
- name: StorageType
value: "hostpath"
- name: BasePath
value: "/data/tdengine" # This path can be modified based on actual needs. Ensure sufficient storage space and that the path exists.
name: openebs-tdengine # The name must be unique within the cluster. Modify the deployment file /etc/kubeasz/guance/infrastructure/yaml/taos.yaml accordingly before installation.
provisioner: openebs.io/local
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
Ensure the
/data/tdenginedirectory has sufficient disk capacity.
Configure storage space size:
volumeClaimTemplates:
- metadata:
name: taos-tdengine-taosdata
spec:
accessModes:
- "ReadWriteOnce"
storageClassName: "openebs-tdengine"
resources:
requests:
storage: "50Gi" ## Allocate data storage space according to actual needs.
- metadata:
name: taos-tdengine-taoslog
spec:
accessModes:
- "ReadWriteOnce"
storageClassName: "openebs-tdengine"
resources:
requests:
storage: "1Gi" ## Allocate log storage space according to actual needs.
7. Installation¶
# Create the namespace
kubectl create ns middleware
# Deploy the TDengine service
kubectl apply -f /etc/kubeasz/guance/infrastructure/yaml/taos.yaml -n middleware
8. Verify Deployment and Configuration¶
8.1 Check Container Status¶
[root@ecs-788c ~]# kubectl get pods -n middleware |grep taos
taos-tdengine-0 1/1 Running 0 5m32s
taos-tdengine-arbitrator-5bfd76b7bd-8jtmd 1/1 Running 0 5m32s
8.2 Verify Service¶
Verify TDengine service availability
# After successful installation, use the following command to log in and verify.
[root@ecs-788c ~]# kubectl exec -it -n middleware taos-tdengine-0 -- taos
Welcome to the TDengine shell from Linux, Client Version:2.6.0.18
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
********************* How to Use TAB in TAOS Shell ******************************
* Taos shell supports pressing TAB key to complete word. You can try it. *
* Press TAB key anywhere, You'll get surprise. *
* KEYBOARD SHORTCUT: *
* [ TAB ] ...... Complete the word or show help if no input *
* [ Ctrl + A ] ...... move cursor to [A]head of line *
* [ Ctrl + E ] ...... move cursor to [E]nd of line *
* [ Ctrl + W ] ...... move cursor to line of middle *
* [ Ctrl + L ] ...... clean screen *
* [ Ctrl + K ] ...... clean after cursor *
* [ Ctrl + U ] ...... clean before cursor *
* *
**********************************************************************************
taos> show mnodes;
id | end_point | role | role_time | create_time |
=============================================================================================================
1 | taos-tdengine-0.taos-tdengi... | leader | 2022-11-03 08:52:13.219 | 2022-11-03 08:52:13.219 |
Query OK, 1 row(s) in set (0.000748s)
taos> show dnodes;
id | end_point | vnodes | cores | status | role | create_time | offline reason |
======================================================================================================================================
1 | taos-tdengine-0.taos-tdengi... | 1 | 8 | ready | any | 2022-11-03 08:52:13.219 | |
0 | taos-tdengine-arbitrator | 0 | 0 | ready | arb | 2022-11-03 08:52:14.044 | - |
Query OK, 2 row(s) in set (0.000451s)
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
====================================================================================================================================================================================================================================================================================
log | 2022-11-03 08:52:14.221 | 12 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
Query OK, 1 row(s) in set (0.000493s)
taos> show users;
name | privilege | create_time | account | tags |
=======================================================================================================================
_root | writable | 2022-11-03 08:52:13.219 | root | |
monitor | writable | 2022-11-03 08:52:13.219 | root | |
root | super | 2022-11-03 08:52:13.219 | root | |
Query OK, 3 row(s) in set (0.000691s)
8.3 Cluster Scaling¶
Note
Optional. Determine whether scaling is needed based on actual resource planning.
[root@ecs-788c ~]# kubectl scale --replicas=3 -n middleware statefulset taos-tdengine
statefulset.apps/taos-tdengine scaled
Verify scaling success
[root@ecs-788c ~]# kubectl exec -it -n middleware taos-tdengine-0 -- taos -uroot
Welcome to the TDengine shell from Linux, Client Version:2.6.0.18
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
********************* How to Use TAB in TAOS Shell ******************************
* Taos shell supports pressing TAB key to complete word. You can try it. *
* Press TAB key anywhere, You'll get surprise. *
* KEYBOARD SHORTCUT: *
* [ TAB ] ...... Complete the word or show help if no input *
* [ Ctrl + A ] ...... move cursor to [A]head of line *
* [ Ctrl + E ] ...... move cursor to [E]nd of line *
* [ Ctrl + W ] ...... move cursor to line of middle *
* [ Ctrl + L ] ...... clean screen *
* [ Ctrl + K ] ...... clean after cursor *
* [ Ctrl + U ] ...... clean before cursor *
* *
**********************************************************************************
taos> show dnodes;
id | end_point | vnodes | cores | status | role | create_time | offline reason |
======================================================================================================================================
1 | taos-tdengine-0.taos-tdengi... | 0 | 8 | ready | any | 2022-11-03 09:46:02.087 | |
2 | taos-tdengine-1.taos-tdengi... | 0 | 8 | ready | any | 2022-11-03 09:46:40.592 | |
3 | taos-tdengine-2.taos-tdengi... | 1 | 8 | ready | any | 2022-11-03 09:49:44.772 | |
0 | taos-tdengine-arbitrator | 0 | 0 | ready | arb | 2022-11-03 09:46:02.905 | - |
Query OK, 4 row(s) in set (0.000708s)
taos> show mnodes;
id | end_point | role | role_time | create_time |
=============================================================================================================
1 | taos-tdengine-0.taos-tdengi... | leader | 2022-11-03 09:46:02.087 | 2022-11-03 09:46:02.087 |
2 | taos-tdengine-1.taos-tdengi... | follower | 2022-11-03 09:47:02.166 | 2022-11-03 09:46:53.208 |
3 | taos-tdengine-2.taos-tdengi... | follower | 2022-11-03 09:50:02.214 | 2022-11-03 09:49:57.378 |
Query OK, 3 row(s) in set (0.000542s)
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
====================================================================================================================================================================================================================================================================================
log | 2022-11-03 09:46:03.089 | 24 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
Query OK, 1 row(s) in set (0.000449s)
[root@ecs-788c ~]# kubectl get pods -n middleware |grep taos
taos-tdengine-0 1/1 Running 0 41m
taos-tdengine-1 1/1 Running 0 41m
taos-tdengine-2 1/1 Running 0 40m
taos-tdengine-arbitrator-5bfd76b7bd-925wf 1/1 Running 0 41m
8.4 User Management¶
System administrators can add, delete users, and modify passwords in the CLI interface. The SQL syntax in the CLI is as follows:
Create a user with a specified username and password. The password must be enclosed in single quotes (half-width English single quotes).
Delete a user. This command is restricted to the root user.
Modify the user password. To prevent conversion to lowercase, the password must be enclosed in single quotes (half-width English single quotes).
Modify the user privilege to write or read. Do not include single quotes.
Note
The system has three privilege levels: super/write/read. However, the super privilege cannot be granted to a user via the alter command.
Display all users.
In the SQL syntax, < > indicates a part that requires user input, but do not include < > themselves.
8.4.1 Account Management¶
# Create a new account
taos> CREATE USER zhuyun PASS 'dfjdljf12341@3$';
Query OK, 0 of 0 row(s) in database (0.002040s)
# Modify account privileges
taos> ALTER USER zhuyun PRIVILEGE write;
# Modify account password
taos> ALTER USER zhuyun PASS 'hjdkaGHJH123#';
Query OK, 0 of 0 row(s) in database (0.001996s)
8.4.2 Verify User¶
Verify TDengine service availability
[root@ecs-788c ~]# kubectl exec -it -n middleware taos-tdengine-0 -- taos -u zhuyun -p
Welcome to the TDengine shell from Linux, Client Version:2.6.0.18
Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
Enter password:
********************* How to Use TAB in TAOS Shell ******************************
* Taos shell supports pressing TAB key to complete word. You can try it. *
* Press TAB key anywhere, You'll get surprise. *
* KEYBOARD SHORTCUT: *
* [ TAB ] ...... Complete the word or show help if no input *
* [ Ctrl + A ] ...... move cursor to [A]head of line *
* [ Ctrl + E ] ...... move cursor to [E]nd of line *
* [ Ctrl + W ] ...... move cursor to line of middle *
* [ Ctrl + L ] ...... clean screen *
* [ Ctrl + K ] ...... clean after cursor *
* [ Ctrl + U ] ...... clean before cursor *
* *
**********************************************************************************
taos> show users;
name | privilege | create_time | account | tags |
=======================================================================================================================
_root | writable | 2022-11-03 08:52:13.219 | root | |
monitor | writable | 2022-11-03 08:52:13.219 | root | |
zhuyun | writable | 2022-11-03 09:06:41.294 | root | |
root | super | 2022-11-03 08:52:13.219 | root | |
Query OK, 4 row(s) in set (0.000730s)