Linux之CentOS 7 安装CrateDB 3.1.3版本集群

  • A+
所属分类:数据库

安装Python3.7

yum install -y gcc gcc-c++ make zlib-devel readline-devel sqlite-devel openssl-devel bzip2-devel ncurses-devel tk-devel libffi-devel && \
mkdir -p /tmp/python3 && \
cd /tmp/python3/ && \
URL=https://www.python.org/ftp/python && \
RELEASE=$(curl -Lks "${URL}"|awk -F'[/"]' '$2~/^3/{a=$2}END{print a}') && \
FILENAME=$(curl -Lks "${URL}"/${RELEASE}| awk -F'[><]' '$3~/tar.xz$/{print $3;exit}') && \
URL="${URL}/${RELEASE}/${FILENAME}" && \
echo "=== Start Download ${URL}" && \
curl -Lk ${URL}|tar -xJ -C /tmp/python3 --strip-components=1 && \
./configure --prefix=/usr/local/python3 --enable-optimizations && \
make -j$(getconf _NPROCESSORS_ONLN) altinstall && \
make install && \
echo 'export PATH=/usr/local/python3/bin:$PATH' > /etc/profile.d/py3.sh \
&& . /etc/profile.d/py3.sh && cd - && \
\rm -rf /tmp/python3 && curl https://bootstrap.pypa.io/get-pip.py | python3

安装JDK1.8.191

curl -Lkj 'https://javadl.oracle.com/webapps/download/AutoDL?BundleId=235716_2787e4a523244c269598db4e85c51e0c' -o jdk-8u191-linux-x64.rpm
yum install ./jdk-8u191-linux-x64.rpm -y

添加运行用户和运行目录

groupadd -g 400 -r crate && \
useradd -u 400 -r -s /sbin/nologin -g 400 -d /data/CrateDB -m -c 'crate' crate && \
sudo -u crate mkdir -p /data/CrateDB/{data,logs,backup} && \
mkdir -p /var/{run,log,lib}/crate &&  chown -R crate.crate /var/{run,log,lib}/crate /data/CrateDB/

下载CrateDB

Url=https://cdn.crate.io/downloads/releases/ && curl -Lk "$(curl -Ls "${Url}"|awk -F'"' '$2~/^crate-3\..*gz$/{a="'${Url}'"$2}END{print a}')"|tar -xz -C /data/CrateDB/ --strip-components=1
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=2g
 
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终端控制

pip3 install crash

修改配置文件

cat >> /data/CrateDB/config/crate.yml <<EOF
license.enterprise: false
#不启用企业版的试用环境,直接使用社区版

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

配置启动控制文件

curl -Lk https://github.com/xiaoyawl/centos_init/raw/master/init.d/crate.service > /usr/lib/systemd/system/crate.service
systemctl daemon-reload

启动单节点模式

systemctl start crate.service

Linux之CentOS 7 安装CrateDB 3.1.3版本集群

集群环境配置文件

cat >> /data/CrateDB/config/crate.yml <<EOF
network.publish_host: 172.20.255.241
#设置其他节点将用于与此节点通信的地址。 如果未设置,则会自动导出。 它必须指向一个实际的IP地址。
#network.host: 172.20.255.241
#设置bind_host和publish_host两者
gateway.recover_after_nodes: 2
#值要大于discovery.zen.minimum_master_nodes且小于等于gateway.expected_nodes
gateway.expected_nodes: 3
#值要等于集群总节点数
discovery.zen.minimum_master_nodes: 3
#值最小设置为 (集群总节点数/2)+1
discovery.zen.ping.unicast.hosts: ["172.20.255.242:4300", "172.20.255.241:4300", "172.20.255.240:4300"]
EOF

Linux之CentOS 7 安装CrateDB 3.1.3版本集群

如果启用了企业版或者在使用企业版的试用,那么WEB-GUI是需要验证才能进去的,这时候我们需要在数据库里面创建用户和授权,集群中随便选择一个节点执行授权命令就可以。

CREATE  USER  admin  WITH  (password  =  'admin');
GRANT DQL TO admin;
GRANT DDL TO admin;
GRANT DML TO admin;

Linux之CentOS 7 安装CrateDB 3.1.3版本集群

lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: