homework-jianmu/docs/en/06-advanced/06-tdgpt/02-management.md

6.8 KiB
Raw Blame History

title sidebar_label
Installation Installation

Preparing Your Environment

To use the analytics capabilities offered by TDgpt, you deploy an AI node (anode) in your TDengine cluster. Anodes run on Linux and require Python 3.10 or later.

TDgpt is supported in TDengine 3.3.6 and later. You must upgrade your cluster to version 3.3.6 or later before deploying any anodes.

You can run the following commands to install Python 3.10 in Ubuntu.

Install Python

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
sudo update-alternatives --config python3
sudo apt install python3.10-venv
sudo apt install python3.10-dev

Install pip

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

Configure Environment Variables

Add ~/.local/bin to the PATH environment variable in ~/.bashrc or ~/.bash_profile.

export PATH=$PATH:~/.local/bin

The Python environment has been installed. You can now install TDgpt.

Install TDgpt

Obtain the installation package TDengine-anode-3.3.x.x-Linux-x64.tar.gz and install it on your machine:

tar -xzvf TDengine-anode-3.3.6.0-Linux-x64.tar.gz
cd TDengine-anode-3.3.6.0
sudo ./install.sh

You can run the rmtaosanode command to uninstall TDgpt. To prevent TDgpt from affecting Python environments that may exist on your machine, anodes are installed in a virtual environment. When you install an anode, a virtual Python environment is deployed in the /var/lib/taos/taosanode/venv/ directory. All libraries required by the anode are installed in this directory. Note that this virtual environment is not uninstalled automatically by the rmtaosanode command. If you are sure that you do not want to use TDgpt on a machine, you can remove the directory manually.

Start the TDgpt Service

The taosanoded service is created when you install an anode. You can use systemd to manage this service:

systemctl start  taosanoded
systemctl stop   taosanoded
systemctl status taosanoded

Directory and Configuration Information

The directory structure of an anode is described in the following table:

Directory or File Description
/usr/local/taos/taosanode/bin Directory containing executable files
/usr/local/taos/taosanode/resource Directory containing resource files, linked to /var/lib/taos/taosanode/resource/
/usr/local/taos/taosanode/lib Directory containing libraries
/usr/local/taos/taosanode/model Directory containing models, linked to /var/lib/taos/taosanode/model
/var/log/taos/taosanode/ Log directory
/etc/taos/taosanode.ini Configuration file

Configuration

The anode provides services through an uWSGI driver. The configuration for the anode and for uWSGI are both found in the taosanode.ini file, located by default in the /etc/taos/ directory.

The configuration options are described as follows:

[uwsgi]

# Anode RESTful service ip:port
http = 127.0.0.1:6090

# base directory for Anode python files do NOT modified this
chdir = /usr/local/taos/taosanode/lib

# initialize Anode python file
wsgi-file = /usr/local/taos/taosanode/lib/taos/app.py

# pid file
pidfile = /usr/local/taos/taosanode/taosanode.pid

# conflict with systemctl, so do NOT uncomment this
# daemonize = /var/log/taos/taosanode/taosanode.log

# uWSGI log files
logto = /var/log/taos/taosanode/taosanode.log

# uWSGI monitor port
stats = 127.0.0.1:8387

# python virtual environment directory, used by Anode
virtualenv = /usr/local/taos/taosanode/venv/

[taosanode]
# default taosanode log file
app-log = /var/log/taos/taosanode/taosanode.app.log

# model storage directory
model-dir = /usr/local/taos/taosanode/model/

# default log level
log-level = INFO

:::note Do not specify a value for the daemonize parameter. This parameter causes a conflict between uWSGI and systemctl. If you enable the daemonize parameter, your anode will fail to start. :::

The configuration file above includes only the basic configuration needed for an anode to provide services. For more information about configuring uWSGI, see the official documentation.

The main configuration options for an anode are described as follows:

  • app-log: Specify the directory in which anode log files are stored.
  • model-dir: Specify the directory in which models are stored. Models are generated by algorithms based on existing datasets.
  • log-level: Specify the log level for anode logs.

Managing Anodes

You manage anodes through the TDengine CLI. The following actions must be performed within the CLI on a client that is connected to your TDengine cluster.

Create an Anode

CREATE ANODE {node_url}

The node_url parameter determines the IP address and port of the anode. This information will be registered to your TDengine cluster. Do not register a single anode to multiple TDengine clusters.

View Anodes

You can run the following command to display the FQDN and status of the anodes in your cluster:

SHOW ANODES;

taos> show anodes;
     id      |              url               |    status    |       create_time       |       update_time       |
==================================================================================================================
           1 | 192.168.0.1:6090               | ready        | 2024-11-28 18:44:27.089 | 2024-11-28 18:44:27.089 |
Query OK, 1 row(s) in set (0.037205s)

View Advanced Analytics Services

SHOW ANODES FULL;

taos> show anodes full;
     id      |            type            |              algo              |
============================================================================
           1 | anomaly-detection          | shesd                          |
           1 | anomaly-detection          | iqr                            |
           1 | anomaly-detection          | ksigma                         |
           1 | anomaly-detection          | lof                            |
           1 | anomaly-detection          | grubbs                         |
           1 | anomaly-detection          | ad_encoder                     |
           1 | forecast                   | holtwinters                    |
           1 | forecast                   | arima                          |
Query OK, 8 row(s) in set (0.008796s)

Refresh the Algorithm Cache

UPDATE ANODE {anode_id}
UPDATE ALL ANODES

Delete an Anode

DROP ANODE {anode_id}

Deleting an anode only removes it from your TDengine cluster. To stop an anode, use systemctl on the machine where the anode is located. To remove an anode, run the rmtaosanode command on the machine where the anode is located.