티스토리 뷰
InfluxDB + Ubuntu 설치하기
버전정보
InfluxDB v1.5.1
Ubuntu 17.10
influxdb download : https://portal.influxdata.com/downloads
$ wget https://dl.influxdata.com/influxdb/releases/influxdb_1.5.1_amd64.deb
$ sudo dpkg -i influxdb_1.5.1_amd64.deb
라이브러리 설치
$ sudo sed -i -e 's/us.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install curl
$ apt-get install apt-transport-https ( https 접근에 문제가 있을경우에 )
인스톨 : https://docs.influxdata.com/influxdb/v1.5/introduction/installation/
$ curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
$ source /etc/lsb-release
$ echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
실행
$ sudo apt-get update && sudo apt-get install influxdb
$ sudo service influxdb start
$ influxd
$ influx
연결 | influx -username 'root' -password 'password' |
SELECT sum(packets) as packets,sum(octets) as octets FROM aus where time > now() - 1h group by time(5m) | |
SELECT sum(packets) as packets,sum(octets) as octets FROM aus where time > now() - 1d group by time(1h) |
단위
h (hours), m (minutes), s (seconds), ms (milliseconds), u (microseconds), ns (nanoseconds).
$ influx -precision='s' ( 실행할때 -precision 옵션으로 h,m,s,ms,u,ns ) 지정할 수 있다.
> CREATE DATABASE xdn
> USE xdn
> INSERT lowdata srcIp="192.168.0.2",dstIp="192.168.0.3",prot=6,srcPort=1433,dstPort=50745,octets=254,packets=3
> select * from lowdata
name: lowdata
time dstIp dstPort dstport load octets packets prot srcIP srcIp srcPort srcip srcport
---- ----- ------- ------- ---- ------ ------- ---- ----- ----- ------- ----- -------
1522665050 192.168.5.97 50745 254 3 6 192.168.10.6 1433
epoch 옵션
$ select * from table epoch=[ns,u,µ,ms,s,m,h]
$ curl -G 'http://localhost:8086/query?db=mydb&pretty=true&epoch=s' --data-urlencode 'q=SELECT * FROM "mymeas"'