Linux之CentOS 7 安装CrateDB集群

  • A+
摘要

随手小计下CrateDB集群的安装和配置

Node1:172.30.5.69

Node2:172.30.5.70

Node3:172.30.5.71

Node4:172.30.5.72

Node5:172.30.5.73

先安装下python3

[root@DS-VM-Node69 ~]# yum install -y gcc gcc-c++ make zlib-devel readline-devel sqlite-devel openssl-devel
[root@DS-VM-Node69 ~]# mkdir -p /tmp/python3 && cd /tmp/python3/
[root@DS-VM-Node69 /tmp/python3]# URL=https://www.python.org/ftp/python
[root@DS-VM-Node69 /tmp/python3]# curl -Lks "${URL}"/$(curl -Lks "${URL}"|awk -F'[/"]' '$2~/^3/{a=$2}END{print a}')/$(curl -Lks "${URL}"/$(curl -Lks "${URL}"|awk -F'[/"]' '$2~/^3/{a=$2}END{print a}')| awk -F'[><]' '$3~/tar.xz$/{print $3}')|tar -xJ -C /tmp/python3 --strip-components=1
[root@DS-VM-Node69 /tmp/python3]# ./configure --prefix=/usr/local/python3 && make -j$(getconf _NPROCESSORS_ONLN) && make install
[root@DS-VM-Node69 /tmp/python3]# echo 'export PATH=/usr/local/python3/bin:$PATH' > /etc/profile.d/py3.sh && . /etc/profile.d/py3.sh && cd && rm -rf /tmp/python3
[root@DS-VM-Node69 ~]# curl https://bootstrap.pypa.io/get-pip.py | python3
#一键安装python3
TmpDir=/tmp/python3 && URL=https://www.python.org/ftp/python && yum install -y gcc gcc-c++ make zlib-devel readline-devel sqlite-devel openssl-devel && mkdir -p ${TmpDir} && curl -Lks "${URL}"/$(curl -Lks "${URL}"|awk -F'[/"]' '$2~/^3/{a=$2}END{print a}')/$(curl -Lks "${URL}"/$(curl -Lks "${URL}"|awk -F'[/"]' '$2~/^3/{a=$2}END{print a}')| awk -F'[><]' '$3~/tar.xz$/{print $3}')|tar -xJ -C ${TmpDir} --strip-components=1 && ./configure --prefix=/usr/local/python3 && make -j$(getconf _NPROCESSORS_ONLN) -C ${TmpDir} && make install -C ${TmpDir} && echo 'export PATH=/usr/local/python3/bin:$PATH' > /etc/profile.d/py3.sh && . /etc/profile.d/py3.sh && rm -rf ${TmpDir} && curl https://bootstrap.pypa.io/get-pip.py | python3

安装CrateDB

[root@DS-VM-Node69 ~]# groupadd -g 400 -r crate
[root@DS-VM-Node69 ~]# useradd -u 400 -r -s /sbin/nologin -g 400 -d /data/CrateDB -m -c 'crate' crate
[root@DS-VM-Node69 ~]# sudo -u crate mkdir -p /data/CrateDB/{work,data,logs,backup}
[root@DS-VM-Node69 ~]# curl -Lk onekey.sh/install_tomcat|bash -s jdk8
[root@DS-VM-Node69 ~]# Url=https://cdn.crate.io/downloads/releases/ && curl -Lk "$(curl -Ls "${Url}"|awk -F'"' '$2~/^crate-[0-9].*gz$/{a="'${Url}'"$2}END{print a}')"|tar -xz -C /data/CrateDB/ --strip-components=1
[root@DS-VM-Node69 ~]# echo "export PATH=/data/CrateDB/bin:\$PATH" > /etc/profile.d/cratedb.sh && . /etc/profile.d/cratedb.sh
#下面的配置文件以Node1为示范,其他节点请对应修改。
[root@DS-VM-Node69 ~]# echo -e '\n\ncluster.name: history_bet_cluster
node.name: crate_node_1
index.number_of_replicas: 1
path.conf: /data/CrateDB/config
path.data: /data/CrateDB/data
path.work: /data/CrateDB/work
path.logs: /data/CrateDB/logs
path.plugins: /data/CrateDB/plugins

network.bind_host: 0.0.0.0
#设置具体绑定地址(IPv4或IPv6)
network.publish_host: 172.30.5.69
#设置其他节点将用于与此节点通信的地址。 如果未设置,则会自动导出。 它必须指向一个实际的IP地址。
#network.host: 172.30.5.69
#设置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.zen.ping.timeout: 5s
discovery.zen.fd.ping_interval: 10s
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["172.30.5.69:4300", "172.30.5.70:4300", "172.30.5.71:4300", "172.30.5.72:4300", "172.30.5.73:4300"]' >> /data/CrateDB/config/crate.yml
[root@DS-VM-Node69 ~]# sudo -u crate /data/CrateDB/bin/crate -d

检查集群

[root@DS-VM-Node69 ~]# /data/CrateDB/bin/crash
cr> \c 172.30.5.69:4200
+-------------------------+--------------+---------+-----------+---------+
| server_url              | node_name    | version | connected | message |
+-------------------------+--------------+---------+-----------+---------+
| http://172.30.5.69:4200 | crate_node_1 | 1.0.3   | TRUE      | OK      |
+-------------------------+--------------+---------+-----------+---------+
CONNECT OK
CLUSTER CHECK OK
TYPES OF NODE CHECK OK
cr> CREATE TABLE user (id INT primary key,name STRING,day_joined TIMESTAMP,bio STRING INDEX using fulltext,address OBJECT (dynamic) AS (city STRING,country STRING));
CREATE OK, 1 row affected  (0.376 sec)
cr> show tables;
+------------+
| table_name |
+------------+
| user       |
+------------+
SHOW 1 row in set (0.011 sec)
cr> select * from user;
+---------+-----+------------+----+------+
| address | bio | day_joined | id | name |
+---------+-----+------------+----+------+
+---------+-----+------------+----+------+
SELECT 0 rows in set (0.040 sec)
cr> drop table user;
DROP OK, 1 row affected  (0.021 sec)
cr> show tables;
+------------+
| table_name |
+------------+
+------------+
SHOW 0 rows in set (0.002 sec)
cr> \q
Bye!
[root@DS-VM-Node69 ~]# 

Linux之CentOS 7 安装CrateDB集群

Linux之CentOS 7 安装CrateDB集群

lookback

发表评论

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