1. System environment:
- OS: CentOS7.3
- Java: JDK8
- Cassandra: cassandra-3.10
2. Install KairosDB
2.1 download and unzip
[root@cassandra01 software]# tar -zxvf kairosdb-1.2.1-1.tar.gz -C /software/ [root@cassandra01 software]# cd /software/kairosdb/ [root@cassandra01 kairosdb]#
2.4 modify underlying storage
KairosDB's default underlying storage is H2, which is modified to Cassandra according to our needs.
[root@cassandra01 kairosdb]# vi conf/kairosdb.properties kairosdb.service.datastore=org.kairosdb.datastore.cassandra.CassandraModule kairosdb.datastore.cassandra.cql_host_list=192.168.1.6:9042,192.168.1.7:9042,192.168.1.8:9042 kairosdb.datastore.cassandra.auth.user_name=cassandra kairosdb.datastore.cassandra.auth.password=cassandra
2.5 configure cassandra
start_rpc: false -> start_rpc: true ???
cqlsh connects to cassandra, and modifies the repair configuration
[root@cassandra01 kairosdb]# cqlsh -ucassandra -pcassandra 192.168.1.6 Connected to Cassandra01 at 192.168.1.6:9042. [cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. beaconuser1@cqlsh> use kairosdb ... ; beaconuser1@cqlsh:kairosdb> show tables; Improper show command. beaconuser1@cqlsh:kairosdb> desc tables; row_keys data_points string_index row_key_index service_index row_key_time_index # These three parameters are used to set the probability of cassandra's process read repair, which is 100% by default and 10% here. beaconuser1@cqlsh:kairosdb> alter table data_points with read_repair_chance = 0.1; beaconuser1@cqlsh:kairosdb> alter table row_key_index with read_repair_chance = 0.1; beaconuser1@cqlsh:kairosdb> alter table string_index with read_repair_chance = 0.1;
2.6 starting KairosDB
[root@cassandra01 kairosdb]# ./bin/kairosdb.sh start [root@cassandra01 kairosdb]# netstat -nltp | grep java tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 12364/java tcp 0 0 0.0.0.0:4242 0.0.0.0:* LISTEN 12364/java tcp 0 0 172.16.16.50:9042 0.0.0.0:* LISTEN 27922/java tcp 0 0 0.0.0.0:3030 0.0.0.0:* LISTEN 29584/java tcp 0 0 172.16.16.50:7000 0.0.0.0:* LISTEN 27922/java tcp 0 0 0.0.0.0:7199 0.0.0.0:* LISTEN 27922/java tcp 0 0 127.0.0.1:45088 0.0.0.0:* LISTEN 27922/java [root@cassandra01 kairosdb]#
2.7 basic concepts of time series database
- metric: measure, equivalent to table in relational database.
- Data point: data point, equivalent to row in a relational database.
- timestamp: time stamp, which represents the time of data point generation.
- field: different fields under measurement. For example, the measure of location has two fields: longitude and latitude. In general, it stores data that will change with the time stamp.
- Tag: tag, or additional information. Generally, attribute information that does not change with time stamp is stored. timestamp plus all tags can be considered as the primary key of table.