tile38 复制配置
基于复制我们可以保证tile38 server 的ha
环境准备
- docker-compose 文件
说明里面多了一个webhook 的服务,可以不用管
version: "3"
services:
app:
image: tile38/tile38
ports:
- "9851:9851"
app2:
image: tile38/tile38
ports:
- "9852:9851"
benthos:
image: jeffail/benthos
volumes:
- "./conf/webhook.yaml:/benthos.yaml"
ports:
- "4195:4195"
启动&&配置
- 启动
docker-compose up -d
- 配置
进入容器
docker-compose exec app2 sh
我们打算让app 为leader
tile38-cli
127.0.0.1:9851> FOLLOW app 9851
{"ok":true,"elapsed":"3.217411ms"}
127.0.0.1:9851>
- 效果
添加数据在app
SET key1 obj1 POINT 33.1 -112.4
app2 获取数据
从下边的日志也可以看出直接在follower 添加数据是不允许的
SET key1 obj1 POINT 33.1 -112.4
(error) not the leader
127.0.0.1:9851> get key1 obj1
{"ok":true,"object":{"type":"Point","coordinates":[-112.4,33.1]},"elapsed":"7.939µs"}