Ubuntu 22.04
Sponsored Link

InfluxDB : インストール2022/10/26

 
時系列データベース InfluxDB をインストールします。
[1] InfluxDB をインストールします。
root@dlp:~#
apt -y install influxdb influxdb-client
[2] InfluxDB の初期設定です。
デフォルトでは認証は無効となっているため、認証を有効にしておきます。
# 管理者ユーザー作成
# [admin] ⇒ 任意のユーザー名を設定
# [adminpassword] ⇒ 任意のパスワードを設定

root@dlp:~#
influx -execute "create user admin with password 'adminpassword' with all privileges"

root@dlp:~#
influx -execute "show users"

user  admin
----  -----
admin true

root@dlp:~#
vi /etc/influxdb/influxdb.conf
[http]
  # Determines whether HTTP endpoint is enabled.
  # enabled = true

  # The bind address used by the HTTP service.
  # bind-address = ":8086"

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  # 226行目 : コメント解除して変更
  auth-enabled = true

root@dlp:~#
systemctl restart influxdb
[3] 認証を有効にした場合は、以下のように InfluxDB へアクセスします。
# InfluxDB の CLI を起動して認証する

root@dlp:~#
influx

Connected to http://localhost:8086 version 1.6.7~rc0
InfluxDB shell version: 1.6.7~rc0
> auth
username: admin
password:

> exit

# CLI に認証情報を付加して認証する

root@dlp:~#
influx -username admin -password adminpassword

Connected to http://localhost:8086 version 1.6.7~rc0
InfluxDB shell version: 1.6.7~rc0
> exit

# 環境変数に認証情報を設定して認証する

root@dlp:~#
export INFLUX_USERNAME=admin

root@dlp:~#
export INFLUX_PASSWORD=adminpassword

root@dlp:~#
influx

Connected to http://localhost:8086 version 1.6.7~rc0
InfluxDB shell version: 1.6.7~rc0
> exit

# HTTP API で認証する

root@dlp:~#
curl -G http://localhost:8086/query?pretty=true -u admin:adminpassword --data-urlencode "q=show users"

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "columns": [
                        "user",
                        "admin"
                    ],
                    "values": [
                        [
                            "admin",
                            true
                        ]
                    ]
                }
            ]
        }
    ]
}
関連コンテンツ