如何在 Ubuntu 22.04 上安装 InfluxDB如何在 Ubuntu 22.04 上安装 InfluxDB如何在 Ubuntu 22.04 上安装 InfluxDB如何在 Ubuntu 22.04 上安装 InfluxDB
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Ubuntu 22.04 上安装 InfluxDB

InfluxDB是InfluxData公司开发的一款高读写速度的开源数据库。它是用 Go 编写的,专为创建基于时间序列的应用程序的开发人员而设计。它可以存储大量时间序列数据并快速对该数据进行实时分析。您可以将其安装在多个操作系统上,并且它支持各种客户端库。

在这篇文章中,我们将解释如何在 Ubuntu 22.04 上安装 InfluxDB。

要求

  • 运行 Ubuntu 22.04 的服务器。
  • root 密码已在您的服务器上设置。

第一步

首先,使用以下命令将所有系统软件包更新到最新版本:

apt update -y
apt upgrade -y

一旦您的系统是最新的,请使用以下命令安装您需要的任何其他依赖项:

apt install wget curl gnupg2 -y

安装所有依赖项后,您可以继续安装 InfluxDB。

安装 InfluxDB

默认情况下,InfluxDB 在 Ubuntu 22.04 的默认存储库中不可用。因此,您需要为 InfluxDB 创建一个存储库。

首先,使用以下命令添加 InfluxDB GPG 密钥:

wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null

接下来,使用以下命令将 IngluxDB 存储库添加到 APT:

export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | tee /etc/apt/sources.list.d/influxdb.list > /dev/null

接下来,使用以下命令更新存储库缓存并安装 InfluxDB:

apt update -y
apt install influxdb2

安装 InfluxDB 后,您可以继续下一步。

启动InfluxDB服务

默认情况下,InfluxDB 服务由 systemd 管理。您可以使用以下命令启动和停止 InfluxDB 服务:

systemctl start influxdb
systemctl stop influxdb

要在重新引导系统时启用 InfluxDB,请运行以下命令:

systemctl enable influxdb

要检查 InfluxDB 的状态,请运行以下命令:

systemctl status influxdb

您应该得到以下输出:

? influxdb.service - InfluxDB is an open-source, distributed, time series database
     Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-12-05 14:35:23 UTC; 11s ago
       Docs: https://docs.influxdata.com/influxdb/
    Process: 12075 ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh (code=exited, status=0/SUCCESS)
   Main PID: 12076 (influxd)
      Tasks: 8 (limit: 4579)
     Memory: 45.2M
        CPU: 782ms
     CGroup: /system.slice/influxdb.service
             ??12076 /usr/bin/influxd

Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.568768Z lvl=info msg="Open store (end)" log_id=0e_gFea0000>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.568805Z lvl=info msg="Starting retention policy enforcemen>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.568818Z lvl=info msg="Starting precreation service" log_id>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.569835Z lvl=info msg="Starting query controller" log_id=0e>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.573680Z lvl=info msg="Configuring InfluxQL statement execu>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.580309Z lvl=info msg=Starting log_id=0e_gFea0000 service=t>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12076]: ts=2022-12-05T14:35:23.582658Z lvl=info msg=Listening log_id=0e_gFea0000 service=>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12098]: Command "print-config" is deprecated, use the influx-cli command server-config to>
Dec 05 14:35:23 ubuntu2204 influxd-systemd-start.sh[12075]: InfluxDB started

此时InfluxDB已启动并侦听端口8086,您可以使用以下命令检查这一点:

ss -tunelp | grep 8086

您应该看到以下输出:

tcp   LISTEN 0      4096                                *:8086             *:*    users:(("influxd",pid=12076,fd=10)) uid:998 ino:87540 sk:17 cgroup:/system.slice/influxdb.service v6only:0 <->                         

InfluxDB 设置

默认情况下,InfluxDB 未配置。所以你必须通过命令行来配置它。

influx setup

系统将提示您设置管理员用户和密码,如下所示:

> 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 Howtoforge
? Please type your primary bucket name IT
? Please type your retention period in hours, or 0 for infinite 2
? Setup with these parameters?
  Username:          admin
  Organization:      Howtoforge
  Bucket:            IT
  Retention Period:  2h0m0s
 Yes
User	Organization	Bucket
admin	Howtoforge	IT

访问 InfluxDB Web UI。

此时,InfluxDB 已配置并侦听端口 8086,您可以使用以下命令验证这一点:

ss -antpl | grep 8086

您将得到以下输出:

LISTEN 0      4096               *:8086             *:*    users:(("influxd",pid=12076,fd=10))    

现在打开您的 Web 浏览器并使用 URL http://your-server-ip:8086 访问 InfluxDB Web UI。您应该看到 InfluxDB 的登录页面:

输入您的管理员用户名和密码,然后单击登录按钮。在下一页上,您应该看到 InfluxDB 仪表板:

结论

恭喜。您已在 Ubuntu 22.04 上成功安装 InfluxDB。您现在可以在生产环境中使用 InfluxDB 并通过基于 Web 的界面进行管理。

©2015-2025 艾丽卡 support@alaica.com