Tutorial: Setting up the server environment

Matt Bartos edited this page Aug 29, 2017 · 2 revisions

Creating the server and storage volumes on AWS

The first step in setting up the server environment is to create an Amazon Elastic Compute Cloud (EC2) instance.

To launch an EC2 instance, follow Amazon's official documentation for EC2 setup.

Because the EC2 instance provides only 8GB of storage, we will need extra storage for our database. To enable a separate storage volume, we will create an Amazon Elastic Block Store (EBS) volume and attach it to our EC2 instance.

Follow Amazon's guide to create an EBS volume.

Next, attach an EBS volume to your EC2 instance

Mounting the EBS storage volume

After creating these assets, we will need to mount the Elastic Block Store on the EC2 filesystem.

Influxdata recommends using two storage volumes: one for the WAL (influxdb/wal) and one for long-term data storage (influxdb/data), with 1-3k provisioned IOPS for each. For this example, we will only be using one storage volume.

Log in to the EC2 server and execute the following commands:

#### Enable elastic block store at mount point /data
#### This assumes you have an EMPTY elastic block store attached at /sdf
#### Do not do this if the elastic block store has data on it!

sudo mkfs -t ext4 /dev/xvdf
sudo mkdir /data
sudo mount /dev/xvdf /data
sudo cp /etc/fstab /etc/fstab.orig

Next, open the /etc/fstab file in a text editor:

sudo vim /etc/fstab

Add the following line to enable mount on boot:

/dev/xvdf       /data   ext4    defaults,nofail,nobootwait        0       2

Now, mount the volume based on the configuration in /etc/fstab:

sudo mount -a

Installing Influxdb

Now, we'll set up the actual influxdb service. First, download and install influxdb:

#### Influxdb setup (ubuntu)

curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb

Configuring influxdb

#### Set up influxdb write directory
sudo mkdir /data/influxdb
sudo chown influxdb:influxdb /data/influxdb
sudo mkdir /data/influxdb/data
sudo mkdir /data/influxdb/wal
sudo mkdir /data/influxdb/meta
sudo chown influxdb:influxdb /data/influxdb/data
sudo chown influxdb:influxdb /data/influxdb/wal
sudo chown influxdb:influxdb /data/influxdb/meta

Next, open the influxdb configuration file:

sudo vim /etc/influxdb/influxdb.conf

... and make the following change:

"""
[meta]
  dir = "/data/influxdb/meta"

...

[data]
  dir = "/data/influxdb/data"
  wal-dir = "/data/influxdb/wal"
"""

Now, start the influxdb service:

sudo service influxdb start

Now, open /etc/environment in a text editor:

sudo vim /etc/environment

... and add the influxdb configuration path to your environment variables:

INFLUXDB_CONFIG_PATH="/etc/influxdb/influxdb.conf"

Now reboot the server and run influxdb for the first time:

influxd

Opening ports

The following inbound ports need to be opened on the EC2 instance security group. If greater security is desired, the IP range for each port can be restricted.

Type Service Protocol Port IP range
SSH SSH TCP 22 0.0.0.0/0
Custom TCP Rule Influxdb TCP 8086 0.0.0.0/0
Custom TCP Rule Kapacitor TCP 9092 0.0.0.0/0
Custom TCP Rule Grafana TCP 3000 0.0.0.0/0
Custom TCP Rule Influxdb backups TCP 8080 0.0.0.0/0

The following outbound ports also need to be opened.

Type Service Protocol Port IP range
HTTPS Kapacitor: Slack TCP 443 0.0.0.0/0
Custom TCP Rule Influxdb backups TCP 8080 0.0.0.0/0
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.