The influx CLI Client is a command-line interface tool for interacting with the database. You can use it to write data and perform interactive queries.
Prerequisites
2. Tencent Cloud CVM should be in the same VPC network as TencentDB for CTSDB 3.0 instance.
3. Configure outbound rules in the security group of Tencent Cloud CVM. Add the IP and port of TencentDB for CTSDB 3.0 to the outbound rules. Configure inbound rules in the security group of TencentDB for CTSDB 3.0 and add the IP and port of the CVM to the inbound rules. For operation details, see Security Group. Downloading the influx CLI Client
2. Execute tar xvfz influxdb-1.8.10_linux_amd64.tar.gz to decompress the compressed package.
Connecting to the Database
Enter the influx CLI path and execute the following command to connect to the TencentDB for CTSDB 3.0 instance.
./influx -host <DB_HOST> -port <DB_PORT> -username <USERNAME> -password <PASSWORD>
-username: a created user account.
-password: password corresponding to the user account.
-host: access address of the instance. Configure it as the private network access address of TencentDB for InfluxDB version.
-port: network port. The VPC network uses 8086.
The execution example is as follows:
./influx -host 10.0.1.7 -port 8086 -username ctsdbi-m35uo1e8 -password test@123
Using the Database
You can directly use database language to create databases, manage databases, and write data.
1. Creating a database
Execute the following statement to create a time-series database named time_series_test_db1 with permanent data retention:
CREATE DATABASE time_series_test_db1.
Execute the following statement to create a time-series database named time_series_test_db2, which enables data expiration and sets the data retention period to 30 days:
CREATE DATABASE time_series_test_db2 WITH DURATION 30d .
To query the created database, execute show databases.
2. Writing data to the database
|
1 | Designating a database | use time_series_test_db
| Using database time_series_test_db
|
2 | Inserting data | INSERT test_ctsdb,cap_id=king value=2
| - |
3 | Querying data | show measurements
| name: measurements
name
----
test_ctsdb
|