2, Installation, deployment, basic usage
1. Installation and startup
(2) Suppose our server is CentOS, execute the following command to download rpm File:
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.2.x86_64.rpm
(3) After downloading, execute the following command to install:
sudo yum localinstall influxdb-1.8.2.x86_64.rpm
(4) After installation, execute the following command to start InfluxDB:
systemctl start influxdb
(5) Finally, you can execute the following command to set it as startup:
systemctl enable influxdb
2. Connect to InfluxDB
InfluxDB After the installation runs, we execute influx Command to connect to local InfluxDB On the instance:
explain:
- InfluxDB of HTTP The interface starts on by default eight thousand and eighty-six Come on, so influx The default is even the local 8086 port
- -precision The parameter indicates the format and precision of any returned timestamp. In the above example, rfc3339 Is let InfluxDB return RFC339 Timestamp of format (yyyy-mm-ddthh: mm: SS. Nnnnnz).
influx -precision rfc3339
3. Operation database
Description: the name of the database can be any name enclosed in double quotation marks Unicode Character. If the name contains only ASCII Letters, numbers, or underscores that do not begin with numbers can also be avoided.
CREATE DATABASE mydb
(2) Execute the following command to display all current databases:
SHOW DATABASES
(3) Execute the following command to delete the specified database:
DROP DATABASE mydb
(4) Execute the following command to use the specified database:
USE mydb
4. Insert data (new table)
- For example, we execute the following command to transfer a single piece of time series data to InfluxDB Yes. Such a measurement by temperature,tag yes machine and type,external Value is 25,internal Value is thirty-seven The data point of is written InfluxDB Medium:
Note: field values It can be integer, floating point number, string and Boolean value. See the appendix at the end of this article for the insertion specifications of different types of data.
INSERT temperature,machine=unit42,type=assembly external=25,internal=37
- The system will automatically add a timestamp to the above statement. Of course, we can also write the timestamp ourselves when adding data:
INSERT temperature,machine=unit42,type=assembly external=25,internal=37 1435362189575692182
(2) Execute the following command to display all tables:
SHOW MEASUREMENTS
(3) The specified table can be deleted by executing the following command:
DROP MEASUREMENT temperature
5. Query data
SELECT "machine", "type", "external", "internal" FROM "temperature"
(2) If you want to return all fields and tag, you can use *:
SELECT * FROM "temperature"
Attachment: Specifications for inserting various types of field values
differ tag keys,tag values,field keys Always a string, field values Can be integers, floating point numbers, strings, and Booleans.
1. Floating point number
The default is floating point number, incluxdb Assume all received field value All floating point numbers.
// Store 82 in floating point type: INSERT temperature,machine=unit42,type=assembly external=82 1435362189575692182
2. Integer
// Store 82 in integer type: INSERT temperature,machine=unit42,type=assembly external=82i 1435362189575692182
3. String
Double quotation marks cause the field value to represent the string:
// Store values as string types too warm: INSERT temperature,machine=unit42,type=assembly external="too warm" 1435362189575692182
4. Boolean
// Store values as Boolean types true INSERT temperature,machine=unit42,type=assembly external=true 1435362189575692182