influxDB | Install | insert | select

InfluxDB

InfluxDB is a time series database designed to handle high write and query loads. It is an integral part of the TICK stack. InfluxDB is intended to be used as a backing store for any use case involving large amounts of time-stamped data, including DevOps monitoring, application metrics, IoT sensor data, and real-time analysis.

Installation process

1. Download:
https://portal.influxdata.com/downloads/

Choose version 1.8 and download it on windows.
[The page has been revised, and no specific download link can be found. But the official website is as above. 】

2. Find the downloaded file in the local file and unzip it to the directory you want to install.
Example: My installation is in D:\Program Files\influxdb-1.8.3-1

Insert picture description here

Modify the configuration file.

Insert picture description here


3. Double-click influxd.exe to open the program.

Insert picture description here


4. Open on the command line.
Enter the corresponding path to execute.
influxd.exe -config influxdb.conf

Insert picture description here

Simple sentence

Official document: https://docs.influxdata.com/influxdb/v1.8/

  • Enter influx
influx 
Insert picture description here
  • View help
help
Insert picture description here
  • View the database (you do not need a semicolon)
show databases
Insert picture description here
  • Create a database (student)
create database student
Insert picture description here
  • Delete the database (student)
drop database student
Insert picture description here
  • Use database (student)
use student
Insert picture description here

Inserting data
There is no concept of creating a new table in Influx. The table is automatically created when inserting data.

insert test,id=1 value=1
Insert picture description here
  • Viewing the table
    measurement is equivalent to the concept of a table in mysql.
show measurements
Insert picture description here
  • View the data of the table
select * from test
Insert picture description here
  • Query lat and lng two fields
select lat,lng from student
Insert picture description here
  • Query the three fields of time, lat and lng
select time,lat,lng from student
Insert picture description here
  • Format time
 precision rfc3339
Insert picture description here
  • Small problem: wrong time

My current time display is wrong, and the environment is windows. The query time is 8h less than the correct time.

"The bottom layer of influxdb is written in go language, and the time zone database cannot be obtained correctly on the windows machine, so whether it is the original time zone in the document or "Asia/Shanghai", the same error is reported. There are three solutions, or you can install it on linux , Either install the go environment on windows, or the backend converts the time zone by itself" -----Comments from other blogs.

Insert picture description here


Insert picture description here

Solution:

1. Modify the time in the configuration

将serverTimezone的配置改为Asia/Shanghai
url: jdbc:mysql://47.100.245.18:3306/bfc?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useSSL=false

2. Manually add time to the dao layer code.

 @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createDate;

Delete table

 drop measurement test
Insert picture description here


After deleting, you will find that the current database is unable to find the data content of the table.

  • Insert a multi-field table
    Table name: student
    tag (tag): id
    filed (field): lat, lng, sid
insert + measurement + “,” + tag=value,tag=value + +
field=value,field=value Tag and tag are separated by commas; field and field are separated by commas,
tag and field are separated by spaces All are string types, do not need quotation marks to wrap the value
field. If it is a string type, you need to add quotation marks
Insert picture description here
insert student,id=1 lat=1,lng=1,sid=1
insert student,id=2 lat=2,lng=2,sid=2
  • Query table data
select * from student
Insert picture description here
  • Exit influx

Ctrl+C terminates the currently running query. Useful when an interactive query takes a long time to respond because it tries to return too much data.

exit | quit | Ctrl+D Exit the influx shell.

Insert picture description here


Insert picture description here
  • Create user
auth
Insert picture description here
  • Create an administrator
CREATE USER root WITH PASSWORD 'root' WITH ALL PRIVILEGES



over. Supplements will be added later.
In order to catch up with the homework, I will start learning temporarily. Thank you for the tutorials of the community leaders. Write down notes here for subsequent reference.

Reference link:

Influx Sql series of tutorials five: insert to add data

8 hours more time found in the database & 8 hours less time for normal display of query data