InfluxDB, developed by InfluxData, is a powerful open-source time series database. It is known for its simplicity, scalability, and ability to handle high write and query loads. Whether you are working on data analysis, monitoring, or any other time series-based application, InfluxDB can be a valuable tool in your tech stack. In this tutorial, we will guide you through the step-by-step process of installing InfluxDB on CentOS 8, a popular Linux distribution.
Prerequisites
Before we dive into the installation process, make sure you have the following prerequisites:
- A server running CentOS 8.
- A root password configured on your server.
Installing InfluxDB
By default, InfluxDB is not available in the CentOS 8 default repository. Therefore, we need to create a repository for InfluxDB. Follow the steps below to set it up:
- Open the terminal on your CentOS 8 server.
- Use the following command to create the InfluxDB repository file:
nano /etc/yum.repos.d/influxdb.repo
- Paste the following lines into the 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
- Save and close the file by pressing
Ctrl + X
, thenY
, and finallyEnter
. - Update the repository cache by running the following command:
dnf makecache
- Now, you can install InfluxDB by executing the following command:
dnf -y install influxdb
Once the installation is complete, you can verify the installed version of InfluxDB using the following command:
rpm -qi influxdb
If everything went smoothly, you should see the output displaying the version, release, architecture, and other details of InfluxDB.
Managing the InfluxDB Service
Now that InfluxDB is installed on your CentOS 8 server, let’s take a look at how to manage the InfluxDB service. You can start and stop the service using the following commands:
systemctl start influxdb systemctl stop influxdb
To ensure that InfluxDB starts automatically at system reboot, run the following command:
systemctl enable influxdb
If you want to check the status of the InfluxDB service, you can use the following command:
systemctl status influxdb
This will provide you with detailed information about the service, including its active state and any associated processes.
Configuring InfluxDB
By default, InfluxDB listens on port 8086 for incoming connections. You can verify this by running the following command:
ss -tunelp | grep8086
The output should indicate that InfluxDB is listening on port 8086. If you need to change this port, you can do so by modifying the configuration file located at /etc/influxdb/influxdb.conf
.
Enabling Authentication
By default, InfluxDB allows connections without authentication, which may not be ideal for security. To secure your InfluxDB installation, it is recommended to enable authentication.
To enable authentication, open the InfluxDB configuration file using the following command:
nano /etc/influxdb/influxdb.conf
Look for the [http]
section and locate the following line:
auth-enabled = false
Change it to:
auth-enabled = true
Save and close the file. To apply the changes, restart the InfluxDB service by running the following command:
systemctl restart influxdb
Now, InfluxDB requires authentication for any database operations.
Creating an Admin User
With authentication enabled, you need to create an admin user to access InfluxDB. Run the following command to create the admin user:
curl -XPOST "http://localhost:8086/query" --data-urlencode "q=CREATE USER admin WITH PASSWORD 'password' WITH ALL PRIVILEGES"
Replace 'password'
with your desired password. This command will create an admin user with full privileges.
Working with InfluxDB
Now that InfluxDB is up and running with authentication enabled, let’s explore how to interact with the database. To start, you can connect to the InfluxDB shell using the following command:
influx -username 'admin' -password 'password'
Replace 'admin'
with your admin username and 'password'
with your admin password.
Once connected, you will see the InfluxDB shell prompt, indicating a successful connection. From here, you can perform various operations on your databases.
Creating a Database
To create a new database, use the following command within the InfluxDB shell:
CREATE DATABASE mydb
This will create a new database named mydb
. You can replace mydb
with your preferred database name.
Listing Databases
To view a list of all databases, run the following command:
SHOW DATABASES
You will see a list of databases, including the default _internal
database and the one you just created.
Exiting the InfluxDB Shell
To exit the InfluxDB shell, simply type exit
and press Enter
. This will return you to the command line.
Alternatively, if you want to list all databases without entering the InfluxDB shell, you can use the following command:
curl -G http://localhost:8086/query -u admin:password --data-urlencode "q=SHOW DATABASES"
This command will provide you with a JSON response containing the list of databases.
Conclusion
Congratulations! You have successfully installed InfluxDB on your CentOS 8 server. You now have a powerful time series database at your disposal, ready to handle your data analysis, monitoring, and other time series-based applications. InfluxDB’s scalability and simplicity make it a reliable choice for managing large amounts of data.
If you are looking for a reliable hosting provider to run InfluxDB on CentOS 8, consider Shape.host’s Linux SSD VPS services. With Shape.host, you can enjoy high-performance virtual private servers optimized for speed, security, and scalability. Visit shape.host to explore their offerings and find the perfect hosting solution for your needs.
Remember to regularly update and secure your InfluxDB installation to ensure the integrity of your data and protect against potential threats. Happy time series data management!