Influxdb-install-relay--http Write--read. [Create db]

Source: Internet
Author: User
Tags auth curl urlencode influxdb

 

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
    1. Create an Admin user
    2. By default, authentication is turned off in the configuration file. Can be opened by setting [http] the auth-enabled=true
    3. 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"
    • 1

Write:

-v -XPOST "http://login1.org:8086/write?db=test&u=admin&p=admin" --data-binary "table dd=44"
    • 1

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>
    • 1
    • 2
    • 3
    • 4
    • 5
    • Start with user name password:
-username todd -password influxdb4ever
    • 1
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 SERIESand the DROP MEASUREMENT
? CREATE RETENTION POLICY, ALTER RETENTION POLICY , and DROP RETENTION POLICY
? CREATE CONTINUOUS QUERYand 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 PASSWORDand 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
    • 1
    • Authorizing administrator rights for an existing user
GRANT ALL PRIVILEGES TO <username>
    • 1
    • Cancel User Rights
FROM <username>
    • 1
    • Show users and their permissions
SHOW USERS
    • 1
Non-administrator user management:
    • Create a new normal user
CREATE USER <username> WITH PASSWORD ‘<password>‘
    • 1
    • Authorized for an existing user
GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
    • 1
    • Cancel Permissions
REVOKE [READ,WRITE,ALL] ON <database_name> FROM <username>
    • 1
    • Show user permissions on different databases
SHOW GRANTS FOR <user_name>
    • 1
General User Account function management
    • Reset Password
SET PASSWORD FOR <username> = ‘<password>‘
    • 1
    • Delete User
DROP USER <username>
    • 1
HTTP error for user authentication and authorization

When validation fails, HTTP returns:

HTTP 401 Unauthorized

Influxdb-install-relay--http Write--read. [Create db]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.