当前位置:网站首页>Influxdb basic understanding
Influxdb basic understanding
2022-07-27 04:24:00 【Stars baa】
Catalog
One 、 What is a temporal database
1、 Time series database InfluxDb
5、influxdb System architecture
1.Windows Computer installation influxdb Time series database
1、influxdb Unpack the installation
3、 Start the client to test whether the server starts successfully
3、 ... and 、influxdb Basic operation
2、InfluxDB Data table operation
3、 Data retention strategy (Retention Policies)
Create a data retention policy
Four 、influxdb Turn on user login authentication
1、 Turn on login authentication
2、 Log in without password after opening authentication
3、 After opening the authentication, there is a password to log in
One 、 What is a temporal database
What is a temporal database ? Time series database is a new concept in recent years , With the traditional Mysql Comparison of relational databases , Its biggest feature is : Data is stored in chronological order .
for instance , Log data , It is stored in chronological order , So it is a good choice to use time series database to store . Use Mysql In the process of storage , This time-based data is not optimized , therefore , In the query 、 There are some bottlenecks in the insertion .
1、 Time series database InfluxDb
InfluxDB Is an open source database for storing and analyzing time series data . It is also the most used time series database .
2、InfluxDB Characteristics
InfluxDB It has a lot of characteristics , as follows :
built-in HTTP Interface , Easy to use
Data can be tagged , In this way, the query can be very flexible
class SQL Query statement
Installation management is simple , And it's efficient to read and write data
Be able to query in real time , Data can be found immediately after being indexed at the time of writing
3、influxdb Data model

measurement: Tables in the database ;
points: A row of data in the table .
Point By time stamp (time)、 data (field) And labels (tags) form :
time: Time of each data record , It is also the main index automatically generated by the database ;
fields: Values of various records ;
tags: All kinds of indexed properties .
temperature Namely measurement Represent a list . Each line represents a point internal extenal Is the value of two data indicators .tags Represents the location where the value is generated .
4、influxdb Timeline
series : All the data in the database , All need to be shown in charts , Represents the data in the table , You can draw a few lines on the graph , adopt tags The permutation is calculated .
series It's some kind of specific tag Time series value set of a specific index under .
5、influxdb System architecture
Every database There can be multiple RP(retention policy Data retention strategy ), But there is only one default policy . Under the strategy, it is divided into multiple according to the time period ShardGroup, Every ShardGroup Store data for a period of time . Every shardgroup There are several shard To store data .
Two 、influxdb Installation
1.Windows Computer installation influxdb Time series database
1、influxdb Unpack the installation
Download and unzip it directly , take influxdb Extract to a directory :

There are several documents we need to remember :
influxdb.conf It's a configuration file
influxd yes influx The main program of
2、 start-up influxdb database
adopt cmd Enter this directory , perform influxd.exe You can start :

A reminder that you need the network may pop up , At this time, click allow access to the network .

3、 Create services
Click below nssm.exe Download to influxdb Directory :
(1) adopt cmd Enter this directory , perform nssm.exe install influxdb, Choose the path
choice influxd.exe
(2) stay Arguments fill -config ./influxdb.conf
(3) Open Task Manager , start-up influxdb service
3、 Start the client to test whether the server starts successfully
Through again cmd Enter this directory , perform influx.exe You can start :
perform show databases, The client will connect to the default db, Pictured above , Displaying the corresponding database means influxdb It's working .
3、 ... and 、influxdb Basic operation
This time Linux Operation demonstration in
1、InfluxDB Database operation
Display database
show databases

explain :
_internalThe database is used to store InfluxDB Internal real-time monitoring data .
Create database
create database test
Delete database
drop database kkkkk
Use the specified database
use mydb
2、InfluxDB Data table operation
stay InfluxDB among , There is no watch (table) The concept , In its place MEASUREMENTS,MEASUREMENTS The function of is consistent with the table in traditional database , So we can also put MEASUREMENTS be called InfluxDB In the table .
Show all tables
SHOW MEASUREMENTS
new table
InfluxDB There is no explicit statement to create a new table , Only through insert Data to create new tables .
insert cpu,host=serverA,region=us_west value=0.64
among cpu It's the name of the watch ,host、region It's the index (tags),value=xx It's the record value (fields), There can be more than one record value , The system automatically appends the timestamp
Query table data
select * from cpu
perform precision rfc3339 Change to international time , Time difference with Beijing 8 Hours
Delete table
drop measurement
3、 Data retention strategy (Retention Policies)
influxDB There is no way to delete data records directly , But provide data saving strategy , Mainly used to specify data retention time , Beyond the specified time , Just delete this part of data .( Set statements similar to periodic cleanup )
Retention policy syntax
CREATE RETENTION POLICY <retention_policy_name> ON <database_name> DURATION <duration> REPLICATION <n> [SHARD DURATION <duration>] [DEFAULT]
<retention_policy_name>: The name of the retention policy ( Customize )
<database_name>: Create a retention policy for which database
<duration>: The data expiration time corresponding to the retention policy
REPLICATION: Copy factor SHARD DURATION: Default duration of tile group
[DEFAULT]: Whether it is the default policy
Create a data retention policy
CREATE RETENTION POLICY "influx_retention" ON "mydb" DURATION 30d REPLICATION 1 DEFAULT
influx_retention: Policy name ;
mydb: Specific database name ;
30d: preservation 30 God ,30 The data before days will be deleted ,influxdb There are various event parameters , such as :h( Hours ),d( God ),w( week / Zhou );
replication 1: Number of copies , It's usually 1 That's all right. ;
default: Set as default policy
View retention period
SHOW RETENTION POLICIES ON mydb
Modify the retention period
ALTER RETENTION POLICY "influx_retention" ON mydb DURATION 15d
Delete retention period
DROP RETENTION POLICY "influx_retention" ON mydb
4、 The user action
Show users
show users
Create user
【 Ordinary users 】 Create user and set password
CREATE USER tom WITH PASSWORD '123'
【 Administrator user 】
create user "tony" with password '123' with all privileges
Change user password
SET PASSWORD FOR tom = '123456'
Delete user
drop user admin
5、 Database access rights
User authorization
Authorize the user to operate the database
GRANT ALL PRIVILEGES ON influxdb TO tom
Give users administrator privileges
GRANT ALL PRIVILEGES TO tony
remarks : Only use admin Permission to operate the database
Cancel the authorization
Revoke the user's database operation permission
Revoke ALL PRIVILEGES ON influxdb FROM tom
Revoke user administrator privileges
Revoke ALL PRIVILEGES FROM tony
Four 、influxdb Turn on user login authentication
1、 Turn on login authentication
stay influxdb The configuration file influxdb.conf in , Turn on user login authentication , stay http The module is modified as follows :
[[email protected] ~]# vim /etc/influxdb/influxdb.conf
[http]
······
auth-enabled = true
[[email protected] ~]# systemctl restart influxd # You need to restart after modifying the configuration file
# stay Windows in Then you can In Task Manager Restart influxdb service
When modifying user permissions, you need to modify the configuration file to auth-enabled = false To operate
2、 Log in without password after opening authentication
Ordinary users have no permission to view :
3、 After opening the authentication, there is a password to log in
You have to log in a user with administrator permission to have view permission :
perform influx -username tony -password 123 Sign in influxdb
边栏推荐
- Maximum nesting depth of parentheses
- List Simulation Implementation
- Okaleido ecological core equity Oka, all in fusion mining mode
- Cool Lehman VR panorama paves the way for you to start a business
- c# 获取uuid
- EVT interface definition file of spicy
- xxx is not in the sudoers file. This incident will be reported
- 新互联网时代已来 WEB 3.0 会给我们带来哪些新机遇
- Learning route from junior programmer to architect + complete version of supporting learning resources
- Ribbon-负载均衡原理及部分源码
猜你喜欢

Okaleido ecological core equity Oka, all in fusion mining mode

大咖说·图书分享|精益产品开发:原则、方法与实施

The difference between ArrayList and LinkedList

Cool Lehman VR panorama paves the way for you to start a business

VR panorama gold rush "careful machine" (Part 1)

C language learning notes - memory management

Big talk · book sharing | lean product development: principles, methods and Implementation

Convolution neural network -- a detailed introduction to convolution of 24 bit color images

Delete the whole line of Excel, and delete the pictures together

你了解微信商户分账吗?
随机推荐
xxx is not in the sudoers file. This incident will be reported
标准C语言11
Internet of things smart home project - Smart bedroom
Elastic open source community: Developer Recruitment
VR panorama gold rush "careful machine" (Part 1)
使用kubesphere图形界面dashboard开启devops功能
搜索旋转排序数组
Principle of bean validation --07
Subject 3: Jinan Zhangqiu line 2
【比赛参考】PyTorch常用代码段以及操作合集
Brightcove appoints Dan Freund as chief revenue Officer
Daily question 1: delete continuous nodes with a total value of zero from the linked list
Practice of microservice in solving Library Download business problems
Session&Cookie&token
[leetcode] day104 no overlapping interval
Elastic开源社区:开发者招募
面试题 02.05. 链表求和
leetcode每日一题:数组的相对排序
Delete the whole line of Excel, and delete the pictures together
Slope of binary tree