一摩疑、安裝InfluxDB
-
安裝
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.0.x86_64.rpm
sudo yum localinstall influxdb-1.8.0.x86_64.rpm
-
啟動(dòng)
systemctl enable influxdb
systemctl start influxdb
-
配置文件詳解
vi /etc/influxdb/influxdb.conf
全局配置
reporting-disabled = false # 該選項(xiàng)用于上報(bào)influxdb的使用信息給InfluxData公司危融,默認(rèn)值為false
bind-address = ":8088" # 備份恢復(fù)時(shí)使用,默認(rèn)值為8088
1雷袋、meta相關(guān)配置
[meta]
dir = "/var/lib/influxdb/meta" # meta數(shù)據(jù)存放目錄
retention-autocreate = true # 用于控制默認(rèn)存儲策略吉殃,數(shù)據(jù)庫創(chuàng)建時(shí),會(huì)自動(dòng)生成autogen的存儲策略楷怒,默認(rèn)值:true
logging-enabled = true # 是否開啟meta日志寨腔,默認(rèn)值:true
2、data相關(guān)配置
[data]
dir = "/var/lib/influxdb/data" # 最終數(shù)據(jù)(TSM文件)存儲目錄
wal-dir = "/var/lib/influxdb/wal" # 預(yù)寫日志存儲目錄
query-log-enabled = true # 是否開啟tsm引擎查詢?nèi)罩韭使眩J(rèn)值: true
cache-max-memory-size = 1048576000 # 用于限定shard最大值迫卢,大于該值時(shí)會(huì)拒絕寫入,默認(rèn)值:1000MB冶共,單位:byte
cache-snapshot-memory-size = 26214400 # 用于設(shè)置快照大小乾蛤,大于該值時(shí)數(shù)據(jù)會(huì)刷新到tsm文件每界,默認(rèn)值:25MB,單位:byte
cache-snapshot-write-cold-duration = "10m" # tsm引擎 snapshot寫盤延遲家卖,默認(rèn)值:10Minute
compact-full-write-cold-duration = "4h" # tsm文件在壓縮前可以存儲的最大時(shí)間眨层,默認(rèn)值:4Hour
max-series-per-database = 1000000 # 限制數(shù)據(jù)庫的級數(shù),該值為0時(shí)取消限制上荡,默認(rèn)值:1000000
max-values-per-tag = 100000 # 一個(gè)tag最大的value數(shù)趴樱,0取消限制,默認(rèn)值:100000
3酪捡、coordinator查詢管理的配置選項(xiàng)
[coordinator]
write-timeout = "10s" # 寫操作超時(shí)時(shí)間叁征,默認(rèn)值: 10s
max-concurrent-queries = 0 # 最大并發(fā)查詢數(shù),0無限制逛薇,默認(rèn)值: 0
query-timeout = "0s # 查詢操作超時(shí)時(shí)間捺疼,0無限制,默認(rèn)值:0s
log-queries-after = "0s" # 慢查詢超時(shí)時(shí)間永罚,0無限制啤呼,默認(rèn)值:0s
max-select-point = 0 # SELECT語句可以處理的最大點(diǎn)數(shù)(points),0無限制呢袱,默認(rèn)值:0
max-select-series = 0 # SELECT語句可以處理的最大級數(shù)(series)官扣,0無限制,默認(rèn)值:0
max-select-buckets = 0 # SELECT語句可以處理的最大"GROUP BY time()"的時(shí)間周期羞福,0無限制惕蹄,默認(rèn)值:0
4、retention舊數(shù)據(jù)的保留策略
[retention]
enabled = true # 是否啟用該模塊坯临,默認(rèn)值 : true
check-interval = "30m" # 檢查時(shí)間間隔,默認(rèn)值 :"30m"
5恋昼、shard-precreation分區(qū)預(yù)創(chuàng)建
[shard-precreation]
enabled = true # 是否啟用該模塊看靠,默認(rèn)值 : true
check-interval = "10m" # 檢查時(shí)間間隔,默認(rèn)值 :"10m"
advance-period = "30m" # 預(yù)創(chuàng)建分區(qū)的最大提前時(shí)間液肌,默認(rèn)值 :"30m"
6挟炬、monitor 控制InfluxDB自有的監(jiān)控系統(tǒng)。 默認(rèn)情況下嗦哆,InfluxDB把這些數(shù)據(jù)寫入_internal 數(shù)據(jù)庫谤祖,如果這個(gè)庫不存在則自動(dòng)創(chuàng)建。 _internal 庫默認(rèn)的retention策略是7天老速,如果你想使用一個(gè)自己的retention策略粥喜,需要自己創(chuàng)建。
[monitor]
store-enabled = true # 是否啟用該模塊橘券,默認(rèn)值 :true
store-database = "_internal" # 默認(rèn)數(shù)據(jù)庫:"_internal"
store-interval = "10s # 統(tǒng)計(jì)間隔额湘,默認(rèn)值:"10s"
7卿吐、admin web管理頁面
[admin]
enabled = true # 是否啟用該模塊,默認(rèn)值 : false
bind-address = ":8083" # 綁定地址锋华,默認(rèn)值 :":8083"
https-enabled = false # 是否開啟https 嗡官,默認(rèn)值 :false
https-certificate = "/etc/ssl/influxdb.pem" # https證書路徑,默認(rèn)值:"/etc/ssl/influxdb.pem"
8毯焕、http API
[http]
enabled = true # 是否啟用該模塊衍腥,默認(rèn)值 :true
bind-address = ":8086" # 綁定地址,默認(rèn)值:":8086"
auth-enabled = false # 是否開啟認(rèn)證纳猫,默認(rèn)值:false
realm = "InfluxDB" # 配置JWT realm婆咸,默認(rèn)值: "InfluxDB"
log-enabled = true # 是否開啟日志,默認(rèn)值:true
write-tracing = false # 是否開啟寫操作日志续担,如果置成true擅耽,每一次寫操作都會(huì)打日志,默認(rèn)值:false
pprof-enabled = true # 是否開啟pprof物遇,默認(rèn)值:true
https-enabled = false # 是否開啟https乖仇,默認(rèn)值:false
https-certificate = "/etc/ssl/influxdb.pem" # 設(shè)置https證書路徑,默認(rèn)值:"/etc/ssl/influxdb.pem"
https-private-key = "" # 設(shè)置https私鑰询兴,無默認(rèn)值
shared-secret = "" # 用于JWT簽名的共享密鑰乃沙,無默認(rèn)值
max-row-limit = 0 # 配置查詢返回最大行數(shù),0無限制诗舰,默認(rèn)值:0
max-connection-limit = 0 # 配置最大連接數(shù)警儒,0無限制,默認(rèn)值:0
unix-socket-enabled = false # 是否使用unix-socket眶根,默認(rèn)值:false
bind-socket = "/var/run/influxdb.sock" # unix-socket路徑蜀铲,默認(rèn)值:"/var/run/influxdb.sock"
9、subscriber 控制Kapacitor接受數(shù)據(jù)的配置
[subscriber]
enabled = true # 是否啟用該模塊属百,默認(rèn)值 :true
http-timeout = "30s" # http超時(shí)時(shí)間记劝,默認(rèn)值:"30s"
insecure-skip-verify = false # 是否允許不安全的證書
ca-certs = "" # 設(shè)置CA證書
write-concurrency = 40 # 設(shè)置并發(fā)數(shù)目,默認(rèn)值:40
write-buffer-size = 1000 # 設(shè)置buffer大小族扰,默認(rèn)值:1000
10厌丑、graphite 相關(guān)配置
[[graphite]]
enabled = false # 是否啟用該模塊,默認(rèn)值 :false
database = "graphite" # 數(shù)據(jù)庫名稱渔呵,默認(rèn)值:"graphite"
retention-policy = "" # 存儲策略怒竿,無默認(rèn)值
bind-address = ":2003" # 綁定地址,默認(rèn)值:":2003"
protocol = "tcp" # 協(xié)議扩氢,默認(rèn)值:"tcp"
consistency-level = "one" # 一致性級別耕驰,默認(rèn)值:"one
batch-size = 5000 # 批量size,默認(rèn)值:5000
batch-pending = 10 # 配置在內(nèi)存中等待的batch數(shù)录豺,默認(rèn)值:10
batch-timeout = "1s" # 超時(shí)時(shí)間耍属,默認(rèn)值:"1s"
udp-read-buffer = 0 # udp讀取buffer的大小托嚣,0表示使用操作系統(tǒng)提供的值,如果超過操作系統(tǒng)的默認(rèn)配置則會(huì)出錯(cuò)厚骗。 該配置的默認(rèn)值:0
separator = "." # 多個(gè)measurement間的連接符示启,默認(rèn)值: "."
11、collectd
[[collectd]]
enabled = false # 是否啟用該模塊领舰,默認(rèn)值 :false
bind-address = ":25826" # 綁定地址夫嗓,默認(rèn)值: ":25826"
database = "collectd" # 數(shù)據(jù)庫名稱,默認(rèn)值:"collectd"
retention-policy = "" # 存儲策略冲秽,無默認(rèn)值
typesdb = "/usr/local/share/collectd" # 路徑舍咖,默認(rèn)值:"/usr/share/collectd/types.db"
auth-file = "/etc/collectd/auth_file"
batch-size = 5000
batch-pending = 10
batch-timeout = "10s"
read-buffer = 0 # udp讀取buffer的大小,0表示使用操作系統(tǒng)提供的值锉桑,如果超過操作系統(tǒng)的默認(rèn)配置則會(huì)出錯(cuò)排霉。默認(rèn)值:0
12、opentsdb
[[opentsdb]]
enabled = false # 是否啟用該模塊民轴,默認(rèn)值:false
bind-address = ":4242" # 綁定地址攻柠,默認(rèn)值:":4242"
database = "opentsdb" # 默認(rèn)數(shù)據(jù)庫:"opentsdb"
retention-policy = "" # 存儲策略,無默認(rèn)值
consistency-level = "one" # 一致性級別后裸,默認(rèn)值:"one"
tls-enabled = false # 是否開啟tls瑰钮,默認(rèn)值:false
certificate= "/etc/ssl/influxdb.pem" # 證書路徑,默認(rèn)值:"/etc/ssl/influxdb.pem"
log-point-errors = true # 出錯(cuò)時(shí)是否記錄日志微驶,默認(rèn)值:true
batch-size = 1000
batch-pending = 5
batch-timeout = "1s"
13浪谴、udp
[[udp]]
enabled = false # 是否啟用該模塊,默認(rèn)值:false
bind-address = ":8089" # 綁定地址因苹,默認(rèn)值:":8089"
database = "udp" # 數(shù)據(jù)庫名稱苟耻,默認(rèn)值:"udp"
retention-policy = "" # 存儲策略,無默認(rèn)值
batch-size = 5000
batch-pending = 10
batch-timeout = "1s"
read-buffer = 0 # udp讀取buffer的大小扶檐,0表示使用操作系統(tǒng)提供的值凶杖,如果超過操作系統(tǒng)的默認(rèn)配置則會(huì)出錯(cuò)。 該配置的默認(rèn)值:0
14蘸秘、continuous_queries
[continuous_queries]
enabled = true # enabled 是否開啟CQs官卡,默認(rèn)值:true
log-enabled = true # 是否開啟日志蝗茁,默認(rèn)值:true
run-interval = "1s" # 時(shí)間間隔醋虏,默認(rèn)值:"1s"
二、安裝Influx-proxy
依賴的環(huán)境有:Golang >= 1.7 Redis-server Python >= 2.7 哮翘,redis使用已有的集群颈嚼,這里不再安裝。
1饭寺、下載golang版本https://golang.google.cn/dl/
2阻课、解壓到指定文件夾叫挟,這里我解壓到 /usr/local 目錄下,這也是官方文檔推薦的位置限煞。
tar -C /usr/local -xzvf go1.13.8.linux-amd64.tar.gz
3抹恳、創(chuàng)建工作目錄,我把 Go 代碼放在自己的用戶目錄下署驻,根據(jù)自己的需要進(jìn)行創(chuàng)建即可奋献。
mkdir -p ~/code/go
4、配置環(huán)境變量
sudo vi /etc/profile
# 在尾部寫入
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/home/hesunfly/code/go
# 保存退出
:wq
source /etc/profile
5旺上、測試是否生效:
go env
三瓶蚂、安裝python
1、安裝下載好的所有的rpm包(使用最新的gcc安裝包)
rpm -Uvh --force --nodeps *rpm
解壓zlib
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
2宣吱、執(zhí)行安裝命令
./configure --prefix=/usr/local/python
make
make install
/home/root/code/go/src/github.com/shell909090/influx-proxy/bin
3窃这、將go目錄下的依賴庫上傳到go的src目錄
在influx-proxy下執(zhí)行
python config.py
make
啟動(dòng)命令:
nohup ./influx-proxy -redis 192.168.10.195:26379,192.168.10.124:26379,192.168.10.100:26379 -redis-pwd 123456 -redis-db 1 &