Install and Configure InfluxDB on Amazon Linux

Samar Acharya
Brightergy Engineering
3 min readJul 28, 2016

TL;DR You can just follow this gist with adaptation to your use-case.

We recently started using InfluxDB as our time-series database for our IoT platform. InfluxDB allows us to store large amount of time-series data collected from various type of devices such as power meters and solar generation monitors. We reviewed couple of time series databases such as Prometheus, OpenTSDB and Graphite and finally settled with InfluxDB as it is best suited for use-case. While InfluxDB does not have many features and there are certain shortcomings with it, we see it as a promising young time-series database. We had tried InfluxCloud but we had certain issues such as lack of control and visibility of the InfluxDB cluster servers. Thus, we decided to run our InfluxDB in house and it turned out to be a straightforward process.

In this post, we will see how to install and configure a single node InfluxDB service using AWS with an optimal configuration. For our setup, we will use two volumes, one for the WAL (write-ahead logging) and one for the InfluxDB data. The general idea is to use a higher IOPS, lower size volume for the WAL and a larger sized, but slower IOPS volume for the data.

Pre-install

From your AWS console or AWS CLI, create a new security group called influxdb-sg and allow inbound connection to TCP port 8086 from the appropriate source. Launch an EC2 instance using the Amazon Linux AMI and your desired instance size with the security group we created earlier. Since we’re going to store the data and the WAL in separate volumes, you can either choose to add these volumes as part of your launch process or later on. Or you can just choose not to use volumes based on your needs.

Once the instance is up, create a SSH session and run the following commands:

yum update
mkdir -p /opt/influx/{wal,data,ssl}

WAL and Data Volumes Configuration

Make sure your device paths are correct. If you are not using additional volumes, you can skip this step.

mkfs.ext4 /dev/sdb
mkfs.ext4 /dev/sdc
mount /dev/sdb /opt/influx/wal/
mount /dev/sdc /opt/influx/data/

Installation

At the I wrote this, the latest stable version of InfluxDB was 0.13 which we are going to use.

wget https://dl.influxdata.com/influxdb/releases/influxdb-0.13.0.x86_64.rpm
yum localinstall influxdb-0.13.0.x86_64.rpm
chkconfig influxdb on

Configuration

SSL

Its recommended to use SSL with InfluxDB whenever you can. InfluxDB requires you to concatenate your private key and your certificate bundle in a single file.

cat privkey.pem mysite.crt mysite-ca-bundle.crt > bundle.pem
scp bundle.pem root@myhost:/tmp

Now, on the influx host, you can update the InfluxDB configuration. We will also update the meta, data and WAL configurations down below.

mv /tmp/bundle.pem /opt/influx/ssl/
chown -R influxdb:influxdb /opt/influx/
cp /etc/influxdb/influxdb.conf{,-bak}
sed -i s./var/lib/influxdb/meta./opt/influx/data/meta. /etc/influxdb/influxdb.conf
sed -i s./var/lib/influxdb/data./opt/influx/data/data. /etc/influxdb/influxdb.conf
sed -i s./var/lib/influxdb/wal./opt/influx/wal. /etc/influxdb/influxdb.conf
sed -i s,/etc/ssl/influxdb.pem,/opt/influx/ssl/bundle.pem, /etc/influxdb/influxdb.conf
sed -i "s/https-enabled = false/https-enabled = true/" /etc/influxdb/influxdb.conf

Authentication

Now that we have InfluxDB ready to be run, we want to enable some form of authentication. Since we’re going to use http based data in-and-out (which is the default mechanism in InfluxDB), we need to enable authentication. We first need to create users before we can enable authentication and hence, we need to connect to the InfluxDB instance with authentication disabled (authentication is turned off by default).

influx
> create user superadmin with password 'my_password' with all privileges
> create user nonadmin with password 'na_password'
> grant all on tsdb_stage to nonadmin
> grant READ on tsdb_prod to nonadmin
> grant WRITE on tsdb_dev to nonadmin

We just created two users, an admin user and a non-admin user. Now, we can enable the authentication and we should be ready to go with our newly setup InfluxDB instance.

/etc/init.d/influxdb stop
sed -i "s/auth-enabled = false/auth-enabled = true/" /etc/influxdb/influxdb.conf
/etc/init.d/influxdb start

The single node InfluxDB is ready now. If you are using Elixir, you can use the nice Instream package to interact with InfluxDB. If you have need help porting data from one InfluxDB instance to another, you may find influx-copy helpful.

--

--