当前,我正在尝试连接到Platform.sh上托管的InfluxDB,但没有任何运气。
我遵循了https://docs.platform.sh/configuration/services/influxdb.html中所述的设置指令。完成这些步骤后,该服务就可以在Platform.sh上使用。
之后,我使用Platform.sh的社区指南(https://community.platform.sh/t/how-to-access-influxdb-credentials-on-platform-sh/148)连接到数据库。
然后我运行以下命令并选择了连接到InfluxDB服务的应用程序(Grafana)
platform tunnel:single && export PLATFORM_RELATIONSHIPS="$(platform tunnel:info --encode)"
Enter a number to choose an app:
[0] app
[1] grafana
> 1
Enter a number to choose a relationship:
[0] datadb
[1] confdb ([email protected])
> 0
SSH tunnel opened to datadb at: http://127.0.0.1:30000
然后我连接到InfluxDB并尝试创建数据库:
influx -host '127.0.0.1' -port '30000'
Connected to http://127.0.0.1:30000 version 1.7.10
InfluxDB shell version: v1.7.9
> CREATE DATABASE test
ERR: error authorizing query: create admin user first or disable authentication
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
不幸的是,关系JSON不包含任何用户或默认数据库信息:
datadb:
-
service: timedb
ip: 169.254.1.23
hostname: abcd.timedb.service._.eu-4.platformsh.site
cluster: abcdg-feature-platform-test-1234
host: datadb.internal
rel: influxdb
scheme: http
type: 'influxdb:1.7'
port: 8086
url: 'http://datadb.internal:8086'
我如何连接到数据库?是否有默认用户或默认数据库?还是可以在services.yaml中定义一些设置?
谢谢!
[我在Platform.sh forums上了解到,我必须创建一个管理员用户。隧道开放后,我必须运行:
influx -host 127.0.0.1 -port 30000
Connected to http://127.0.0.1:30000 version 1.7.10
InfluxDB shell version: v1.7.9
> CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES
此后,我使用新创建的用户重新连接到数据库
influx -host 127.0.0.1 -port 30000 -username admin -password ''