如何以编程的方式创建数据库和用户?

时间:2021-05-03 23:02:04

In my use case I am using single ec2 instance [not a cluster]. I want to create a database and an user with all privileges programmatically? Is there a config file which I can edit and copy to the right location after influxdb is installed.

在我的用例中,我使用的是单个ec2实例(而不是集群)。我想以编程方式创建一个数据库和一个具有所有权限的用户?是否有一个配置文件,我可以在安装了影响数据库后编辑并复制到正确的位置。

Could someone help me with this?

有人能帮我一下吗?

2 个解决方案

#1


2  

There isn't any config option that you can use to do that with InfluxDB itself. After starting up an instance you can use the InfluxDB HTTP to create the users. The curl command to do so would be the following:

没有任何配置选项可以用于使用影响数据库本身。在启动实例之后,您可以使用influence xdb HTTP来创建用户。curl命令如下:

curl "http://localhost:8086/query" --data-urlencode "q=CREATE USER myuser WITH PASSWORD 'mypass' WITH ALL PRIVILEGES"

Just run this command for each of the users you'd like to create. After that, you'll need to enabled the auth value of the [http] section of the config.

只需为您想要创建的每个用户运行此命令。之后,您将需要启用配置的[http]部分的auth值。

#2


0  

you can use ansible to setup influxb with your own recipe.

你可以用ansible来设置影响你的食谱。

here's the ansible module documentation that you can use http://docs.ansible.com/ansible/influxdb_database_module.html

下面是可以使用的模块文档,您可以使用http://docs.ansible.com/ansible/influence xdb_database_module.html

or, any config/deploy manager that you prefer. i'd do this anyday instead of some ssh script or who knows what. https://forge.puppet.com/tags/influxdb

或者,您喜欢的任何配置/部署管理器。我每天都做这个,而不是使用ssh脚本,或者谁知道什么。https://forge.puppet.com/tags/influxdb

chef. https://github.com/bdangit/chef-influxdb

厨师。https://github.com/bdangit/chef-influxdb

and also, you can use any of the above config managers to provision/manipulate your ec2 instance(s).

而且,您还可以使用上面的任何配置管理器来提供/操作ec2实例。

#1


2  

There isn't any config option that you can use to do that with InfluxDB itself. After starting up an instance you can use the InfluxDB HTTP to create the users. The curl command to do so would be the following:

没有任何配置选项可以用于使用影响数据库本身。在启动实例之后,您可以使用influence xdb HTTP来创建用户。curl命令如下:

curl "http://localhost:8086/query" --data-urlencode "q=CREATE USER myuser WITH PASSWORD 'mypass' WITH ALL PRIVILEGES"

Just run this command for each of the users you'd like to create. After that, you'll need to enabled the auth value of the [http] section of the config.

只需为您想要创建的每个用户运行此命令。之后,您将需要启用配置的[http]部分的auth值。

#2


0  

you can use ansible to setup influxb with your own recipe.

你可以用ansible来设置影响你的食谱。

here's the ansible module documentation that you can use http://docs.ansible.com/ansible/influxdb_database_module.html

下面是可以使用的模块文档,您可以使用http://docs.ansible.com/ansible/influence xdb_database_module.html

or, any config/deploy manager that you prefer. i'd do this anyday instead of some ssh script or who knows what. https://forge.puppet.com/tags/influxdb

或者,您喜欢的任何配置/部署管理器。我每天都做这个,而不是使用ssh脚本,或者谁知道什么。https://forge.puppet.com/tags/influxdb

chef. https://github.com/bdangit/chef-influxdb

厨师。https://github.com/bdangit/chef-influxdb

and also, you can use any of the above config managers to provision/manipulate your ec2 instance(s).

而且,您还可以使用上面的任何配置管理器来提供/操作ec2实例。