cratedb 4.2.1单机安装

1.下载安装介质
Cratedb下载地址:https://cdn.crate.io/downloads/releases/nightly/
cratedb官方文档手册:https://crate.io/docs/crate/reference/en/latest/

2.安装java
安装java,确保版本在1.8以上
[root@localhost ~]# 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)

3.创建crate用户
因为cratedb不能在root用户下启动,所以需要创建非root用户,我这里创建crate用户
[root@localhost /]# useradd crate
[root@localhost /]# passwd crate
密码和用户名一致

4.配置crate环境变量
[crate@localhost ~]$ more .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
JAVA_HOME=/usr/local/java/jdk1.8.0_151
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin

export PATH

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

[root@localhost /]# sysctl -w vm.max_map_count=262144

配置永久生效

vi /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p

 


6.安装python3
步骤省略,可以参考
http://blog.chinaunix.net/uid-77311-id-5787558.html

7.准备安装目录
[root@localhost ~]# cd /
[root@localhost /]# mkdir cratedb421

8.解压安装
[root@localhost soft]# tar -xvf crate-4.2.1.tar.gz
[root@localhost soft]# [root@localhost soft]# mv crate-4.2.1 /cratedb421/


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

10.创建数据存放目录
[root@localhost crate-4.2.1]# cd /cratedb421/crate-4.2.1
[root@localhost crate-4.2.1]# mkdir data

11.修改配置文件(/cratedb421/crate-4.2.1/config/crate.yml)

#################################### Paths ###################################
path.data: /cratedb421/crate-4.2.1/data
path.logs: /cratedb421/crate-4.2.1/logs


#//////////////////////// Database Administration ////////////////////////////
auth.host_based.enabled: true
auth:
  host_based:
    config:
      0:
        user: crate
        address: 192.168.1.118
        method: trust
      99:
        method: password
        
############################# BACKUP / RESTORE ###############################
# Paths where Repositories of type fs may be created:
path.repo: /home/middle/cratedb/snapdata


network.bind_host: 192.168.1.118
network.publish_host: 192.168.1.118
network.host: 192.168.1.118
bootstrap.memory_lock: false


11.修改目录权限
[root@localhost /]# chown -R crate.crate /cratedb421


12.启动
注意不能在root下启动
[root@localhost /]# su - crate
[crate@localhost bin]$ cd /cratedb421/crate-4.2.1/bin
[crate@localhost bin]$./crate -d ##表示后台启

13.登陆
发现3.2.0版本没有crash后台登陆了,只能通过界面的方式登陆,在IE栏输入:
http://192.168.1.118:4200

14.安装crash
curl -o crash https://cdn.crate.io/downloads/releases/crash_standalone_latest
chmod +x crash
crash --host 192.168.1.129

或是浏览器下载后执行

./crash_standalone_latest.latest --host 192.168.1.129

 

新版的可能有些问题

-bash-4.2$ ./crash --host 192.168.1.129
-bash: ./crash: /usr/bin/python3: bad interpreter: No such file or directory
需要若软连接
ln -s 源文件 目标文件
ln -s /usr/local/bin/python3 /usr/bin/python3

 


这里如下需要设置address为服务器的ip地址
auth:
  host_based:
    config:
      0:
        user: crate
        address: 192.168.1.118
        method: trust
      99:
        method: password

15.使用
/cratedb/crash --host 192.168.1.118
创建用户
CREATE USER devtest WITH (password='123456');
#赋予权限
GRANT DQL TO devtest;
GRANT DDL TO devtest;
GRANT DML TO devtest;

 

修改用户密码

alter USER devtest set (password='123abc');


16.ie登陆
创建普通用户之后,在ie浏览器里就可以输入账号密码登陆了

http://192.168.1.118:4200


17.创建表
CREATE TABLE computed_parted_table (
id bigint,
created_at timestamp with time zone,
month timestamp with time zone GENERATED ALWAYS AS date_trunc('month', created_at)
) PARTITIONED BY (month)

写入数据
insert into computed_parted_table(id,created_at) values(1,now());
insert into computed_parted_table(id,created_at) values(2,now());
insert into computed_parted_table(id,created_at) values(3,now());
insert into computed_parted_table(id,created_at) values(4,now());

 

18.开机自启动

1.在/etc/systemd/system目录下创建cratedb.service文件
[Unit]
Description=cratedb
[Service]
User=ucratedb
Type=forking
LimitNOFILE=100000
LimitNPROC=100000
ExecStart=/usr/local/services/cratedb/bin/crate -d
[Install]
WantedBy=multi-user.target

2.设置开启启动
systemctl enable cratedb

 

或是在/etc/rc.d/rc.local文件中添加如下内容:

su ucratedb -c "/usr/local/services/cratedb/bin/crate -d"

chmod +x /etc/rc.d/rc.local

 

posted @ 2020-07-30 13:42  slnngk  阅读(719)  评论(0编辑  收藏  举报