部署Influx CLI
部署Influx CLI
下载 Influx CLI
# wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.6.1-linux-amd64.tar.gz
解压 Influx CLI
# tar xf influxdb2-client-2.6.1-linux-amd64.tar.gz
# cp influxdb2-client-2.6.1-linux-amd64/influx /usr/local/bin/
初始化 InfluxDB
在 InfluxDB 初始化过程中,创建了一个用户和 API 令牌,它有权管理 InfluxDB 实例中的所有内容。这称为操作员令牌。
设置用户名密码
# influx setup -u wgs-01 -p wgs-01:passwd -o wgs -b wgs -f
User Organization Bucket
wgs-01 wgs wgs
查看 Influx CLI configs
# cat /root/.influxdbv2/configs
[default]
url = "http://localhost:8086"
token = "yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A=="
org = "wgs"
active = true
查看用户列表
# influx user list
ID Name
0af25bfe35ca4000 wgs-01
查看组织列表
# influx org list
ID Name
bd8cdb1ca689b797 wgs
查看auth列表
# influx auth list
ID Description Token User Name User ID Permissions
0af25bfe450a4000 wgs-01's Token yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A== wgs-01 0af25bfe35ca4000 [read:/authorizations write:/authorizations read:/buckets write:/buckets read:/dashboards write:/dashboards read:/orgs write:/orgs read:/sources write:/sources read:/tasks write:/tasks read:/telegrafs write:/telegrafs read:/users write:/users read:/variables write:/variables read:/scrapers write:/scrapers read:/secrets write:/secrets read:/labels write:/labels read:/views write:/views read:/documents write:/documents read:/notificationRules write:/notificationRules read:/notificationEndpoints write:/notificationEndpoints read:/checks write:/checks read:/dbrp write:/dbrp read:/notebooks write:/notebooks read:/annotations write:/annotations read:/remotes write:/remotes read:/replications write:/replications]
访问 InfluxDB dashboard
创建All Access API 令牌
创建一个仅限于组织范围的所有访问令牌。
参数说明
influx auth create \
--all-access \
--host http://localhost:8086 \
--org <YOUR_INFLUXDB_ORG_NAME> \
--token <YOUR_INFLUXDB_OPERATOR_TOKEN>
--host: InfluxDB 主机 URL
标记-o, --org
或--org-id:
带有您的 InfluxDB 组织名称或 ID 的标志-t, --token:
用您的操作员令牌标记
创建 InfluxDB org API 令牌
# influx auth create --all-access --host http://localhost:8086 --org wgs --token yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A==
ID Description Token User Name User ID Permissions
0af25f14000a4000 59fSTydF26m1P34QUVE3EtAUPbjETN2mX1x5aql1A-_DqDOO0wAiWnU8KgQl-cLQ88Fh6_WalQSvNzcvouqbjQ== wgs-01 0af25bfe35ca4000 [read:orgs/bd8cdb1ca689b797/authorizations write:orgs/bd8cdb1ca689b797/authorizations read:orgs/bd8cdb1ca689b797/buckets write:orgs/bd8cdb1ca689b797/buckets read:orgs/bd8cdb1ca689b797/dashboards write:orgs/bd8cdb1ca689b797/dashboards read:/orgs/bd8cdb1ca689b797 read:orgs/bd8cdb1ca689b797/sources write:orgs/bd8cdb1ca689b797/sources read:orgs/bd8cdb1ca689b797/tasks write:orgs/bd8cdb1ca689b797/tasks read:orgs/bd8cdb1ca689b797/telegrafs write:orgs/bd8cdb1ca689b797/telegrafs read:/users/0af25bfe35ca4000 write:/users/0af25bfe35ca4000 read:orgs/bd8cdb1ca689b797/variables write:orgs/bd8cdb1ca689b797/variables read:orgs/bd8cdb1ca689b797/scrapers write:orgs/bd8cdb1ca689b797/scrapers read:orgs/bd8cdb1ca689b797/secrets write:orgs/bd8cdb1ca689b797/secrets read:orgs/bd8cdb1ca689b797/labels write:orgs/bd8cdb1ca689b797/labels read:orgs/bd8cdb1ca689b797/views write:orgs/bd8cdb1ca689b797/views read:orgs/bd8cdb1ca689b797/documents write:orgs/bd8cdb1ca689b797/documents read:orgs/bd8cdb1ca689b797/notificationRules write:orgs/bd8cdb1ca689b797/notificationRules read:orgs/bd8cdb1ca689b797/notificationEndpoints write:orgs/bd8cdb1ca689b797/notificationEndpoints read:orgs/bd8cdb1ca689b797/checks write:orgs/bd8cdb1ca689b797/checks read:orgs/bd8cdb1ca689b797/dbrp write:orgs/bd8cdb1ca689b797/dbrp read:orgs/bd8cdb1ca689b797/notebooks write:orgs/bd8cdb1ca689b797/notebooks read:orgs/bd8cdb1ca689b797/annotations write:orgs/bd8cdb1ca689b797/annotations read:orgs/bd8cdb1ca689b797/remotes write:orgs/bd8cdb1ca689b797/remotes read:orgs/bd8cdb1ca689b797/replications write:orgs/bd8cdb1ca689b797/replications]
查看auth列表
# influx auth list
ID Description Token User Name User ID Permissions
0af25bfe450a4000 wgs-01's Token yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A== wgs-01 0af25bfe35ca4000 [read:/authorizations write:/authorizations read:/buckets write:/buckets read:/dashboards write:/dashboards read:/orgs write:/orgs read:/sources write:/sources read:/tasks write:/tasks read:/telegrafs write:/telegrafs read:/users write:/users read:/variables write:/variables read:/scrapers write:/scrapers read:/secrets write:/secrets read:/labels write:/labels read:/views write:/views read:/documents write:/documents read:/notificationRules write:/notificationRules read:/notificationEndpoints write:/notificationEndpoints read:/checks write:/checks read:/dbrp write:/dbrp read:/notebooks write:/notebooks read:/annotations write:/annotations read:/remotes write:/remotes read:/replications write:/replications]
0af25f14000a4000 59fSTydF26m1P34QUVE3EtAUPbjETN2mX1x5aql1A-_DqDOO0wAiWnU8KgQl-cLQ88Fh6_WalQSvNzcvouqbjQ== wgs-01 0af25bfe35ca4000 [read:orgs/bd8cdb1ca689b797/authorizations write:orgs/bd8cdb1ca689b797/authorizations read:orgs/bd8cdb1ca689b797/buckets write:orgs/bd8cdb1ca689b797/buckets read:orgs/bd8cdb1ca689b797/dashboards write:orgs/bd8cdb1ca689b797/dashboards read:/orgs/bd8cdb1ca689b797 read:orgs/bd8cdb1ca689b797/sources write:orgs/bd8cdb1ca689b797/sources read:orgs/bd8cdb1ca689b797/tasks write:orgs/bd8cdb1ca689b797/tasks read:orgs/bd8cdb1ca689b797/telegrafs write:orgs/bd8cdb1ca689b797/telegrafs read:/users/0af25bfe35ca4000 write:/users/0af25bfe35ca4000 read:orgs/bd8cdb1ca689b797/variables write:orgs/bd8cdb1ca689b797/variables read:orgs/bd8cdb1ca689b797/scrapers write:orgs/bd8cdb1ca689b797/scrapers read:orgs/bd8cdb1ca689b797/secrets write:orgs/bd8cdb1ca689b797/secrets read:orgs/bd8cdb1ca689b797/labels write:orgs/bd8cdb1ca689b797/labels read:orgs/bd8cdb1ca689b797/views write:orgs/bd8cdb1ca689b797/views read:orgs/bd8cdb1ca689b797/documents write:orgs/bd8cdb1ca689b797/documents read:orgs/bd8cdb1ca689b797/notificationRules write:orgs/bd8cdb1ca689b797/notificationRules read:orgs/bd8cdb1ca689b797/notificationEndpoints write:orgs/bd8cdb1ca689b797/notificationEndpoints read:orgs/bd8cdb1ca689b797/checks write:orgs/bd8cdb1ca689b797/checks read:orgs/bd8cdb1ca689b797/dbrp write:orgs/bd8cdb1ca689b797/dbrp read:orgs/bd8cdb1ca689b797/notebooks write:orgs/bd8cdb1ca689b797/notebooks read:orgs/bd8cdb1ca689b797/annotations write:orgs/bd8cdb1ca689b797/annotations read:orgs/bd8cdb1ca689b797/remotes write:orgs/bd8cdb1ca689b797/remotes read:orgs/bd8cdb1ca689b797/replications write:orgs/bd8cdb1ca689b797/replications]
Influx CLI 连接配置
使用token进行身份验证
参数说明
-n, --config-name
:连接配置名称。-u, --host-url
: InfluxDB 主机 URL。-o, --org
:InfluxDB 组织名称。-t, --token
:InfluxDB org API 令牌。
创建配置wgs-02
# influx config create --config-name wgs-02 --host-url http://localhost:8086 --org wgs --token 59fSTydF26m1P34QUVE3EtAUPbjETN2mX1x5aql1A-_DqDOO0wAiWnU8KgQl-cLQ88Fh6_WalQSvNzcvouqbjQ== --active
Active Name URL Org
* wgs-02 http://localhost:8086 wgs
查看 Influx CLI configs
# cat /root/.influxdbv2/configs
[default]
url = "http://localhost:8086"
token = "yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A=="
org = "wgs"
previous = true
[wgs-02]
url = "http://localhost:8086"
token = "59fSTydF26m1P34QUVE3EtAUPbjETN2mX1x5aql1A-_DqDOO0wAiWnU8KgQl-cLQ88Fh6_WalQSvNzcvouqbjQ=="
org = "wgs"
active = true
修改 Influx CLI configs
# cat /root/.influxdbv2/configs
[wgs-02]
url = "http://localhost:8086"
token = "59fSTydF26m1P34QUVE3EtAUPbjETN2mX1x5aql1A-_DqDOO0wAiWnU8KgQl-cLQ88Fh6_WalQSvNzcvouqbjQ=="
org = "wgs"
previous = true
测试连接
# influx user list
ID Name
0af25bfe35ca4000 wgs-01
使用用户名和密码进行身份验证
查看 Influx CLI configs
# cat /root/.influxdbv2/configs
[default]
url = "http://localhost:8086"
token = "yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A=="
org = "wgs"
创建用户wgs-03
# influx user create --name wgs-03 --password ExAmPl3PA55W0rD
ID Name
0af273e1a2ff0000 wgs-03
查看用户列表
# influx user list
ID Name
0af25bfe35ca4000 wgs-01
0af273e1a2ff0000 wgs-03
创建配置wgs-03
# influx config create -n wgs-03 -u http://localhost:8086 -p wgs-03:ExAmPl3PA55W0rD -o wgs -a
Active Name URL Org
* wgs-03 http://localhost:8086 wgs
查看 Influx CLI configs
# cat ~/.influxdbv2/configs
[default]
url = "http://localhost:8086"
token = "yxhyIIkHRyQMUBKHpMMnOBd-d6DdEr-LLUgZQd0-iNJV3xB3C44AsKjrxCKh084LS2bpl6Yfcyo1mM0BSh0V8A=="
org = "wgs"
[wgs-03]
url = "http://localhost:8086"
token = ""
org = "wgs"
active = true
cookie = "d2dzLTAzOkV4QW1QbDNQQTU1VzByRA=="
修改 Influx CLI configs
# cat ~/.influxdbv2/configs
[wgs-03]
url = "http://localhost:8086"
token = ""
org = "wgs"
active = true
cookie = "d2dzLTAzOkV4QW1QbDNQQTU1VzByRA=="
测试连接
# influx user list
ID Name
0af273e1a2ff0000 wgs-03
查看dashboard
启用 shell 补全
# echo "source <(influx completion bash)" >> /root/.bashrc
influx config path
参考文档
https://docs.influxdata.com/influxdb/v2.6/tools/influx-cli/