TDengine集群安装

一、安装包下载:

1、下载TDengine-server-2.0.20.12-Linux-x64.tar.gz
下载地址:https://www.taosdata.com/cn/all-downloads/

二、集群安装

1、安装环境 centos7.7,我们准备了两台服务器安装,一台mnode节点,一台nnode节点
2、hostname配置(h1.wxx.com为mnode),两台服务器都要配置,这里的Ip是云服务器的内网ip

192.168.1.20 h1.wxx.com
192.168.1.21 h2.wxx.com

3、创建数据存储路径data和log目录(两台服务器都要创建)

cd /data
mkdir tdengine
cd tdengine
mkdir data
mkdir log

3、将包上传至服务器/data目录

cd /data
tar xvf TDengine-server-2.0.20.12-Linux-x64.tar.gz
cd TDengine-server-2.0.20.12
./install.sh

重点说明:
mnode节点安装,一路回车,不输入任务内容
nnode节点安装时,提示是否加入其余他节点,输入

h1.wxx.com:6030

4、taos.cfg配置文件修改,两台服务器配置不同的就是fqdn参数
mnode节点

firstEp                   h1.wxx.com:6030
fqdn                      h1.wxx.com
serverPort                6030
logDir                    /data/tdengine/log
dataDir                  /data/tdengine/data

nnode节点

firstEp                   h1.wxx.com:6030
fqdn                      h2.wxx.com
serverPort                6030
logDir                    /data/tdengine/log
dataDir                  /data/tdengine/data

5、创建启动脚本,时间长了,命令容易忘

cd /data/tdengine
vi mystart.sh

插入

systemctl start taosd

6、启动

sh mystart.sh
systemctl status taosd

显示如下,表示成功

[root@server06 tdengine]# systemctl status taosd
● taosd.service - TDengine server service
   Loaded: loaded (/etc/systemd/system/taosd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-08-10 14:57:22 CST; 9s ago
  Process: 330 ExecStartPre=/usr/local/taos/bin/startPre.sh (code=exited, status=0/SUCCESS)
 Main PID: 339 (taosd)
   CGroup: /system.slice/taosd.service
           └─339 /usr/bin/taosd

Aug 10 14:57:22 server06 systemd[1]: Starting TDengine server service...
Aug 10 14:57:22 server06 systemd[1]: Started TDengine server service.
Aug 10 14:57:22 server06 TDengine:[339]: Starting TDengine service...
Aug 10 14:57:22 server06 TDengine:[339]: Started TDengine service successfully.

7、针对云服务器,开放端口,同时要开放TCP的6030端口,UDP的6030端口,客户端才可以访问

三、验证数据库可用

1、查看集群相关节点,用taos命令进入命令窗口

taos> show dnodes;
   id   |           end_point            | vnodes | cores  |   status   | role  |       create_time       |      offline reason      |
======================================================================================================================================
      1 | h1.wxx.com:6030             |      0 |      8 | ready      | any   | 2021-08-10 11:33:02.299 |                          |
      2 | h2.wxx.com:6030             |      2 |      8 | ready      | any   | 2021-08-10 11:38:29.550 |                          |
Query OK, 2 row(s) in set (0.000641s)

taos> show mnodes;
   id   |           end_point            |     role     |       create_time       |
===================================================================================
      1 | h1.wxx.com:6030             | master       | 2021-08-10 11:33:02.299 |
Query OK, 1 row(s) in set (0.000529s)

2、建库,建表

create database db;
use db;
create table t (ts timestamp, speed int);
insert into t values ('2019-07-15 00:00:00', 10);
insert into t values ('2019-07-15 01:00:00', 20);
select * from t;
           ts            |    speed    |
========================================
 2019-07-15 00:00:00.000 |          10 |
 2019-07-15 01:00:00.000 |          20 |
Query OK, 2 row(s) in set (0.003128s)
四、客户端的使用

1、客户端下载(注:客户端与服务器端版本必须保持一至)
包名为:TDengine-client-2.0.20.12-Windows-x64.exe
下载地址:https://www.taosdata.com/cn/all-downloads/
2、直接双击安装,默认安装到了C:\TDengine目录,
3、编辑C:\TDengine\taos.cfg配置
关键配置如下:

firstEp                   h1.wxx.com:6030

4、修改C:\Windows\System32\drivers\etc\hosts,加入(这里是云服务器的外网ip)

120.63.178.133  h1.wxx.com
120.63.254.178  h2.wxx.com

5、使用

C:\TDengine>taos.exe

Welcome to the TDengine shell from Linux, Client Version:2.0.20.12
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.

taos> show databases;
              name              |      created_time       |   ntables   |   vgroups   | replica | quorum |  days  |   keep0,keep1,keep(D)    |  cache(MB)  |   blocks    |   minrows   |   maxrows   | wallevel |    fsync    | comp | cachelast | precision | update |   status   |
====================================================================================================================================================================================================================================================================================
 demo                           | 2021-08-10 11:41:30.773 |           1 |           1 |       1 |      1 |     10 | 3650,3650,3650           |          16 |           6 |         100 |        4096 |        1 |        3000 |    2 |         0 | ms        |      0 | ready      |
 log                            | 2021-08-10 11:33:03.301 |           5 |           1 |       1 |      1 |     10 | 30,30,30                 |           1 |           3 |         100 |        4096 |        1 |        3000 |    2 |         0 | us        |      0 | ready      |
Query OK, 2 row(s) in set (0.149000s)

taos> use demo;
Query OK, 0 of 0 row(s) in database (0.016000s)

taos> select * from t;
           ts            |    speed    |
========================================
 2019-07-15 00:00:00.000 |          10 |
 2019-07-15 01:00:00.000 |          20 |
Query OK, 2 row(s) in set (0.132000s)

taos>

你可能感兴趣的:(TDengine,TDengine集群安装)