Getting started with OpenTSDB on Amazon AWS - Part 1
OpenTSDB is an open-source time series database. In this part we’ll install HBase and OpenTSDB with a minimal setup on an EC2 instance.
Setting up the EC2 instance
Set up an Amazon EC2 instance with the Ubuntu 16.04 AMI. I’m choosing the t2.small instance type to keep costs down.
SSH into the instance and upgrade it:
1
sudo apt-get update && sudo apt-get upgrade -y && sudo reboot now
Wait a minute and SSH back in.
According to the installation docs, we’ll need to install HBase, starting with JDK 8:
1
sudo apt-get install -y default-jdk
Installing HBase
Fetch and install the newest stable HBase binary. This version may have changed when you read this:
1
wget https://apache.claz.org/hbase/stable/hbase-1.2.4-bin.tar.gztar xzvf hbase-*.tar.gzcd hbase*
According to the docs, JAVA_HOME
has to be set in the HBase env config:
1
echo 'export JAVA_HOME=/usr' >> conf/hbase-env.sh
Next, we’ll edit conf/hbase-site.xml
with a minimal config:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///home/ubuntu/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/home/ubuntu/zookeeper</value>
</property>
</configuration>```
And let’s start it:
```bash
bin/start-hbase.sh
Verify that HBase is running from the shell:
1
./bin/hbase shell
And use the status
command:
1
2
hbase(main):001:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load
Installing OpenTSDB
Let’s make sure ZooKeeper is running:
1
2
$ nc -v localhost 2181
Connection to localhost 2181 port [tcp/*] succeeded!
Looks good. Let’s fetch some dependencies:
1
sudo apt-get install -y gnuplot build-essential python autoconf
And build opentsdb:
1
2
3
git clone git://github.com/OpenTSDB/opentsdb.git && \
cd opentsdb && \
./build.sh
OpenTSDB should now have been built:
1
2
3
$ ./build/tsdb version
net.opentsdb.tools 2.3.0 built at revision b81ef90 (MINT)
Built on 2017/03/08 21:12:19 +0000 by ubuntu@ip-10-30-1-146:/home/ubuntu/opentsdb/build
Copy the configuration template:
1
cp src/opentsdb.conf .
And create the tables. Note that your hbase directory may vary by version:
1
$ env COMPRESSION=NONE HBASE_HOME=../hbase-1.2.4 ./src/create_table.sh
Running OpenTSDB in the foreground
We’re now ready to run OpenTSDB:
1
2
3
tsdtmp=${TMPDIR-'/tmp'}/tsd
mkdir -p "$tsdtmp"
./build/tsdb tsd --port=4242 --staticroot=build/staticroot --cachedir="$tsdtmp" --zkquorum=localhost:2181
At this point you can add a security group inbound rule to the EC2 instance’s Security Group that opens up port 4242 and open it up in a browser:
Stay tuned for the next part where we’ll start feeding some metrics into our OpenTSDB.