Skip to content

Instantly share code, notes, and snippets.

@techgaun
Last active February 13, 2020 11:21
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save techgaun/c2802fb94ba36852690b74ea175faf09 to your computer and use it in GitHub Desktop.
Save techgaun/c2802fb94ba36852690b74ea175faf09 to your computer and use it in GitHub Desktop.
InfluxDB on Amazon Linux

Last updated: 2017-03-22 : Update to 1.2.2

The following assumes you're executing as a root user

Pre-install

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

WAL and Data volumes

# devices maybe different for you so adjust accordingly
mkfs.ext4 /dev/sdb
mkfs.ext4 /dev/sdc
mount /dev/sdb /opt/influx/wal/
mount /dev/sdc /opt/influx/data/

Permanent mounts via fstab

# it may look something like this so your devices are mounted across restarts
/dev/sdb   /opt/influx/wal ext4 defaults,nofail 0 2
/dev/sdc   /opt/influx/data ext4 defaults,nofail 0 2

Install

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

Configuration

SSL

First, you need to download the certificate bundle on the influxdb host. Below is an example of sending from your local system.

# on your local
# scp the cert or download
# your cert needs to be bundle that combines the private key, your crt and certificate chain
# do so with something like below
cat privkey.pem mysite.crt mysite-ca-bundle.crt > bundle.pem
scp bundle.pem root@myhost:/tmp

Now, on the influx host, you can configure influxdb config

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,# https-certificate = "/etc/ssl/influxdb.pem",https-certificate = "/opt/influx/ssl/bundle.pem",' /etc/influxdb/influxdb.conf
sed -i "s/# https-enabled = false/https-enabled = true/" /etc/influxdb/influxdb.conf
Authentication configuration
/etc/init.d/influxdb start # start with auth-enabled = false

Now, connect to the influxdb and configure the users. We'll configure one admin user and one non-admin user.

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

Once you have created necessary users, you can re-enable the authentication. You could have chosen to just create admin user first and then create non-admin users after enabling authentication to reduce the window of keeping your influxdb wide open.

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

That should be all for getting the influxdb up and running on Amazon Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment