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

  • A+
所属分类:Linux  数据库

节点IP
Node1: 172.16.10.23
Node2: 172.16.10.24
Node3: 172.16.10.25
Node4: 172.16.10.26
Node5: 172.16.10.27

[root@DS-VM-Node23 ~]# yum install -y gcc gcc-c++ make zlib-devel readline-devel sqlite-devel openssl-devel
[root@DS-VM-Node23 ~]# mkdir -p /tmp/python3 && cd /tmp/python3/
[root@DS-VM-Node23 /tmp/python3]# URL=https://www.python.org/ftp/python
[root@DS-VM-Node23 /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-Node23 /tmp/python3]# ./configure --prefix=/usr/local/python3 && make -j$(getconf _NPROCESSORS_ONLN) && make install
[root@DS-VM-Node23 /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-Node23 ~]# curl https://bootstrap.pypa.io/get-pip.py | python3
[root@DS-VM-Node23 ~]# 
#一键安装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-Node23 ~]# groupadd -g 400 -r crate
[root@DS-VM-Node23 ~]# useradd -u 400 -r -s /sbin/nologin -g 400 -d /data/CrateDB -m -c 'crate' crate
[root@DS-VM-Node23 ~]# sudo -u crate mkdir -p /data/CrateDB/{data,logs,backup}
[root@DS-VM-Node23 ~]# mkdir -p /var/run/crate && chown -R crate.crate /var/run/crate
[root@DS-VM-Node23 ~]# curl -Lk onekey.sh/install_tomcat|bash -s jdk8
[root@DS-VM-Node23 ~]# 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-Node23 ~]# echo "export PATH=/data/CrateDB/bin:\$PATH" > /etc/profile.d/cratedb.sh && . /etc/profile.d/cratedb.sh
[root@DS-VM-Node23 ~]# cat >> /etc/security/limits.conf <<-EOF
crate soft nofile 65536
crate hard nofile 65536
EOF
[root@DS-VM-Node23 ~]# echo 'vm.max_map_count=655360' >> /etc/sysctl.conf && sysctl -p
[root@DS-VM-Node23 ~]# 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
[root@DS-VM-Node23 ~]# cat > /etc/logrotate.d/crate <<-EOF
/data/CrateDB/logs/*.log {
        daily
        rotate 14
        copytruncate
        compress
        missingok
        notifempty
}
EOF
[root@DS-VM-Node23 ~]# curl -Lk https://raw.githubusercontent.com/xiaoyawl/centos_init/master/init.d/crate > /etc/init.d/crate && chmod +x /etc/init.d/crate
[root@DS-VM-Node23 ~]# chmod +x /etc/init.d/crate
[root@DS-VM-Node23 ~]# 

配置文件

#下面的配置文件以Node1为示范,其他节点请对应修改。
[root@DS-VM-Node23 ~]# echo -e '\n\ncluster.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)
network.publish_host: 172.16.10.23
#设置其他节点将用于与此节点通信的地址。 如果未设置,则会自动导出。 它必须指向一个实际的IP地址。
#network.host: 172.16.10.23
#设置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.unicast.hosts: ["172.16.10.23:4300", "172.16.10.24:4300", "172.16.10.25:4300", "172.16.10.26:4300", "172.16.10.27:4300"]' >> /data/CrateDB/config/crate.yml
[root@DS-VM-Node23 ~]# 

启动节点

[root@DS-VM-Node23 ~]# service crate start
Starting crate (via systemctl):                            [  确定  ]
[root@DS-VM-Node23 ~]# ps aux | grep crate| grep -v grep
crate    25966  0.7 10.1 5937572 831880 ?      Sl   11:04   0:33 /bin/java -XX:+UseCompressedOops -Xms2g -Xmx2g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -cp /data/CrateDB/lib/*:/data/CrateDB/lib/enterprise/*:/data/CrateDB/lib/sigar/* io.crate.bootstrap.CrateDB -Cpidfile=/var/run/crate/crate.pid -Cpath.home=/data/CrateDB -Cpath.conf=/data/CrateDB/config -Cpath.logs=/data/CrateDB/logs -d
[root@DS-VM-Node23 ~]# ss -tnl
State      Recv-Q Send-Q                                                                 Local Address:Port                                                                                Peer Address:Port              
LISTEN     0      128                                                                                *:10050                                                                                          *:*                  
LISTEN     0      32768                                                                              *:4200                                                                                           *:*                  
LISTEN     0      32768                                                                              *:4300                                                                                           *:*                  
LISTEN     0      128                                                                                *:22                                                                                             *:*                  
LISTEN     0      32768                                                                              *:5432                                                                                           *:*                  
LISTEN     0      100                                                                        127.0.0.1:25                                                                                             *:*                  
LISTEN     0      128                                                                        127.0.0.1:6010                                                                                           *:*                  
[root@DS-VM-Node23 ~]# 

检查集群

[root@DS-VM-Node23 ~]# crash
+-----------------------+--------------+---------+-----------+---------+
| server_url            | node_name    | version | connected | message |
+-----------------------+--------------+---------+-----------+---------+
| http://localhost:4200 | crate_node_1 | 2.1.5   | TRUE      | OK      |
+-----------------------+--------------+---------+-----------+---------+
cr> \c 172.16.10.23:4200
+--------------------------+--------------+---------+-----------+---------+
| server_url               | node_name    | version | connected | message |
+--------------------------+--------------+---------+-----------+---------+
| http://172.16.10.23:4200 | crate_node_1 | 2.1.5   | TRUE      | OK      |
+--------------------------+--------------+---------+-----------+---------+
cr> create table tweets (created_at timestamp, id string primary key, retweeted boolean, source string INDEX using fulltext, text string INDEX using fulltext, user_id string);
CREATE OK, 1 row affected  (1.186 sec)
cr> insert into tweets values (1394182937, '1', true, 'web', 'Don''t panic', 'Douglas');
INSERT OK, 1 row affected  (0.146 sec)
cr> show tables;
+------------+
| table_name |
+------------+
| tweets     |
+------------+
SHOW 1 row in set (0.005 sec)
cr> select * from tweets;
+------------+----+-----------+--------+-------------+---------+
| created_at | id | retweeted | source | text        | user_id |
+------------+----+-----------+--------+-------------+---------+
| 1394182937 | 1  | TRUE      | web    | Don't panic | Douglas |
+------------+----+-----------+--------+-------------+---------+
SELECT 1 row in set (0.104 sec)
cr> drop table tweets;
DROP OK, 1 row affected  (0.072 sec)
cr> show tables;
+------------+
| table_name |
+------------+
+------------+
SHOW 0 rows in set (0.001 sec)
cr> \q
Bye!
[root@DS-VM-Node23 ~]# 

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

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

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

lookback

发表评论

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