Skip to main content
Version: 2.4.x

Ubuntu & Debian

Ubuntu and Debian users can install the latest stable version of CnosDB using package manager apt-get.

Download

For Ubuntu or Debian users, use the following command to add the CnosDB repository:

curl -fsSL https://cnosdb-package-repository.s3.us-west-2.amazonaws.com/cnosdb.gpg-key.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/cnosdb.gpg > /dev/null
echo "deb [signed-by=/etc/apt/trusted.gpg.d/cnosdb.gpg] https://cnosdb-package-repository.s3.us-west-2.amazonaws.com/deb stable main" | sudo tee /etc/apt/sources.list.d/cnosdb.list > /dev/null

Update and download software:

sudo apt-get update & apt-get -y install cnosdb cnosdb-meta

Start a standalone instance

1. Edit configuration

Change [deployment].mode to singleton

[deployment]
mode = "query_tskv"

2. Start

systemctl start cnosdb

If Ubuntu 14.04 and previous versions and Debian 9, start with the following command:

service cnosdb start

Starting the cluster

note

Please add the following records to your DNS resolution server for communication between instances in your CnosDB cluster.Please contact your network administrator when necessary.

Record typeHostnameIP
Ameta1.cnosdb.commeta1_ip
Ameta2.cnosdb.commeta2_ip
Ameta3.cnosdb.commeta3_ip
Aquery_tskv1.cnosdb.comquery_tskv1_ip
Aquery_tskv2.cnosdb.comquery_tskv2_ip

Start the meta service

1. Edit configuration

Default configuration file location: /etc/cnosdb/cnosdb-meta.conf

Add the records added in the DNS server to the configuration file, assigning different records to different meta services.

host = meta<n>.cnosdb.com

Assign a node_id to each meta service, the id must not be duplicated.

id = n

The configuration file example after configuration is completed is as follows:

id = n
host = "meta<n>.cnosdb.com"
port = 8901
... ...

Start Service

systemctl start cnosdb-meta

If Ubuntu 14.04 and previous versions and Debian 9, start with the following command:

service cnosdb-meta start

Initialize meta service

If there are multiple meta services in your cluster, you only need to execute the initialization command on one of the meta services.

curl http://meta1.cnosdb.com:8901/init -d '{}'

Add other meta service instances

curl http://meta1.cnosdb.com:8901/add-learner -H "Content-Type: application/json" -d '[2, "meta2.cnosdb.com:8901"]' | jq
curl http://meta1.cnosdb.com:8901/add-learner -H "Content-Type: application/json" -d '[3, "meta3.cnosdb.com:8901"]' | jq

Reset cluster members to make the cluster take effect

Executing the following command can modify the cluster members. If there are multiple meta services in your cluster, use the node that initially performed the initialization to execute this command.

curl http://meta1.cnosdb.com:8901/change-membership -H "Content-Type: application/json" -d '[1,2,3]' | jq

View Cluster Status

Specify different nodes separately, perform the following commands to view cluster status.

Replace <n> in the command to specify a different meta service instance.

curl http://meta<n>.cnosdb.com:8901/metrics | jq

If the cluster installation is successful, the following content should be returned:

state may also be Follower.

{
"Ok": {
"running_state": {
"Ok": null
},
"id": 1,
... ...
"state": "Leader",
... ...
}

Launch the cnosdb service

Edit profile

The configuration file for the cnosdb service is located at /etc/cnosdb/cnosdb.conf.

Add entries to the DNS server to the configuration file and assign different cnosdb services to different records.

host = "query_tskv<n>.cnosdb.com"

Change [deployment].mode to query_tskv.

[deployment]
mode = "query_tskv"

Modify node_id, node_id cannot be duplicated.

[node_basic]
node_id = <n>

Change meta service address. Change meta service address. [cluster].name needs to be the same as [meta_init].cluster_name in the cnosdb-meta configuration.

 [cluster]
name = "cluster_xxx"
meta_service_addr = ['meta1.cnosdb.com:8901', 'meta2.cnosdb.com:8901', 'meta3.cnosdb.com:8901']

The configuration file example after configuration is completed is as follows:

 ... ...
host = "query_tskv<n>.cnosdb.com"
[deployment]
mode = 'query_tskv'
... ...
[cluster]
name = 'cluster_xxx'
meta_service_addr = ['meta1.cnosdb.com:8901', 'meta2.cnosdb.com:8901', 'meta3.cnosdb.com:8901']
[node_basic]
node_id = <n>
... ...

Start Service

systemctl start cnosdb

If Ubuntu 14.04 and previous versions and Debian 9, start with the following command:

service cnosdb start