1. inflexdb 설치 (time series database)
1) Hardware
[DISK]
2개에 볼륨이 필요하며, 가능한 SSD 사용이 좋음 (IOPS : 1k -3k)
- influxdb/wal : 로그 기록용 (디스크 양이 작고 IOPS 빠른 볼륨)
- influxdb/data : 실 데이터 (디크스 양은 크고 IOPS wal 비해 낮아도 됨)
[RAM]
최소 8G에 이상
2) centos / redhat
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.4.3.x86_64.rpm
yum localinstall influxdb-1.4.3.x86_64.rpm
설치는 root로 진행하여나 하나 운영은 influxdb 계정으로 수행
3) linux generic
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.4.3_linux_amd64.tar.gz
tar xvfz influxdb-1.4.3_linux_amd64.tar.gz
4) 포트
8086 : client-server 통신 (http api)
8088 : rpc service (backup and restore)
5) 설정 파일
/etc/influxdb/influxdb.conf (custom 설정 : INFLUXDB_CONFIG_PATH 환경변수에 지정)
설정 내용 확인 : influxd config
6) influxdb 시작/중단
systemctl start influxdb (service influxdb start)
systemctl stop influxdb (service influxdb stop)
7) influxdb 디렉토리 퍼미션 변경
chown influxdb:influxdb influxdb/wal
chown influxdb:influxdb influxdb/data
8) influxdb 파라미터 환경 설정
GOMAXPROCS = 코어 프로세스값
[/etc/influxdb/influxdb.conf]
bind-address : rpc service
[meta] : users, db, shards등에 meta정보 저장
[data] : wal/data 파일 위치 및 cache 관련 설정
[coorditnator] : query 관련 configuration 정보
[retention] : old data retention 관련 설정
[shard-precreation] : shards precreation에 대한 설정
[monitor] : influxdb 진단을 위한 통계 정보 설정
[admin] : 버전 1.3이후부터 web admin은 chrongraf로 대체
[http] : 데이터 in/out하는 http에 설정
9) cli (http api를 사용하여 influx 명령어 사용)
influx
influx -execute 'SHOW DATABASES'
influx -execute 'SELECT * from "test" limit 3' -database="test" -precision=rfc3399
influx -format=column
influx -format=csv
influx -format=json
influx -format=json -pretty
# import
influx -import -path=/tmp/test.txt -precision=s
# ddl, dml
create database test1
create retention policy t1 on test1 duration 1d replication 1
# insert (measurement/table,field-key=field-value,field-key=field-value value timestamp)
test1,test_id=id1 value=100 1439856000
influx -precision rfc3339 (rtf3339 : YYYY-MM-DDHH:MM:SS.nnnnnnnnnZ)
# db 생성
create database test1
# 전체 db 리스트 출력
show databases
use test1
#기존 RDB와 용어 맵핑
table : measurement
column : fields, tags
index : tags
10) http api
# create database
curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE test1"
# write data
curl -i -XPOST 'http://localhost:8086/write?db=test1' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64'
curl -i -XPOST 'http://localhost:8086/write?db=test1' --data-binary 'cpu_load_short,host=server02 value=0.67
cpu_load_short,host=server02,region=us-west value=0.55 1422568543702900257
cpu_load_short,direction=in,host=server01,region=us-west value=2.0 1422568543702900257'
# write data from file
curl -i -XPOST 'http://localhost:8086/write?db=test1' --data-binary @cpu_data.txt
# query data
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb"
--data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'"
curl -G 'http://localhost:8086/query' --data-urlencode "db=mydb" --data-urlencode "epoch=s"
--data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'"
curl -G 'http://localhost:8086/query' --data-urlencode "db=deluge" --data-urlencode "chunked=true"
--data-urlencode "chunk_size=20000" --data-urlencode "q=SELECT * FROM liters"
# user 인증
curl -G http://localhost:8086/query -u todd:influxdb4ever --data-urlencode "q=SHOW DATABASES"
curl -G "http://localhost:8086/query?u=todd&p=influxdb4ever" --data-urlencode "q=SHOW DATABASES"
curl -G http://localhost:8086/query --data-urlencode "u=todd" --data-urlencode "p=influxdb4ever" --data-urlencode "q=SHOW DATABASES"
11) long query 확인
show queries
kill query qid
12) db user ( 인증 enable시 )
- Admin users
create user admin with password '<password>' with all priviles;
grant all privileges to <username>
revoke all privileges from <username>
show users
- Non Admin users
create user <username> with password '<password>'
grant [read,write,all] on <database_name> to <username>
revoke [read,write,all] on <database_name> from <username>
- User 권한 보기
show grants for <user_name>
- user 삭제
drop user <username>
13) 데이터 cq (continuous query) 및 rp (retention policy)
- rp
create retention policy "two_hours" on "test" duration 2h replication 1 default (test db 2시간 데이터 보관, default)
create retention policy "a_year" on "test" duration 52w replication 1
- cq
create continuous query "cq_30m" on "test" begin
select mean("website") as website, mean("phone" as "mean_phone"
into "a_year"."downsampled_orders"
from "orders"
group by time(30m)
end
2. telegraf 설치
1) centos / redhat
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.5.2-1.x86_64.rpm
yum localinstall telegraf-1.5.2-1.x86_64.rpm
2) linux generic
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.5.2_linux_amd64.tar.gz
tar xf telegraf-1.5.2_linux_amd64.tar.gz
3) 처리 흐름