堕落不振功业废,勤耕不辍日月新

Linux之CentOS 7 上CrateDB 4 社区版搭建集群

C/C++ hailen 18℃

CrateDB Community Edition(社区版获取)

为什么用社区版?因为CrateDB社区版(CrateDB CE)不包含任何Enterprise功能,但可以在任意数量的节点上运行。

CrateDB社区版必须从源代码构建。

系统安装java12

[root@DT_Node-172_30_7_219 ~]# wget http://mirrors.dtops.cc/java/12/12.0.2%2B10/jdk-12.0.2_linux-x64_bin.rpm
[root@DT_Node-172_30_7_219 ~]# yum install -y ./jdk-12.0.2_linux-x64_bin.rpm
[root@DT_Node-172_30_7_219 ~]# java -version
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

从源码构建CrateDB社区版

[root@DT_Node-172_30_7_219 ~]# git clone https://github.com/crate/crate /tmp/crate
[root@DT_Node-172_30_7_219 ~]# cd /tmp/crate
[root@DT_Node-172_30_7_219 /tmp/crate]# git submodule update --init
[root@DT_Node-172_30_7_219 /tmp/crate]# git checkout 4.0.3
[root@DT_Node-172_30_7_219 /tmp/crate]# ./gradlew clean communityEditionDistTar

不想构建的也可以直接用我这边构建好的

http://mirrors.dtops.cc/sql/CrateDB/crate-ce-4.0.3-1b7058f.tar.gz

Linux之CentOS 7 上CrateDB 4 社区版搭建集群

安装Python3

[root@DT_Node-172_30_7_219 /tmp/crate]# TmpDir=/tmp/python3 && mkdir -p ${TmpDir} && cd ${TmpDir}
[root@DT_Node-172_30_7_219 /tmp/python3]# yum install -y gcc gcc-c++ make zlib-devel readline-devel sqlite-devel openssl-devel libffi-devel curl
[root@DT_Node-172_30_7_219 /tmp/python3]# curl -Lk https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz|tar -xJ -C ${TmpDir} --strip-components=1
[root@DT_Node-172_30_7_219 /tmp/python3]# cd ${TmpDir}
[root@DT_Node-172_30_7_219 /tmp/python3]# ./configure --prefix=/usr/local/python3
[root@DT_Node-172_30_7_219 /tmp/python3]# make -j$(getconf _NPROCESSORS_ONLN)
[root@DT_Node-172_30_7_219 /tmp/python3]# make install
[root@DT_Node-172_30_7_219 /tmp/python3]# echo 'export PATH=/usr/local/python3/bin:$PATH' > /etc/profile.d/py3.sh
[root@DT_Node-172_30_7_219 /tmp/python3]# . /etc/profile.d/py3.sh
[root@DT_Node-172_30_7_219 /tmp/python3]# curl https://bootstrap.pypa.io/get-pip.py | python3
[root@DT_Node-172_30_7_219 /tmp/python3]# cd && 
m -rf ${TmpDir}

添加运行用户和运行目录

[root@DT_Node-172_30_7_219 ~]# groupadd -g 400 -r crate
[root@DT_Node-172_30_7_219 ~]# useradd -u 400 -r -s /sbin/nologin -g 400 -d /data/CrateDB -m -c 'crate' crate
[root@DT_Node-172_30_7_219 ~]# mkdir -p /data/CrateDB/{data,logs,backup}
[root@DT_Node-172_30_7_219 ~]# mkdir -p /var/{run,log,lib}/crate &&  chown -R crate.crate /var/{run,log,lib}/crate /data/CrateDB/

部署CrateDB

[root@DT_Node-172_30_7_219 ~]# tar xzf /tmp/crate/app/build/distributions/crate-ce-4.0.3-1b7058f.tar.gz -C /data/CrateDB/ --strip-components=1
[root@DT_Node-172_30_7_219 ~]# chown -R crate.crate /data/CrateDB/
[root@DT_Node-172_30_7_219 ~]# echo 'export PATH=/data/CrateDB/bin:$PATH' > /etc/profile.d/cratedb.sh && . /etc/profile.d/cratedb.sh

配置系统环境

cat >> /etc/security/limits.conf <<-EOF
crate soft nofile 65536
crate hard nofile 65536
EOF
echo 'vm.max_map_count=655360' >> /etc/sysctl.conf && sysctl -p
cat > /etc/sysconfig/crate <<-EOF
# Recommended memory settings for production:
# - assign half of the OS memory to CrateDB
#   (e.g. 26g, stay below ~30G to benefit from CompressedOops)
# - disable swapping my setting bootstrap.mlockall in crate.yml
  
CRATE_HEAP_SIZE=512m
#我这里是测试环境所以给的小(我系统内存才1G)
  
CRATE_HOME=/data/CrateDB
CRATE_PATH_LOG=/data/CrateDB/logs
CRATE_PATH_CONF=/data/CrateDB/config
CRATE_CONFIG=/data/CrateDB/config/crate.yml
  
CRATE_INCLUDE=/data/CrateDB/bin/crate.in.sh
EOF
cat > /etc/logrotate.d/crate <<-EOF
/data/CrateDB/logs/*.log {
        daily
        rotate 14
        copytruncate
        compress
        missingok
        notifempty
}
EOF

安装crash终端控制

[root@DT_Node-172_30_7_219 ~]# pip3 install crash

修改配置文件

cat >> /data/CrateDB/config/crate.yml <<EOF
 
cluster.name: history_bet_cluster
node.name: crate_node_1
stats.enabled: true
#path.conf: /data/CrateDB/config
#path.data: /data/CrateDB/data
#path.logs: /data/CrateDB/logs
#path.plugins: /data/CrateDB/plugins
 
network.bind_host: 0.0.0.0
#设置具体绑定地址(IPv4或IPv6)
EOF

配置启动控制文件

[root@DT_Node-172_30_7_219 ~]# curl -Lk https://github.com/xiaoyawl/centos_init/raw/master/init.d/crate.service > /usr/lib/systemd/system/crate.service
[root@DT_Node-172_30_7_219 ~]# systemctl daemon-reload && systemctl enable crate.service

启动单节点模式

[root@DT_Node-172_30_7_219 ~]# systemctl start crate.service 
[root@DT_Node-172_30_7_219 ~]# systemctl status crate.service 
● crate.service - CrateDB Server
   Loaded: loaded (/usr/lib/systemd/system/crate.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-08-09 09:43:22 CST; 9s ago
     Docs: https://crate.io/docs
 Main PID: 16728 (java)
    Tasks: 17
   Memory: 275.1M
   CGroup: /system.slice/crate.service
           └─16728 /bin/java -Xms512m -Xmx512m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Xlog:gc*,gc+age=trace,safepoint:file=/var/log/crate/gc.log:utctime,pid,tags:filecount=16,filesize=64m -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.ski...

Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,316][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [io.crate.plugin.PluginLoaderPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,316][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [io.crate.plugin.SrvPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,316][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [io.crate.udc.plugin.UDCPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,316][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [org.elasticsearch.analysis.common.CommonAnalysisPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,317][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [org.elasticsearch.discovery.ec2.Ec2DiscoveryPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,317][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [org.elasticsearch.plugin.repository.url.URLRepositoryPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,317][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [org.elasticsearch.repositories.azure.AzureRepositoryPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,317][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [org.elasticsearch.repositories.s3.S3RepositoryPlugin]
Aug 09 09:43:30 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:30,317][INFO ][o.e.p.PluginsService     ] [crate_node_1] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
Aug 09 09:43:31 DS-VM-Node172_30_7_219.cluster.com crate[16728]: [2019-08-09T09:43:31,885][INFO ][o.e.d.DiscoveryModule    ] [crate_node_1] using discovery type [zen] and seed hosts providers [settings]
[root@DT_Node-172_30_7_219 ~]# ss -tnl| awk '/4200|4300|5432/'
LISTEN     0      32768        *:4200                     *:*                  
LISTEN     0      32768        *:4300                     *:*                  
LISTEN     0      32768        *:5432                     *:*                  
[root@DT_Node-172_30_7_219 ~]# 

Linux之CentOS 7 上CrateDB 4 社区版搭建集群

Linux之CentOS 7 上CrateDB 4 社区版搭建集群

配置集群环境(将IP改成对应的IP即可)

cat >> /data/CrateDB/config/crate.yml <<EOF

network.publish_host: 172.25.20.43
#设置其他节点将用于与此节点通信的地址。 如果未设置,则会自动导出。 它必须指向一个实际的IP地址。
#network.host: 172.25.20.43
#设置bind_host和publish_host两者
gateway.recover_after_nodes: 4
#值要大于discovery.zen.minimum_master_nodes且小于等于gateway.expected_nodes
gateway.expected_nodes: 5
#值要等于集群总节点数
#discovery.zen.minimum_master_nodes: 3
#值最小设置为 (集群总节点数/2)+1
discovery.seed_hosts: ["172.25.20.39:4300", "172.25.20.41:4300", "172.25.20.42:4300", "172.25.20.43:4300", "172.25.20.44:4300"]
EOF

Linux之CentOS 7 上CrateDB 4 社区版搭建集群

转载请注明:我是IT » Linux之CentOS 7 上CrateDB 4 社区版搭建集群

喜欢 (0)or分享 (0)