InfluxDB is a highly efficient open-source time series database developed by InfluxData. Written in Go, it is designed to handle large write and query loads, making it an ideal choice for high-performance environments. InfluxDB is recognized for its simplicity and scalability, supporting multiple operating systems and an extensive range of client libraries.
This comprehensive guide will walk you through the steps to install InfluxDB on a CentOS 8 server.
Prerequisites
- A server running CentOS 8.
- Root access enabled on your server.
Install InfluxDB
InfluxDB is not included in the default CentOS 8 repositories. Therefore, you need to create a custom repository to facilitate its installation. Execute the following command to create the repository file:
nano /etc/yum.repos.d/influxdb.repo
Add these lines to the newly created file:
[ influxdb] name = InfluxDB Repository baseurl = https://repos.influxdata.com/rhel/8/x86_64/stable/ enabled = 1 gpgcheck = 1 gpgkey = https://repos.influxdata.com/influxdb.key
After saving and closing the file, update your repository cache using:
dnf makecache
Now, proceed to install InfluxDB by executing:
dnf -y install influxdb
Upon successful installation, verify the installed InfluxDB version with the following command:
rpm -qi influxdb
You should see an output similar to this:
Name : influxdb Version : 1.8.4 Release : 1 Architecture: x86_64 Install Date: Wednesday 07 April 2021 01:24:54 AM EDT Group : default Size : 174431824 License : Proprietary Signature : RSA/SHA256, Monday 01 February 2021 08:01:46 PM EST, Key ID 684a14cf2582e0c5 Source RPM : influxdb-1.8.4-1.src.rpm Build Date : Thursday 28 January 2021 05:31:21 AM EST Build Host : bf85fc4b5de4 Relocations : / Packager : support@influxdb.com Vendor : InfluxData URL : https://influxdata.com Summary : Distributed time-series database. Description : Distributed time-series database.
Manage InfluxDB Service
You can control the InfluxDB service using systemctl:
systemctl start influxdb systemctl stop influxdb
To enable the InfluxDB service to start on system boot, use:
systemctl enable influxdb
Check the status of the InfluxDB service with:
systemctl status influxdb
The output should be similar to:
? influxdb.service - InfluxDB is an open-source, distributed, time series database Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2021-04-07 01:25:11 EDT; 11s ago Docs: https://docs.influxdata.com/influxdb/ Main PID: 48978 (influxd) Tasks: 8 (limit: 12524) Memory: 7.9M CGroup: /system.slice/influxdb.service ??48978 /usr/bin/influxd -config /etc/influxdb/influxdb.conf Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426523Z lvl=info msg="Starting precreation service" log_id=0TMhWB~l000 service=> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426552Z lvl=info msg="Starting snapshot service" log_id=0TMhWB~l000 service=sna> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426570Z lvl=info msg="Starting continuous query service" log_id=0TMhWB~l000 ser> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426616Z lvl=info msg="Starting HTTP service" log_id=0TMhWB~l000 service=httpd a> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426634Z lvl=info msg="opened HTTP access log" log_id=0TMhWB~l000 service=httpd > Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426802Z lvl=info msg="Listening on HTTP" log_id=0TMhWB~l000 service=httpd addr=> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426831Z lvl=info msg="Starting retention policy enforcement service" log_id=0TM> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.427033Z lvl=info msg="Listening for signals" log_id=0TMhWB~l000 Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.427330Z lvl=info msg="Storing statistics" log_id=0TMhWB~l000 service=monitor db> Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.427779Z lvl=info msg="Sending usage statistics to usage.influxdata.com" log_id=>
InfluxDB listens on port 8086 by default. Verify this with the command:
ss -tunelp | grep 8086
You should see an output like:
tcp LISTEN 0 128 *:8086 *:* users:(("influxd",pid=49040,fd=14)) uid:987 ino:824427 sk:c v6only:0 <->
Enable Authentication
InfluxDB is initially configured to allow non-authenticated connections. Enhancing security with authentication is a crucial step. Begin by modifying the configuration file:
nano /etc/influxdb/influxdb.conf
Locate the [http] section and change the relevant line as shown below:
auth-enabled = true
Save your changes and restart the InfluxDB service to apply them:
systemctl restart influxdb
To create an admin user for authentication purposes, use:
curl -XPOST "http://localhost:8086/query" --data-urlencode "q=CREATE USER admin WITH PASSWORD 'password' WITH ALL PRIVILEGES"
Your InfluxDB instance is now secured with authentication credentials.
Working with InfluxDB
To connect to the InfluxDB shell, execute:
influx -username 'admin' -password 'password'
This will bring up the following prompt:
Connected to http://localhost:8086 version 1.8.4 InfluxDB shell version: 1.8.4
Create a new database by typing:
> CREATE DATABASE mydb
To view all existing databases, run:
> SHOW DATABASES
You should receive an output like this:
name: databases name ---- _internal mydb
To exit the InfluxDB shell, type:
> exit
You can also list databases without entering the shell by using:
curl -G http://localhost:8086/query -u admin:password --data-urlencode "q=SHOW DATABASES"
Expect an output as follows:
{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["_internal"],["mydb"]]}]}]}
Conclusion
Congratulations! You’ve successfully set up InfluxDB on CentOS 8. You are now equipped to leverage InfluxDB for managing substantial data loads in a production environment.
Frequently Asked Questions (FAQ)
Q: What is InfluxDB used for?
A: InfluxDB is a time series database ideal for high write and query workloads, often used to store and analyze time-stamped data, such as metrics and events.
Q: Can I use InfluxDB for free?
A: Yes, InfluxDB is open-source and available for free. Enterprise solutions with additional features and support are also offered by InfluxData.
Q: Are there any alternatives to InfluxDB?
A: Yes, alternative time series databases include Graphite, Prometheus, and TimescaleDB, each with unique features and capabilities.
Q: How do I ensure data security in InfluxDB?
A: Security can be enhanced by enabling authentication, using HTTPS for client connections, and controlling permissions with user roles and privileges.