How to create database and user in influxdb programmatically?

守給你的承諾、 提交于 2019-12-11 04:25:41

问题


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.

Could someone help me with this?


回答1:


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:

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.




回答2:


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

here's the ansible module documentation that you can use http://docs.ansible.com/ansible/influxdb_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

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

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



来源:https://stackoverflow.com/questions/38656960/how-to-create-database-and-user-in-influxdb-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!