InfluxDB Installation\Oracle Installation
(→Oracle Linux) |
|||
Line 24: | Line 24: | ||
By default, InfluxDB creates a simple web portal that developers can use to verify or generate query strings. You should be able to access it by going to: <br \> | By default, InfluxDB creates a simple web portal that developers can use to verify or generate query strings. You should be able to access it by going to: <br \> | ||
<code>http://domain.com:8083/</code> | <code>http://domain.com:8083/</code> | ||
+ | ===Database config=== | ||
+ | Login and create a DB | ||
+ | <nowiki>~$ influx | ||
+ | Connected to http://localhost:8086 version 0.13.0 | ||
+ | InfluxDB shell version: 0.13.0 | ||
+ | > CREATE DATABASE influxdb | ||
+ | > SHOW DATABASES | ||
+ | name: databases | ||
+ | --------------- | ||
+ | name | ||
+ | _internal | ||
+ | influxdb</nowiki> | ||
+ | ====Testing DB==== | ||
+ | <nowiki>~$ influx | ||
+ | > USE influxdb | ||
+ | > INSERT cpu,host=serverA value=0.64 | ||
+ | > SELECT * from cpu | ||
+ | name: cpu | ||
+ | --------- | ||
+ | time host value | ||
+ | 1467318896821675352 serverA 0.64 | ||
+ | </nowiki> | ||
+ | Setting up an external write into the database. Open a new shell on the same host. | ||
+ | <nowiki>~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.60' | ||
+ | HTTP/1.1 204 No Content | ||
+ | Request-Id: d333c2a3-3f03-11e6-800b-000000000000 | ||
+ | X-Influxdb-Version: 0.13.0 | ||
+ | Date: Thu, 30 Jun 2016 20:47:14 GMT</nowiki> | ||
+ | |||
+ | Write the same string multiple times to the influxdb, but remember to change the value | ||
+ | <nowiki>~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.30' | ||
+ | ~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.40'</nowiki> | ||
+ | |||
+ | |||
+ | Verify the data is there | ||
+ | <nowiki>~$ influx | ||
+ | > USE influxdb | ||
+ | Using database influxdb | ||
+ | > SELECT * from cpu_load_short | ||
+ | name: cpu_load_short | ||
+ | -------------------- | ||
+ | time host region value | ||
+ | 1434055562000000000 server01 us-west 0.64</nowiki> | ||
+ | |||
+ | ===Adding an Administrator Account=== | ||
+ | <nowiki>~$ influx | ||
+ | > CREATE USER root WITH PASSWORD 'TuTewlyQsjhMregggQbF' WITH ALL PRIVILEGES</nowiki> | ||
+ | ===Creating User account with access to Database=== | ||
+ | <nowiki>~$ influx | ||
+ | > CREATE USER influx WITH PASSWORD 'influxdb' | ||
+ | > GRANT ALL ON influxdb TO influx</nowiki> | ||
+ | ===Verify Users and Rights=== | ||
+ | <nowiki>~$ influx | ||
+ | > SHOW USERS | ||
+ | user admin | ||
+ | root true | ||
+ | influx false | ||
+ | > SHOW GRANTS FOR influx | ||
+ | database privilege | ||
+ | influxdb ALL PRIVILEGES</nowiki> | ||
+ | ===Add Authentication for HTTP requests=== | ||
+ | '''Note:''' I started out with this enabled, then I had to set it back to false in order for collectd to report metrics. As with anything, lock down traffic to your trusted hosts. | ||
+ | Change <code>auth-enabled = false</code> to <code>auth-enabled = true</code> | ||
+ | <nowiki>~$ sudo vi /etc/influxdb/influxdb.conf | ||
+ | [http] | ||
+ | enabled = true | ||
+ | bind-address = ":8086" | ||
+ | auth-enabled = true # | ||
+ | log-enabled = true | ||
+ | write-tracing = false | ||
+ | pprof-enabled = false | ||
+ | https-enabled = false | ||
+ | https-certificate = "/etc/ssl/influxdb.pem" | ||
+ | max-row-limit = 10000 | ||
+ | </nowiki> | ||
+ | Restart the Service | ||
+ | <nowiki>~$ sudo service influxdb restart</nowiki> | ||
+ | |||
+ | ===Verify local authentication=== | ||
+ | Make sure you can still authenticate with your accounts. Non-Admin accounts '''cannot''' <code>SHOW DATABASES</code> or <code>SHOW USERS</code> | ||
+ | <nowiki> ~$ influx | ||
+ | Connected to http://localhost:8086 version 0.9.4.1 | ||
+ | InfluxDB shell 0.9.4.1 | ||
+ | > auth root TuTewlyQsjhMregggQbF | ||
+ | ></nowiki> | ||
+ | OR | ||
+ | <nowiki>~$ influx -username root -password TuTewlyQsjhMregggQbF</nowiki> | ||
+ | |||
+ | ===Inserting data with Authentication=== | ||
+ | This is an example: | ||
+ | <nowiki>~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' -u influx:influxdb --data-binary 'cpu_load_short,host=server01,region=us-west value=0.10'</nowiki> |
Latest revision as of 11:44, 26 September 2016
Ubuntu Installation | OracleLinux Installation
[edit] Oracle Linux
All the Instructions below assume you have completed the Grafana Installation.
Requirements:
- Ports 8083, 8086 open to users and collectors
[edit] Add InfluxDB Repo
Create a new reoo file for InfluxDB
~$ sudo vi /etc/yum.repos.d/influxdb.repo Add: [influxdb] name = InfluxDB Repository - RHEL \$releasever baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable enabled = 1 gpgcheck = 1 gpgkey = https://repos.influxdata.com/influxdb.key
Update repo cache
~$ sudo yum makecache
[edit] Install InfluxDB
~$ sudo yum install influxdb
Start the service and verify its running
~$ sudo service influxdb start ~$ sudo service influxdb status
[edit] Verify Dev Web Portal
By default, InfluxDB creates a simple web portal that developers can use to verify or generate query strings. You should be able to access it by going to:
http://domain.com:8083/
[edit] Database config
Login and create a DB
~$ influx Connected to http://localhost:8086 version 0.13.0 InfluxDB shell version: 0.13.0 > CREATE DATABASE influxdb > SHOW DATABASES name: databases --------------- name _internal influxdb
[edit] Testing DB
~$ influx > USE influxdb > INSERT cpu,host=serverA value=0.64 > SELECT * from cpu name: cpu --------- time host value 1467318896821675352 serverA 0.64
Setting up an external write into the database. Open a new shell on the same host.
~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.60' HTTP/1.1 204 No Content Request-Id: d333c2a3-3f03-11e6-800b-000000000000 X-Influxdb-Version: 0.13.0 Date: Thu, 30 Jun 2016 20:47:14 GMT
Write the same string multiple times to the influxdb, but remember to change the value
~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.30' ~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.40'
Verify the data is there
~$ influx > USE influxdb Using database influxdb > SELECT * from cpu_load_short name: cpu_load_short -------------------- time host region value 1434055562000000000 server01 us-west 0.64
[edit] Adding an Administrator Account
~$ influx > CREATE USER root WITH PASSWORD 'TuTewlyQsjhMregggQbF' WITH ALL PRIVILEGES
[edit] Creating User account with access to Database
~$ influx > CREATE USER influx WITH PASSWORD 'influxdb' > GRANT ALL ON influxdb TO influx
[edit] Verify Users and Rights
~$ influx > SHOW USERS user admin root true influx false > SHOW GRANTS FOR influx database privilege influxdb ALL PRIVILEGES
[edit] Add Authentication for HTTP requests
Note: I started out with this enabled, then I had to set it back to false in order for collectd to report metrics. As with anything, lock down traffic to your trusted hosts.
Change auth-enabled = false
to auth-enabled = true
~$ sudo vi /etc/influxdb/influxdb.conf [http] enabled = true bind-address = ":8086" auth-enabled = true # log-enabled = true write-tracing = false pprof-enabled = false https-enabled = false https-certificate = "/etc/ssl/influxdb.pem" max-row-limit = 10000
Restart the Service
~$ sudo service influxdb restart
[edit] Verify local authentication
Make sure you can still authenticate with your accounts. Non-Admin accounts cannot SHOW DATABASES
or SHOW USERS
~$ influx Connected to http://localhost:8086 version 0.9.4.1 InfluxDB shell 0.9.4.1 > auth root TuTewlyQsjhMregggQbF >
OR
~$ influx -username root -password TuTewlyQsjhMregggQbF
[edit] Inserting data with Authentication
This is an example:
~$ curl -i -XPOST 'http://localhost:8086/write?db=influxdb' -u influx:influxdb --data-binary 'cpu_load_short,host=server01,region=us-west value=0.10'