高性能、分布式、无模式云原生时序数据库,处理时序型分析型负载

CeresDB是一款高性能、分布式、无模式(Schema-less)的云原生时序数据库,能够同时处理时序型(time-series)以及分析型(analytics)负载。

该项目已经在GitHub上获得了近800个Star。目前,该项目在快速迭代中,早期版本可能存在数据不兼容问题,因此作者不推荐生产使用及性能测试。

高性能、分布式、无模式云原生时序数据库,处理时序型分析型负载

  • 项目地址:https://github.com/CeresDB/ceresdb/blob/main/README-CN.md
  • 开源协议:Apache License 2.0

快速开始

获取代码

通过git克隆代码仓库并进入代码目录:

git clone git@github.com:CeresDB/ceresdb.git
cd ceresdb

通过Docker运行

确保开发环境安装了docker,并通过仓库中的提供的Dockerfile进行镜像构建:

docker build -t ceresdb .

使用编译好的镜像,启动服务:

docker run -d -t --name ceresdb -p 5440:5440 -p 8831:8831 ceresdb

通过源码编译运行

安装依赖:目前为了编译CeresDB,需要安装相关依赖以及Rust工具链。

开发依赖(Ubuntu20.04)

开发环境这里以 Ubuntu20.04 为例,执行如下的命令,即可安装好所需的依赖:

apt install git curl gcc g++ libssl-dev pkg-config cmake

Rust

Rust的安装建议通过rustup,安装了rustup之后,进入到CeresDB项目的时候,会自动根据rust-toolchain文件下载指定的Rust版本。

理论上执行了之后,需要添加环境变量,才能使用Rust工具链,一般会把下面的命令放入到自己的~/.bashrc或者~/.bash_profile中:

source $HOME/.cargo/env

编译和运行

编译Release版本,执行如下命令:

cargo build --release

使用下载的代码中提供的默认配置文件,即可启动:

./target/ceresdb-server --config ./docs/example.toml

进行数据编写

CeresDB支持自定义扩展的SQL协议,目前可以通过http服务以SQL语句进行数据的读写、表的创建。

建表

curl --location --request POST 'http://127.0.0.1:5440/sql' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "CREATE TABLE `demo` (`name` string TAG, `value` double NOT NULL, `t` timestamp NOT NULL, TIMESTAMP KEY(t)) ENGINE=Analytic with (enable_ttl='\''false'\'');"
}'

插入数据

curl --location --request POST 'http://127.0.0.1:5440/sql' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "INSERT INTO demo(t, name, value) VALUES(1651737067000, '\''ceresdb'\'', 100)"
}'

查询数据

curl --location --request POST 'http://127.0.0.1:5440/sql' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "select * from demo"
}'

查看建表信息

curl --location --request POST 'http://127.0.0.1:5440/sql' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "show create table demo"
}'

删除表

curl --location --request POST 'http://127.0.0.1:5440/sql' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "DROP TABLE demo;"
}'

更多细节内容请参阅原项目。

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章