Get Started with TDengine TSDB Using an Installation Package
You can install TDengine TSDB Enterprise on Linux and Windows. To install TDengine TSDB in a Docker container instead of on your machine, see Get Started with TDengine in Docker.
Before You Begin
- Verify that your machine meets the minimum system requirements for TDengine TSDB. For more information, see Supported Platforms and System Requirements.
- (Windows only) Verify that the latest version of the Microsoft Visual C++ Redistributable is installed on your machine. To download the redistributable package, see Microsoft Visual C++ Redistributable latest supported downloads.
Procedure
- Linux
- Windows
- Download the tar.gz installation package from the list below:
- Navigate to the directory where the package is located and extract it using
tar. For example, on an x64 architecture:tar -zxvf tdengine-tsdb-enterprise-3.3.8.1-linux-x64.tar.gz - After extracting the files, go into the subdirectory and run the
install.shscript:sudo ./install.sh
- Download the Windows installation package from the list below:
- Run the installation package and follow the on-screen instructions to complete the installation of TDengine TSDB.
For more package types and versions, visit the TDengine Download Center.
Start the Service
- Linux
- Windows System
After installation, execute the following command in your terminal to start all services:
start-all.sh
All TDengine TSDB components are managed by systemd. You can check their service status with the following commands:
sudo systemctl status taosd
sudo systemctl status taosadapter
sudo systemctl status taoskeeper
sudo systemctl status taos-explorer
If the output shows the status as Active: active (running) since ..., it means the services have started successfully.
After installation, open a terminal as administrator and run the following command to start all services:
C:\TDengine\start-all.bat
You can check the status of each service using:
sc query taosd
sc query taosadapter
sc query taoskeeper
sc query taos-explorer
If the output shows RUNNING, it means the services have started successfully.
Quick Start
TDengine TSDB CLI
To easily check the status of TDengine TSDB and perform various ad-hoc database queries, TDengine TSDB provides a command-line interface. To enter the TDengine CLI, simply execute taos (on Linux/Mac) or taos.exe (on Windows) in your terminal. The prompt appears as:
taos>
In the TDengine TSDB CLI, you can use SQL commands to create or delete databases and tables, as well as perform data insertion and query operations. Each SQL statement executed in the terminal must end with a semicolon (;). For example:
CREATE DATABASE demo;
USE demo;
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)
You can also use the TDengine TSDB CLI to monitor system status, manage users, and perform administrative tasks.
The CLI and client drivers can be installed separately on other machines. For more details, see TDengine CLI Reference.
Data Ingestion
taosBenchmark is a tool designed to evaluate TDengine’s performance in data ingestion, querying, and subscription. It can simulate data generated by numerous devices, allowing flexible configuration of database, supertable, tag columns, data columns, subtable counts, record counts, data intervals, number of threads, and whether to include out-of-order data.
To use taosBenchmark, ensure that TDengine is installed and running, and then execute the following command:
taosBenchmark -y
This automatically creates a database named test containing a supertable named meters. Within the supertable, 10,000 subtables named d0 through d9999 are generated, each containing 10,000 records. Each record has four fields: ts (timestamp), current, voltage, and phase, with timestamps ranging from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table also contains two tags: location and groupId, where groupId ranges from 1 to 10 and location includes cities in California such as California.Campbell and California.Cupertino.
After executing the taosBenchmark command, the system quickly writes 100 million records. The time required depends on your hardware, but on an average server, this process typically takes only a few seconds.
To customize testing parameters such as table counts or record numbers, taosBenchmark provides a wide range of options. To see all available parameters, run the following command:
taosBenchmark --help
For detailed usage instructions, see taosBenchmark Reference.
Data Querying
After inserting data with taosBenchmark, you can run the following queries in the TDengine CLI to verify query performance.
Count total records in the supertable meters:
SELECT COUNT(*) FROM test.meters;
Calculate the average, maximum, and minimum of all records:
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
Count records where location = California.SanFrancisco:
SELECT COUNT(*) FROM test.meters WHERE location = "California.SanFrancisco";
Query the average, maximum, and minimum for all records where groupId = 10:
SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
Aggregate table d1001 in 10-second intervals and compute averages, maxima, and minima:
SELECT _wstart, AVG(current), MAX(voltage), MIN(phase) FROM test.d1001 INTERVAL(10s);
In the above query, the pseudocolumn _wstart represents the start time of each aggregation window.
TDengine TSDB Explorer
TDengine TSDB Explorer is a web-based interface that allows you to manage and interact with TDengine directly from your browser.
To use TDengine TSDB Explorer, access its address in a web browser. The default port is 6060. For example, if TDengine is running locally, visit http://localhost:6060.
Enter your username and password and click Login. The default username is root and password taosdata.
If you have not logged in to TDengine TSDB Explorer before, you must register first. Enter your name and email address and click Get verification code. Then enter the verification code sent to your email address and click Submit.
After logging in, the Explorer page is displayed, where you can view databases, supertables, subtables, and run SQL queries.
On the Programming page, you can view client library examples for various programming languages, all of which can be executed directly via copy/paste.
The Tools page lists visualization tools that integrate with TDengine such as Grafana and Power BI. You can follow the on-screen guidance to create dashboards and reports easily.
Click the ? icon in the upper-right corner of the interface to access the TDengine documentation. This is installed locally and does not require an internet connection.
Integration with Grafana
Grafana is a popular open-source platform for data visualization and monitoring. TDengine integrates seamlessly with Grafana to create dashboards and alert systems, all without writing a single line of code. The example below uses smart meter data generated by taosBenchmark to create a panel that displays current fluctuations.
Prerequisites
-
Install and start Grafana (version 7.5 or above is supported).
-
Insert test data using the following command, which creates a supertable meters in the test database with 100 subtables, each containing 1,000 records starting from one hour ago:
taosBenchmark --start-timestamp=$(date --date="1 hours ago" +%s%3N) \
--time-step=1000 --records=1000 \
--tables=100 --answer-yes
Install the Grafana Plugin
Communication between Grafana and TDengine is handled via the TDengine Datasource plugin.
On Linux, you can install the plugin by running the following command:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/taosdata/grafanaplugin/master/install.sh)"
For other platforms, refer to the plugin installation guide.
After installation, restart the Grafana service:
sudo systemctl restart grafana-server.service
Create a Connection
In Grafana, go to Connections > Add new connection, search for TDengine, and click Add new data source.
Configure the data source as follows:
- TDengine Host: Enter the address and port of your taosAdapter. For local setups, use
http://localhost:6041. - TDengine Authentication: Use the database’s username and password authentication (default: root/taosdata).
Click Save & test. If you see the message TDengine Data source is working, the connection is successful.
Create a Dashboard
Select Dashboards > New and click Add a new panel. Choose the TDengine data source that you configured earlier.
In the Input SQL field, enter the following query and click Apply. This displays the average variation of the current column:
SELECT _wstart AS ts, avg(voltage) AS voltage, avg(phase) AS phase FROM test.meters
WHERE groupid =1 and ts > $from AND ts < $to interval($interval) fill(null)
For more details, see Grafana.
Zero-Code Data Ingestion
TDengine TSDB can ingest data from various sources, including PI System, OPC, InfluxDB, MQTT, Kafka, CSV, MySQL, PostgreSQL, Oracle, and MongoDB.
The following example shows how to create an MQTT data ingestion task to subscribe to data from an MQTT broker and write it into TDengine.
Configure Basic Task Information
-
In a web browser, access TDengine TSDB Explorer.
-
From the main menu on the left, select Data In.
-
On the Data In Task tab, click + Add Source to open the task configuration page.
-
Configure the MQTT task as follows:
- Name: Enter a unique name for the data ingestion task.
- Type: Select MQTT.
- Agent: Leave this field blank.
- Target: Click + Create Database, enter
test-mqttas the name, and click Create.
-
Configure the connection and authentication:
- MQTT Host:
broker.emqx.io - Port:
1883 - TLS Verification: Disable
- Username/Password: Leave these fields blank.
- MQTT Host:
-
Configure MQTT protocol settings:
- MQTT Protocol Version: 3.1
- Client ID: Enter a unique ID for the data ingestion task.
- Topics QoS Config: Must be separated by two colons, e.g.
tdengine-topic1::0 - Retain the default value for all other settings.
-
Click Check Connectivity. If the message
Your data source is reachableappears, the connection is successful. -
Configure payload transformation:
- Enter the following JSON sample representing smart meter readings (voltage, current, and phase) for meter ID 1 in Beijing:
{ "id": 1, "current": 10.42, "phase": 1.38, "voltage":200, "groupid": 7, "location": "beijing" }-
Click the Preview icon on the right to preview parsing results.
-
Under Mapping, create a supertable with the following schema:
Columns:
Data Type Name TIMESTAMP ts INT id DOUBLE current DOUBLE phase INT voltage Tags:
Data Type Name INT groupid VARCHAR(128) location After creating and selecting the supertable, click Submit.
-
Your task is now displayed in the Data In Task list. When its status changes to Running, data from the MQTT topic will be consumed and written into TDengine TSDB automatically.
Send Test Data
You can use the MQTT client tool MQTTX to send test data. For more information, see the documentation.
Use the same broker and topic configuration as your MQTT task:
- Broker Address: broker.emqx.io
- Port: 1883
- Topic: tdengine-topic1
- Sample Data:
{ "id": 1, "current": 10.42, "phase": 1.38, "voltage":200, "groupid": 7, "location": "beijing" }
Verify Data
After sending test data, you can check whether it has been successfully written to TDengine TSDB. In TDengine TSDB Explorer, run the following SQL statement:
SELECT * FROM `test-mqtt`.`meters`;
If data is returned, it confirms successful ingestion.
You can also view the task’s running status, ingestion rate, and error logs on the Data In page.
What to Do Next
After completing this quick start, you can continue exploring TDengine’s advanced capabilities and features.