单节点的cratedb添加一个节点组成一个集群

环境:
OS:centos 7
db:3.2.0

原有节点 新添加节点
192.168.1.118 192.168.1.85


----------------新节点部署cratedb-------------------
1.安装python3
安装步骤可以参考:http://blog.chinaunix.net/uid-77311-id-5787558.html

2.下载cratedb
我这里下载的是:crate-3.2.0-201809190203-616c19f.tar.gz
Cratedb下载地址:https://cdn.crate.io/downloads/releases/nightly/

3.安装java
安装java,确保版本在1.8以上
[[email protected] ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

4.创建crate用户,也可以是其他的用户
因为cratedb不能在root用户下启动,所以需要创建非root用户,我这里创建crate用户
[[email protected] /]# useradd crate
[[email protected] /]# passwd crate
密码和用户名一致

5./etc/security/limits.conf 修改和sysctl修改
在该文件最后面添加如下两项,然后退出重新登录
* hard nofile 65536
* soft nofile 65536

[[email protected] /]# sysctl -w vm.max_map_count=262144


7.准备安装目录
[[email protected] ~]# cd /
[[email protected] /]# mkdir cratedb

8.解压安装
[[email protected] /]# cd /soft
[[email protected] soft]# tar -xvf crate-3.2.0-201809190203-616c19f.tar.gz
[[email protected] soft]# mv crate-3.2.0-201809190203-616c19f /cratedb/crate-3.2.0
[[email protected] /]# chown -R crate.crate /cratedb

9.修改配置文件crate.in.sh(cratedb用户下修改)
配置文件路径为: /cratedb/crate-3.2.0/bin/crate.in.sh
在该配置文件最开始添加如下两项(根据机器实际情况配置):
CRATE_MIN_MEM=2g
CRATE_MAX_MEM=2g

10.修改配置文件
##基本参数配置
network.bind_host: 192.168.1.85
network.publish_host: 192.168.1.85
network.host: 192.168.1.85

auth.host_based.enabled: true

auth:
host_based:
config:
0:
user: crate
address: 192.168.1.85
method: trust
99:
method: password

##集群部分参数
cluster.name: my_cluster
node.name: node2
discovery.zen.ping.unicast.hosts:
- 192.168.1.118:4300
- 192.168.1.85:4300
discovery.zen.minimum_master_nodes: 1

11.启动
注意不能在root下启动
[[email protected] /]# su - crate
[[email protected] bin]$ cd /cratedb/crate-3.2.0/bin
[[email protected] bin]$./crate -d ##表示后台启动


13.安装crash
curl -o crash https://cdn.crate.io/downloads/releases/crash_standalone_latest
chmod +x crash
./crash --host 192.168.1.85
cr> CREATE USER devtest WITH (password=‘123456‘);
cr> GRANT DQL TO devtest;
cr> GRANT DDL TO devtest;
cr> GRANT DML TO devtest;

14.通过web浏览器进行登陆
http://192.168.1.85:4200


15.发现数据已经自动同步过来了
[[email protected] cratedb]$ ./crash --host 192.168.1.85
CONNECT OK
cr> show TABLES
;
+------------+
| table_name |
+------------+
| metric |
| myusers |
| tb_test |
| tb_test01 |
+------------+
SHOW 4 rows in set (0.012 sec)

 

----------------修改主库的参数------------------------
1.停掉主库
2.修改配置文件
cluster.name: my_cluster
node.name: node2
discovery.zen.ping.unicast.hosts:
- 192.168.1.118:4300
- 192.168.1.85:4300
discovery.zen.minimum_master_nodes: 1

3.重新启动

相关文章
相关标签/搜索