安装tdengine
大约 3 分钟
安装tdengine
下载链接
https://www.taosdata.com/assets-download/3.0/TDengine-server-3.0.4.1-Linux-x64.tar.gz
安装
wget https://www.taosdata.com/assets-download/3.0/TDengine-server-3.0.4.1-Linux-x64.tar.gz
tar -zxvf TDengine-server-3.0.4.1-Linux-x64.tar.gz
cd TDengine-server-3.0.4.1
sudo ./install.sh
安装成功
Start to install TDengine...
Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
System hostname is: ubuntu
Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
OR leave it blank to build one:mytest:6030
Enter your email address for priority support or enter empty to skip:
To configure TDengine : edit /etc/taos/taos.cfg
To configure Taos Adapter : edit /etc/taos/taosadapter.toml
To start TDengine : sudo systemctl start taosd
To start Taos Adatper : sudo systemctl start taosadapter
To access TDengine : taos -h mytest -P 6030 to login into cluster, then
execute : create dnode 'newDnodeFQDN:port'; to add this new node
TDengine is installed successfully!
启动tdengine
systemctl start taosd
systemctl start taosadapter
systemctl start taoskeeper
systemctl start taos-explorer
配置
配置
vi /etc/hostname
//将文件内容修改为node1
vi /etc/hosts
//添加一下三行
192.168.0.105 node1
配置taos.cfg
firstEp node1:6030
连接
taos -h node1-P 6030
CREATE DATABASE td_iot KEEP 360 DURATION 10 BUFFER 16 WAL_LEVEL 1;
use td_iot;
CREATE STABLE if not exists `td_iot`.`event_log` (ts TIMESTAMP,output_params NCHAR(4093),event_type TINYINT,identifier NCHAR(50),name NCHAR(50),block NCHAR(50))TAGS(product_key NCHAR(50),device_name NCHAR(50),tenant_id bigint);
CREATE STABLE if not exists `td_iot`.`service_log` (ts TIMESTAMP,message_id NCHAR(50),call_type TINYINT,identifier NCHAR(50),name NCHAR(50),code INT,result NCHAR(1024),input_params NCHAR(4093),output_params NCHAR(4093),call_from NCHAR(50),block NCHAR(50))TAGS(product_key NCHAR(50),device_name NCHAR(50),tenant_id bigint);
CREATE STABLE if not exists `td_iot`.`property_log` (ts TIMESTAMP , iot_value NCHAR(4093),block NCHAR(50))TAGS(identifier NCHAR(50),product_key NCHAR(50),device_name NCHAR(50),tenant_id bigint);
CREATE STABLE if not exists cloud_log(ts TIMESTAMP , trace_id NCHAR(50),message_id NCHAR(50),msg_content NCHAR(4093),biz_type NCHAR(50),biz_operate NCHAR(100),content NCHAR(2048),err_code INT,product_key NCHAR(50),device_name NCHAR(50))TAGS(tenant_id bigint);
CREATE STABLE if not exists local_log(ts TIMESTAMP , module NCHAR(50),trace_context NCHAR(50),code NCHAR(10),log_level NCHAR(10),log_content NCHAR(4093))TAGS(product_key NCHAR(50),device_name NCHAR(50),tenant_id bigint);
安装最新的tdengine3.3.4.3最新版本
卸载之前的版本
下载最新版本https://www.taosdata.com/assets-download/3.0/TDengine-server-3.3.4.3-Linux-x64.tar.gz
tar -zxvf TDengine-server-3.3.4.3-Linux-x64.tar.gz
cd TDengine-server-3.3.4.3
sudo ./install.sh
安装成功如下图
To configure TDengine : edit /etc/taos/taos.cfg
To configure taosadapter : edit /etc/taos/taosadapter.toml
To configure taos-explorer : edit /etc/taos/explorer.toml
To start TDengine server : sudo systemctl start taosd
To start taosAdapter : sudo systemctl start taosadapter
To start taoskeeper : sudo systemctl start taoskeeper
To start taos-explorer : sudo systemctl start taos-explorer
TDengine is updated successfully!
To start all the components : sudo start-all.sh
To access TDengine Commnd Line Interface : taos -h ubuntu
To access TDengine Graphic User Interface : http://ubuntu:6060
root@ubuntu:~/Desktop/TDengine-server-3.3.4.3# sudo start-all.sh
taosd has been started successfully
taosadapter has been started successfully
taos-explorer has been started successfully
taoskeeper has been started successfully
备份功能
#!/bin/sh
DUMP=/usr/bin/taosdump #mysqldump备份程序执行路径
OUT_DIR=/root/tdengine_data #备份文件存放路径
LINUX_USER=root #系统用户名
DB_HOST=127.0.0.1 #要备份的数据库IP
DB_NAME=td_iot #要备份的数据库名字
DB_USER=root #数据库账号 注意:非root用户要使用备份参数 --skip-lock-tables,否则可能会报错
DB_PASS=taosdata #数据库密码
DAYS=30 #DAYS=7代表要删除7天前的备份,即只保留最近7天的备份
cd $OUT_DIR #进入备份存放的目录
DATE=`date +%Y%m%d%H%M` #获取当前系统的时间,注意:date写法
OUT_SQL="$OUT_DIR_bak_$DATE" #备份数据库的文件夹
mkdir $OUT_SQL #创建文件夹
TAR_SQL="$DB_NAME_bak_$DATE.tar.gz" #最备份文件名
$DUMP -h $DB_HOST -u$DB_USER -p$DB_PASS -o $OUT_SQL -T 8 -D $DB_NAME #执行备份命令
tar -czf $TAR_SQL ./$OUT_SQL #压缩为备份数据库文件为.tar.gz格式
rm -rf $OUT_SQL #删除.sql格式的备份文件
chown $LINUX_USER:$LINUX_USER $OUT_DIR/$TAR_SQL #更改备份数据库文件的所有者
find . -mtime +7 -type f -name "*.tar.gz" -exec \rm -f {} \; #删除7天前的备份文件,注意:{} ;中间有空格:wq 保存退出
下载window链接器
https://www.taosdata.com/assets-download/3.0/TDengine-client-3.3.4.3-Windows-x64.exe