cratedb 集群 docker-compose 安装试用

关于集群的配置说明可以参考官方文档,或者es 文档

详细代码参考 https://github.com/rongfengliang/cratedb-cluster-docker

参考配置

  • docker-compose
version: "3"
services:
  crate1:
    image: crate
    volumes:
    - "./data1:/data"
    - "./1.yaml:/crate/config/crate.yml"
    ports:
    - "4200:4200"
    - "4300:4300"
    - "5432:5432"
  crate2:
    image: crate
    volumes:
    - "./data2:/data"
    - "./2.yaml:/crate/config/crate.yml"
    ports:
    - "4201:4200"
    - "4301:4300"
    - "5433:5432"
  crate3:
    image: crate
    volumes:
    - "./data3:/data"
    - "./3.yaml:/crate/config/crate.yml"
    ports:
    - "4202:4200"
    - "4302:4300"
    - "5434:5432"
  • 配置文件
master(一个):

1.yaml:

cluster.name: cratecluster
node.name: node1
node.master: true
node.data: true
http.port: 4200
psql.port: 5432
transport.tcp.port: 4300
discovery.zen.ping.unicast.hosts: ["crate1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
gateway.expected_nodes: 3
gateway.recover_after_nodes: 2
network.host: _local_,_site_
path.logs: /data/log
path.data: /data/data
blobs.path: /data/blobs

node(data):

2.yaml

cluster.name: cratecluster
node.name: node2
node.master: false
node.data: true
http.port: 4200
psql.port: 5432
transport.tcp.port: 4300
discovery.zen.ping.unicast.hosts: ["crate1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
gateway.expected_nodes: 3
gateway.recover_after_nodes: 2
network.host: _local_,_site_
path.logs: /data/log
path.data: /data/data
blobs.path: /data/blobs

3.yaml:

cluster.name: cratecluster
node.name: node3
node.master: false
node.data: true
http.port: 4200
psql.port: 5432
transport.tcp.port: 4300
discovery.zen.ping.unicast.hosts: ["crate1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
network.host: _local_,_site_
gateway.expected_nodes: 3
gateway.recover_after_nodes: 2
path.logs: /data/log
path.data: /data/data
blobs.path: /data/blobs

启动&&运行

  • 启动
docker-compose up -d
  • 查询集群节点
select count(*) from sys.nodes;
  • 查询node check
select id, node_id, description from sys.node_checks order by id, node_id;

参考界面

操作

  • 创建数据表
create table demoapp(id int ,name string, age int);

  • 插入数据
insert into demoapp(id,name,age) values(3,'dalong',3444);

  • 查询数据
select * from demoapp limit 100;

  • join 查询
 select a.* from tweets a join demoapp b on a.id = b.id limit 100;

  • 分片状态

  • 集群状态

参考资料

https://crate.io/docs/crate/reference/en/latest/config/node.html
https://crate.io/docs/crate/reference/en/latest/admin/system-information.html#routing-allocation-disk-watermark-low
https://crate.io/docs/crate/guide/en/latest/scaling/multi-node-setup.html
https://github.com/rongfengliang/cratedb-cluster-docker

posted on 2018-08-06 10:25  荣锋亮  阅读(760)  评论(0编辑  收藏  举报

导航