Create a database
Last updated on Thu Jun 20 11:40:48 2024 by stone1100
Guide showing how to create a database.
Before begin
Make sure LinDB is running and Admin console is available at http://localhost:9000, if not please checkout the quick start.
Create a database
Database can be created via:
Admin console
Create or edit configuration of corresponding database
Create database
CLI
/*configuration in JSON format*/
create database {\"option\":{\"intervals\":[{\"interval\":\"10s\",\"retention\":\"30d\"},{\"interval\":\"5m\",\"retention\":\"3M\"},{\"interval\":\"1h\",\"retention\":\"2y\"}],\"autoCreateNS\":true,\"behead\":\"1h\",\"ahead\":\"1h\"},\"name\":\"system_monitor\",\"storage\":\"/lindb-storage\",\"numOfShard\":3,\"replicaFactor\":2}
Example: create a database named system_monitor
, allocate 3 shards and 2 replicas to store in /lindb-storage
storage cluster.
{
"name":"system_monitor",
"storage":"/lindb-storage",
"numOfShard":3,
"replicaFactor":2,
"option":{
"intervals":[
{
"interval":"10s",
"retention":"30d"
},
{
"interval":"5m",
"retention":"3M"
},
{
"interval":"1h",
"retention":"2y"
}
],
"autoCreateNS":true,
"behead":"1h",
"ahead":"1h"
}
}
Options
Field | Description |
---|---|
name | Required, database name |
storage | Required, Storage cluster(Storage Namespace) |
numOfShard | Required, number of shards |
replicaFactor | Required, number of replicas for each shard |
option.intervals | Required, data storage calculation period and storage ttl, max length is 3(Day/Month/Year) |
option.behead | How long in the past data can be written |
option.ahead | How long in the future data can be written |
Previous
ConnectNext
Insert data