In this tutorial, we'll explain how to install and configure InfluxDB v2 on Ubuntu 24.04. It's time series data. We'll install InfluxCLI, and Nginx for reverse proxy server, and Let's Encrypt Certbot for SSL certificate.
InfluxDB v2 is a powerful open-source time series database designed for high-performance data storage, retrieval, and analysis. It is tailored for handling large volumes of time-stamped data, making it ideal for use cases such as monitoring, observability, and IoT data management. The key enhancements in InfluxDB v2 include a new query language called Flux, a more streamlined and efficient data model, and a unified API for writing and querying data.
One of the significant changes in InfluxDB v2 is the introduction of the integrated InfluxDB 2.0 platform, which combines the core database with tools like InfluxDB UI, Chronograf, Telegraf, and Kapacitor into a single cohesive package. This integration allows users to collect, visualize, and analyze data more efficiently.
The web-based user interface simplifies database management and provides rich data visualization capabilities. The use of Flux as the query language enhances flexibility in data analysis, offering more advanced features compared to the traditional InfluxQL.
Prerequisites
- An Ubuntu 24.04 installed dedicated server or KVM VPS
- Basic knowledge of Linux commands
- A root user access or normal user with administrative privileges
Install and Configure InfluxDB v2 on Ubuntu
Step 1: Update the System
First, update your system to ensure all packages are up-to-date.
sudo apt update
Step 2: Install InfluxDB v2
InfluxDB is not available in the default Ubuntu repositories, so you need to add the InfluxData repository. For more information visit official download page.
Create a repository file:
# influxdata-archive_compat.key GPG fingerprint:
# 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
Save and exit the file.
Install InfluxDB using the dnf package manager.
sudo apt-get update && sudo apt-get install influxdb2 -y
After installing InfluxDB, start the service and enable it to start on boot.
sudo systemctl start influxdb
sudo systemctl enable influxdb
Verify that InfluxDB is running:
sudo systemctl status influxdb
Step 3: Install InfluxDB CLI
Next, we need to download InfluxDB CLI. Visit official website for latest version. Execute following command to download InfluxDB CLI:
wget https://download.influxdata.com/influxdb/releases/influxdb2-client-2.7.5-linux-amd64.tar.gz
Install the CLI tool
tar xvf influxdb2-client-2.7.5-linux-amd64.tar.gz
sudo cp influx /usr/local/bin/
Verify the installation
influx version
Output:
Influx CLI dev (git: a79a2a1b825867421d320428538f76a4c90aa34c) build_date: 2024-04-16T14:34:32Z
Step 4: Set up InfluxDB 2
InfluxDB v2 comes with a setup wizard to help you get started.
Run the setup command:
influx setup
Follow the prompts to set up your initial user, organization, and bucket. Example prompts and responses:
> Welcome to InfluxDB 2.0!
? Please type your primary username admin
? Please type your password *********
? Please type your password again ********
? Please type your primary organization name my_org
? Please type your primary bucket name my_bucket
? Please type your retention period in hours, or 0 for infinite 1
? Setup with these parameters?
Username: admin
Organization: my_org
Bucket: my_bucket
Retention Period: 1h0m0s
Yes
User Organization Bucket
admin my_org my_bucket
InfluxDB setup has been completed.
Step 5: Configure Firewall and SELinux
We need to add HTTP and HTTPS ports in the firewall. Execute following command:
ufw allow 80/tcp
ufw allow 443/tcp
ufw reload
Next if you have enabled SELinux, follow this step. To allow Nginx to work correctly under SELinux, you need to set the appropriate SELinux policies.
sudo semanage fcontext -a -t httpd_sys_content_t
Step 6: Install and Configure Nginx for InfluxDB v2
First, install Nginx on your Ubuntu 24.04 server.
sudo apt install nginx -y
Start and enable Nginx:
sudo systemctl start nginx
sudo systemctl enable nginx
Verify Nginx is running:
sudo systemctl status nginx
Next, we need to configure Nginx to proxy requests to InfluxDB.
Create a new Nginx configuration file for InfluxDB:
sudo nano /etc/nginx/sites-available/influxdb
Add the following configuration:
server {
listen 80;
server_name your_domain;
location / {
proxy_pass http://localhost:8086;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Note: Replace your_domain
with your server's domain name.
Save and exit the file.
Enable the configuration and restart Nginx:
sudo ln -s /etc/nginx/sites-available/influxdb /etc/nginx/sites-enabled/
Test the Nginx configuration:
sudo nginx -t
Reload Nginx to apply the new configuration:
sudo systemctl reload nginx
Step 7: Install Certbot for SSL
We'll use Certbot to obtain and install SSL certificates from Let's Encrypt.
sudo apt install certbot python3-certbot-nginx -y
Use Certbot to obtain and install SSL certificates.
Run Certbot:
sudo certbot --nginx -d your_domain
Follow the prompts to complete the setup. Certbot will automatically configure Nginx to use the obtained SSL certificates.
Let's Encrypt certificates are valid for 90 days, so it's essential to set up auto-renewal.
Create a cron job to renew the certificates:
sudo crontab -e
Add the following line to the crontab file to run the renewal twice a day:
0 0,12 * * * /usr/bin/certbot renew --quiet
This cron job will check for certificate renewal twice daily and renew them if needed.
Step 8: Verify Setup
You can verify your setup by accessing the InfluxDB web interface. Open your browser and navigate to https://your_domain
. Log in with the username and password you created during setup.
Conclusion
You have successfully seen how to install and configure InfluxDBv2 on Ubuntu 24.04 Time Series Data. You can now start using InfluxDB for storing and querying time series data. For more advanced configurations and usage, refer to the official InfluxDB documentation.
Feel free to reach out if you have any questions or need further assistance.