Available in VPC
OpenTSDB (Time Series DataBase) is a distributable and scalable time series database powered by HBase.
OpenTSDB was created to store, index, and deliver metrics information collected from servers, networks, and applications.
OpenTSDB architecture
- Time Series Daemon (TSD): Stores the entered metric information in the HBase storage.
- Input sources: Metric information sent from servers, networks, applications, and other sources.
- Storage: Uses HBase as the default storage to save the time series data.

For more information about OpenTSDB, see OpenTSDB website.
This guide explains how to build OpenTSDB with Cloud Hadoop.
For information about the OpenTSDB open source used in this guide, see OpenTSDB.
Preliminary task
Create a server to install OpenTSDB. The example describes how to use it on a Linux server.
- For more information about creating a server, see the Getting started guide.
- To access a Linux server, see the Connect to the server guide.
Using OpenTSDB
First, check the requirements for installing the OpenTSDB open source on the server. The installation requirements are as follows:
Installation requirements
- Java SE (JDK)
- Gnuplot
- OpenTSDB (open source)
1. Install OpenTSDB
To install OpenTSDB on a server:
-
Use the following command to install OpenJDK on the server:
sudo -s yum install java-1.8.0-openjdk-devel.x86_64 -
Use the yum package manager to install the
gnuplotpackage required to create graphs for OpenTSDB.yum -y install gnuplot -
Create a user account.
useradd -m -d /home/opentsdb -u 10001 opentsdb -
Create a log directory.
mkdir /var/log/opentsdb && chown opentsdb:opentsdb /var/log/opentsdb -
Install the OpenTSDB open source.
# root user su - opentsdb # opentsdb user git clone https://github.com/OpenTSDB/opentsdb cd opentsdb -
Build the OpenTSDB source.
# opentsdb user ./build.sh
2. Install HBase client
To install the HBase client:
-
Use the following command to download the HBase binary:
- Cloud Hadoop 2.0 or later versions
# opentsdb user wget https://archive.apache.org/dist/hbase/2.2.6/hbase-2.2.6-bin.tar.gz tar xvfz hbase-2.2.6-bin.tar.gz ln -s hbase-2.2.6 hbase- Cloud Hadoop 1.9 or earlier versions
# opentsdb user wget https://archive.apache.org/dist/hbase/2.0.2/hbase-2.0.2-bin.tar.gz tar xvfz hbase-2.0.2-bin.tar.gz ln -s hbase-2.0.2 hbaseNoteFor Cloud Hadoop Classic, download HBase 1.1.2.
-
In the Ambari UI, click [ACTIONS] > Download Client Configs to check the file name of the HBase client configuration file, then run the command in the OpenTSDB server terminal to download the configuration file (
HBASE_CLIENT-configs.tar.gz) directly.- For more information about accessing and using the Ambari UI, see the Ambari UI guide.

- For more information about accessing and using the Ambari UI, see the Ambari UI guide.
-
Unzip the HBase client configuration information.
# opentsdb user tar xvfz HBASE_CLIENT-configs.tar.gz -C ~/opentsdb/hbase/conf sed -i -e 's|\(^export JAVA_HOME=.*\)|#\1|' ~/opentsdb/hbase/conf/hbase-env.sh -
Edit the
opentsdbuser's.bash_profile.# opentsdb user echo 'export HBASE_HOME=~/opentsdb/hbase' >> ~/.bash_profile echo 'export PATH=$PATH:${HBASE_HOME}/bin' >> ~/.bash_profile echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk' >> ~/.bash_profile logout -
Check the Cloud Hadoop cluster's hostname and private IP information in the Ambari UI > Hosts menu.

-
Use the following commands to add
/etc/hostsinformation:- Add the hostname and private IP information of the Cloud Hadoop cluster you identified in the previous step.
# root user # echo 'IP hostname' >> /etc/hosts echo '1**.**.*.* e-001-*****-**' >> /etc/hosts echo '1**.**.*.* m-001-*****-**' >> /etc/hosts echo '1**.**.*.* m-002-*****-**' >> /etc/hosts echo '1**.**.*.* d-001-*****-**' >> /etc/hosts echo '1**.**.*.* d-002-*****-**' >> /etc/hosts -
Use the following command to test the
hbase shellaccess:su - opentsdb # opentsdb user hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 1.1.2, rcc2b70cf03e3378800661ec5cab11eb43fafe0fc, Wed Aug 26 20:11:27 PDT 2015 hbase(main):001:0> exit
If you fail to access HBase Shell, add an OpenTSDB server to the ACG of Cloud Hadoop. For more information about setting up ACG, see the Firewall Settings (ACG) guide.
3. Create OpenTSDB table
To create an OpenTSDB table:
-
Create a
TSDBtable using the following command:# opentsdb user export COMPRESSION=SNAPPY export DATA_BLOCK_ENCODING=FAST_DIFF export TSDB_TTL=2147483647 sh ~/opentsdb/src/create_table.sh -
Use the following command to view the list of tables:
# opentsdb user hbase shell hbase(main):001:0> list TABLE tsdb tsdb-meta tsdb-tree tsdb-uid 4 row(s) in 0.1620 seconds => ["tsdb", "tsdb-meta", "tsdb-tree", "tsdb-uid"] hbase(main):002:0> exit
4. Activate OpenTSDB
Use the following command to start the TSD on port 8888:
-
For the
--zkquorumoption, you must accurately enter the hostnames of Master Node 1, Master Node 2, and Data Node 1 in the cluster.# opentsdb user cd opentsdb ./build/tsdb tsd --port=8888 --staticroot=build/staticroot -- cachedir=`pwd`/build/tmp --zkquorum=m-001-*****-**,m-002-*****-**,d-001-*****-**: 2181 --zkbasedir=/hbase-unsecure &
5. Store Time Series Data in OpenTSDB
To store time series data in OpenTSDB:
-
Use the following command to create a
cpu.utilmetric:- For the
--zkquorumoption, you must accurately enter the hostnames of Master Node 1, Master Node 2, and Data Node 1 in the cluster.
# opentsdb user ./build/tsdb mkmetric cpu.util --zkquorum=m-001-*****-**,m-002-*****-**,d-001-*****-**: 2181 --zkbasedir=/hbase-unsecure metrics cpu.util: [0, 0, 1] - For the
-
Use the following command to create a
cpu.utilmetrics collection script: (sar-data-input.sh)- Script source: This script is referenced from the original article Effective Monitoring and Alerting.
#!/bin/bash # Ignore sar's header. LC_ALL=en sar -u 1 | sed -u -e '1,3d' | while read time cpu usr nice sys io steal idle; do NOW=$(date +%s) echo put cpu.util $NOW $usr time=user echo put cpu.util $NOW $sys time=system echo put cpu.util $NOW $io time=io echo put cpu.util $NOW $idle time=idle # Report values to standard error. echo timestamp:$NOW user:$usr sys:$sys io:$io idle:$idle >&2 done | nc -w 30 localhost 8888 -
Use the following command to transfer metrics data to OpenTSDB:
sh sar-data-input.sh
6. Check OpenTSDB Graph
To view the OpenTSDB graphs:
- Check the public IP of the OpenTSDB server in the server console.

- Access port
8888on the OpenTSDB server and check the collected graphs.
