influxdb 笔记: 写高可用 Relay


https://github.com/influxdata/influxdb-relay

# 依赖 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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26250550/viewspace-2129322/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值