Influxdb is a time series database. CentOS Download and install commands
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64.rpm
sudo yum localinstall influxdb-1.2.4.x86_64.rpm
Service Influxdb Start//Startup
Netstat-an | grep 8086
Netstta-an | grep 8088
If both ports are started, the Influxdb boot succeeds. INFLUXDB Management port 8083 is turned off by default in 1.2.4 and requires manual configuration for access.
The configuration file defaults to/etc/influxdb/influxdb.conf. You can configure the port number to control the management console. The data store directory.
#是否上报. Default allow escalation, possibly similar to acquisition of user data from Windows
Reporting-disabled = True
#集群数据通信端口. Global configuration
bind-address = ": 8088"
#meta
dir = "/var/lib/influxdb/meta"
#时间序列数据
dir = "/var/lib/influxdb/data"
Writing data and checking the data on the official website is a simple example. https://docs.influxdata.com/influxdb/v1.2/introduction/installation/.
The thing to note about writing data is that the time Series unit is UTC nanoseconds, and just started in this big circle, writing data can be successful but cannot be queried because of the wrong time. Java does not have a direct UTC nanosecond method, only System.currenttimemillis () gets the millisecond method. In fact, according to the millisecond and nanosecond conversion units, directly in the System.currenttimemillis () plus six 0 can be. Given the fact that there will be concurrent writes, the same data may be written within a millisecond, and the 6-bit 0 can be changed to a random number with 6 bits. Further reduce data conflicts caused by concurrency.
curl -POST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
I get an in Method Not Allowed
return.
Nevertheless, doing the same with get works perfectly:
curl http://localhost:8086/query?q=CREATE+DATABASE+"db"
Authentication and authorization (Rights Management)
Authentication and Authorization
Note: Identity authorization and authentication cannot be used to block malicious users. If there is an additional need for rationality and security, INFLUXDB can be run within a third-party service.
Identity verification
Influxdb HTTP API and CLI (command line interface), with simple certificate-based built-in permissions control, use the API to link the database. After authentication is initiated, the HTTP request is accepted only if the certificate is joined.
Note: Authentication applies to the scope of the HTTP request. Plugin Not applicable (Graphite, COLLECTD, etc.)
Setting Up authentication
- Create an Admin user
- By default, authentication is turned off in the configuration file. Can be opened by setting
[http]
the auth-enabled=true
- Restart your app
Influxdb will now check the identity card and only process requests that have been successfully validated.
Note: If the authentication feature is turned on and there is no user, Influxdb will force the Admin user to be created and accept only the query that created the Admin user
Authentication Request HTTP API
Basically the console is possible.
Query:
-v -G "http://login1.org:8086/query?db=test&u=admin&p=admin" --data-urlencode "q=select * from table"
Write:
-v -XPOST "http://login1.org:8086/write?db=test&u=admin&p=admin" --data-binary "table dd=44"
User name password is embedded in plaintext URL.
Cli
There are two ways to do this:
- After you start the console, set up the user
auth <username> <password>
:
to http://localhost:8086 version 0.9.4.1InfluxDB shell 0.9.4.1> auth admin admin>
- Start with user name password:
-username todd -password influxdb4ever
Identity authorization
By default, authentication is turned off, and all users have all permissions, and the associated authentication is ignored. Authorization information is verified only when it is turned on.
User types and their rights administrators
All administrators have read and write access to all databases and can perform all of the following Management class query statements:
Database management:
? CREATE DATABASE
, and DROP DATABASE
? DROP SERIES
and the DROP MEASUREMENT
? CREATE RETENTION POLICY
, ALTER RETENTION POLICY
, and DROP RETENTION POLICY
? CREATE CONTINUOUS QUERY
and theDROP CONTINUOUS QUERY
User management:
? Admin User management:
CREATE USER
,,, GRANT ALL PRIVILEGES
REVOKE ALL PRIVILEGES
and SHOW USERS
? Non-admin User management:
CREATE USER
, GRANT [READ,WRITE,ALL], REVOKE [READ,WRITE,ALL
], and SHOW GRANTS
? General user management:
SET PASSWORD
and theDROP USER
Non-administrator users:
A non-administrator user can assign a permission:
? READ
? WRITE
? ALL
( READ
and WRITE
)
These three scenarios can be assigned to each user, per database.
User Management Commands Admin user management:
- Create a new administrator user
CREATE USER <username> WITH PASSWORD ‘<password>‘ WITH ALL PRIVILEGES
- Authorizing administrator rights for an existing user
GRANT ALL PRIVILEGES TO <username>
FROM <username>
- Show users and their permissions
SHOW USERS
Non-administrator user management:
CREATE USER <username> WITH PASSWORD ‘<password>‘
- Authorized for an existing user
GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
REVOKE [READ,WRITE,ALL] ON <database_name> FROM <username>
- Show user permissions on different databases
SHOW GRANTS FOR <user_name>
General User Account function management
SET PASSWORD FOR <username> = ‘<password>‘
DROP USER <username>
HTTP error for user authentication and authorization
When validation fails, HTTP returns:
HTTP 401 Unauthorized
Influxdb-install-relay--http Write--read. [Create db]