安裝 InfluxDB Cluster
- CentOS 6.x x86_64 環境
- InfluxDB 0.10.x
- Hybrid node :
- infxnode1 : 140.92.143.36
- infxnode2 : 140.92.143.43
- infxnode3 : 140.92.143.86
安裝 InfluxDB
- 建立 InfluxDB yum Repos
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo [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 EOF
- 透過 yum 安裝
su - root yum install influxdb chkconfig influxdb on servvice influxdb start vi /etc/sysconfig/iptables
: -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT # InfluxDB -A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8083 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8086 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 8091 -j ACCEPT :
service iptables reload
- 透過 http://[ip]:8083/ 就可以看到安裝後的基本操作管理網頁
- 透過 tail -f /var/log/influxdb/influxd.log 可以看到運行紀錄
InfluxDB Cluster 設定
- 設定 /etc/hosts
vi /etc/hosts
: 140.92.143.36 infxnode1 140.92.143.43 infxnode2 140.92.143.86 infxnode3
- Node 1 :
vi /etc/influxdb/influxdb.conf
: [meta] enabled = true : bind-address = "infxnode1:8088" http-bind-address = "infxnode1:8091" : [data] enabled = true [http] : bind-address = "infxnode1:8086"
rm -rf /var/lib/influxdb/* service influxdb restart
- Node 2 :
service influxdb stop vi /etc/influxdb/influxdb.conf
: [meta] enabled = true : bind-address = "infxnode2:8088" http-bind-address = "infxnode2:8091" : [data] enabled = true [http] : bind-address = "infxnode2:8086"
vi /etc/default/influxdb
INFLUXD_OPTS="-join infxnode1:8091"
rm -rf /var/lib/influxdb/* service influxdb start
- Node 3 :
service influxdb stop vi /etc/influxdb/influxdb.conf
: [meta] enabled = true : bind-address = "infxnode3:8088" http-bind-address = "infxnode3:8091" : [data] enabled = true [http] : bind-address = "infxnode3:8086" </file<code sh> vi /etc/default/influxdb </code><file> INFLUXD_OPTS="-join infxnode1:8091"
rm -rf /var/lib/influxdb/* service influxdb start
檢查與使用
- 透過每一台的管理界面 Exp. http://140.92.143.86:8083/ 輸入 SHOW SERVERS 就可以看到目前 Cluster 的狀況
data_nodes id http_addr tcp_addr 1 "infxnode1:8086" "infxnode1:8088" 3 "infxnode3:8086" "infxnode3:8088" 5 "infxnode2:8086" "infxnode2:8088" meta_nodes id http_addr tcp_addr 1 "infxnode1:8091" "infxnode1:8088" 2 "infxnode3:8091" "infxnode3:8088" 4 "infxnode2:8091" "infxnode2:8088"
增加一個 Node
- 增加一個 Hybrid node :
- infxnode4 : 140.92.143.17
- 更新 node1 ~ node 4 /etc/hosts 內的定義, 設定 /etc/hosts
vi /etc/hosts
: 140.92.143.36 infxnode1 140.92.143.43 infxnode2 140.92.143.86 infxnode3 140.92.143.17 infxnode4
- 再來執行與 node2 ~ node3 的設定相同
移除一個 Node
- 移除一個 Hybrid node :
- infxnode3 : 140.92.143.86
- 使用 influx CLI 操作
- 連入 influxdb cluster 其中一台 Exp. infxnode3
influx -database sysmon01 -host infxnode3 -port 8086 show servers
> show servers name: data_nodes ---------------- id http_addr tcp_addr 3 infxnode3:8086 infxnode3:8088 5 infxnode2:8086 infxnode2:8088 7 localhost:8086 infxnode4:8088 10 infxnode1:8086 infxnode1:8088 11 infxnode5:8086 infxnode5:8088 name: meta_nodes ---------------- id http_addr tcp_addr 1 infxnode1:8091 infxnode1:8088 2 infxnode3:8091 infxnode3:8088 4 infxnode2:8091 infxnode2:8088 6 infxnode4:8091 infxnode4:8088 8 infxnode5:8091 infxnode5:8088
- 看到 indxnode3 在 data server id 是 3
drop data server 3 show servers
name: data_nodes ---------------- id http_addr tcp_addr 5 infxnode2:8086 infxnode2:8088 7 localhost:8086 infxnode4:8088 10 infxnode1:8086 infxnode1:8088 11 infxnode5:8086 infxnode5:8088 name: meta_nodes ---------------- id http_addr tcp_addr 1 infxnode1:8091 infxnode1:8088 2 infxnode3:8091 infxnode3:8088 4 infxnode2:8091 infxnode2:8088 6 infxnode4:8091 infxnode4:8088 8 infxnode5:8091 infxnode5:8088
- 這樣就移除掉 node3
匯出與匯入
- 匯出資料 Exp. 將 sysmon01 透過 infxnode3 匯出到 /root/sysmon01 目錄內
influxd backup -database sysmon01 -host infxnode3:8088 /root/sysmon01 ls -lt /root/sysmon01
[root@influxdb3 sysmon01]# ls -lt /root/sysmon01 總計 25700 -rw-r--r--. 1 root root 4326400 2016-03-22 18:58 sysmon01.default.00013.00 -rw-r--r--. 1 root root 8824320 2016-03-22 18:58 sysmon01.default.00003.00 -rw-r--r--. 1 root root 1161 2016-03-22 18:58 meta.00
- 清空 Influxdb Cluster node 內所有 /var/lib/influxdb/ 內資料檔案
service influxdb stop rm -rf /var/lib/influxdb/*
- 在重新啟動 Influxdb Cluster
service influxdb start
- 關閉順序 node 5 4 3 2 1(為主要同步點)
- 啟動順訊 node 1(為主要同步點) 2 3 4 5
- 主要同步點各個 node 內 /etc/default/influxdb 設定, 本身不要設定
- 匯入資料 Exp. 將 /root/sysmon01 目錄內 sysmon01 備份資料匯入 infxnode3
influxd restore -database sysmon01 -datadir /var/lib/influxdb/data /root/sysmon01 chown -R influxdb:influxdb /var/lib/influxdb/*