编译cratedb 支持多集群节点部署
很多时候为了体验多集群的特性,但是默认是的3节点的,我们可以修改代码解决
参考代码修改
- 主要是关于企业license 服务的
https://github.com/crate/crate/blob/master/enterprise/licensing/src/main/java/io/crate/license/EnterpriseLicenseService.java#L75
修改参数为自己需要的数量
Dockerfile
需要参考官方docker 信息,配置(crate.yml&&log4j2.properties)以及docker-entrypoint.sh(注意自己的镜像需要添加执行权限)
## -*- docker-image-name: "docker-crate" -*-
#
# Crate Dockerfile
# https://github.com/crate/docker-crate
#
FROM centos:7
RUN groupadd crate && useradd -u 1000 -g crate -d /crate crate
COPY crate-4.4.0-SNAPSHOT-2788b17.tar.gz .
# install crate
RUN yum install -y yum-utils \
&& yum makecache \
&& yum install -y python36 openssl \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& export PLATFORM="$( \
case $(uname --m) in \
x86_64) echo x64_linux ;; \
aarch64) echo aarch64_linux ;; \
esac)" \
&& export GNUPGHOME="$(mktemp -d)" \
&& tar -xf crate-4.4.0-SNAPSHOT-2788b17.tar.gz -C /crate --strip-components=1 \
&& rm crate-4.4.0-SNAPSHOT-2788b17.tar.gz \
&& ln -sf /usr/bin/python3.6 /usr/bin/python3
# install crash
RUN curl -fSL -O https://cdn.crate.io/downloads/releases/crash_standalone_0.26.0 \
&& curl -fSL -O https://cdn.crate.io/downloads/releases/crash_standalone_0.26.0.asc \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 90C23FC6585BC0717F8FBFC37FAAE51A06F6EAEB \
&& gpg --batch --verify crash_standalone_0.26.0.asc crash_standalone_0.26.0 \
&& rm -rf "$GNUPGHOME" crash_standalone_0.26.0.asc \
&& mv crash_standalone_0.26.0 /usr/local/bin/crash \
&& chmod +x /usr/local/bin/crash
ENV PATH /crate/bin:$PATH
# Default heap size for Docker, can be overwritten by args
ENV CRATE_HEAP_SIZE 512M
RUN mkdir -p /data/data /data/log
VOLUME /data
WORKDIR /data
# http: 4200 tcp
# transport: 4300 tcp
# postgres protocol ports: 5432 tcp
EXPOSE 4200 4300 5432
# These COPY commands have been moved before the last one due to the following issues:
# https://github.com/moby/moby/issues/37965#issuecomment-448926448
# https://github.com/moby/moby/issues/38866
COPY --chown=1000:0 config/crate.yml /crate/config/crate.yml
COPY --chown=1000:0 config/log4j2.properties /crate/config/log4j2.properties
LABEL maintainer="Crate.io <office@crate.io>" \
org.opencontainers.image.created="2021-01-06T13:49:59.918942" \
org.opencontainers.image.title="crate" \
org.opencontainers.image.description="CrateDB is a distributed SQL database handles massive amounts of machine data in real-time." \
org.opencontainers.image.url="https://crate.io/products/cratedb/" \
org.opencontainers.image.source="https://github.com/crate/docker-crate" \
org.opencontainers.image.vendor="Crate.io" \
org.opencontainers.image.version="4.4.0"
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["crate"]
参考使用
5 节点的,具体参考github https://github.com/rongfengliang/cratedb4-4-clustere-learning
version: "3"
services:
crate1:
image: dalongrong/cratedb:4.4.0
volumes:
- "./cratedb/data1:/data"
- "./cratedb/1.yaml:/crate/config/crate.yml"
ports:
- "4200:4200"
- "4300:4300"
- "5432:5432"
crate2:
image: dalongrong/cratedb:4.4.0
volumes:
- "./cratedb/data2:/data"
- "./cratedb/2.yaml:/crate/config/crate.yml"
ports:
- "4201:4200"
- "4301:4300"
- "5433:5432"
crate3:
image: dalongrong/cratedb:4.4.0
volumes:
- "./cratedb/data3:/data"
- "./cratedb/3.yaml:/crate/config/crate.yml"
ports:
- "4202:4200"
- "4302:4300"
- "5434:5432"
crate4:
image: dalongrong/cratedb:4.4.0
volumes:
- "./cratedb/data4:/data"
- "./cratedb/4.yaml:/crate/config/crate.yml"
ports:
- "4203:4200"
- "4303:4300"
- "5435:5432"
crate5:
image: dalongrong/cratedb:4.4.0
volumes:
- "./cratedb/data5:/data"
- "./cratedb/5.yaml:/crate/config/crate.yml"
ports:
- "4204:4200"
- "4304:4300"
- "5436:5432"
参考效果
说明
一个可用的docker镜像我已经push dockerhub了dalongrong/cratedb:4.4.0
,但是推荐搭建测试环境使用,如果真要使用
无限制的企业特性最好还是购买企业license
参考资料
https://github.com/rongfengliang/cratedb4-4-clustere-learning
https://github.com/crate/docker-crate
https://github.com/crate/crate
https://github.com/crate/crate/blob/master/devs/docs/basics.rst