influxdb 筆記: 寫高可用 Relay

G8bao7發表於2016-11-29



# 依賴 go 1.5++

### 原理
只負責write的高可用,write時根據配置的每個節點都要寫一次,相當於多寫
read需要其他工具做Load Balance

# 安裝,Install influxdb-relay to your $GOPATH/bin
go get -u github.com/influxdata/influxdb-relay

### docker 編譯
Building
The recommended method for building influxdb-relay is to use Docker and the included Dockerfile_build_ubuntu64 Dockerfile, which includes all of the necessary dependencies.

docker run -v $(pwd):/root/go/src/github.com/influxdata/influxdb-relay influxdb-relay-builder --help
docker build -f Dockerfile_build_ubuntu64 -t influxdb-relay-builder:latest 
docker run --rm -v $(pwd):/root/go/src/github.com/influxdata/influxdb-relay influxdb-relay-builder
# Packages
# To build packages for other platforms or architectures, use the --platform and --arch options. For example, to build an amd64 package for Mac OS X, use the options --package --platform darwin.
docker run -v $(pwd):/root/go/src/github.com/influxdata/influxdb-relay influxdb-relay-builder --package

### 缺陷
# 手動在所有節點上建立資料庫
write操作並不包含建立資料庫,所以需要手動在所有節點上提前建立資料庫

# 故障節點恢復後的控制
叢集(A,B),如果B當機了,當機的這個時間段內的A上的所有寫入都會被快取起來(超過buffer-size-mb則會丟棄,輸出錯誤日誌),當B恢復後,則會將快取的操作在B上重放一次,但如果在重放期間,B上對外仍然可寫(bug產生的原因)。
如何手動控制B提供寫服務


##################
###### 搭建叢集
# node_a, node_b 按標準安裝好
node_relay: 192.168.1.112
node_a: 192.168.1.12
node_b: 192.168.1.15
##################

# 生成 http使用的pem, 密碼: influxdb123
openssl genrsa -des3 -out /etc/influxdb/influxdb-relay.pem 2048

# vim /etc/influxdb/relay.toml
[[http]]
name = "influxdb-http-dba"
bind-addr = "0.0.0.0:9096"
output = [
    { name="http-12", location = "http://192.168.1.12:8086/write", timeout="10s", buffer-size-mb = 100, max-batch-kb = 50, max-delay-interval = "5s" },
    { name="http-15", location = "http://192.168.1.15:8086/write", timeout="10s", buffer-size-mb = 100, max-batch-kb = 50, max-delay-interval = "5s" },
]

[[udp]]
name = "influxdb-udp-dba"
bind-addr = "0.0.0.0:9099"
read-buffer = 0
precision = "n"
output = [
    { name="udp-12", location="192.168.1.12:8089", mtu=512 },
    { name="udp-15", location="192.168.1.15:8089", mtu=1024 },
]

# 啟動
nohup $GOPATH/bin/influxdb-relay -config /etc/influxdb/relay.toml >/tmp/influxdb_relay.log 2>/dev/null &

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26250550/viewspace-2129322/,如需轉載,請註明出處,否則將追究法律責任。

相關文章