docker部署influxdb

参考

https://www.cnblogs.com/Detector/p/10104254.html
https://blog.csdn.net/weixin_44062177/article/details/116330290

image-20230526224422699

一. influxdb容器化部署

镜像可选:

1
2
3
4
# 官网镜像
tutum/influxdb
# 阿里云镜像
registry.cn-hangzhou.aliyuncs.com/zznn/mycentos:tutum-influxdb

docker命令行的方式:

1
docker run -di -p 8083:8083 -p 8086:8086 --expose 8090 --expose 8099 --name influx tutum/influxdb 

docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
version: "3.0"
services:
influxdb:
image: tutum/influxdb
# registry.cn-hangzhou.aliyuncs.com/zznn/mycentos:tutum-influxdb
container_name: influx
# environment:
# - INFLUXDB_ADMIN_ENABLED:"true"
ports:
- "8083:8083"
- "8086:8086"
expose:
- 8090
- 8099
# volumes:
# - influxdb-storage:/var/lib/influxdb
networks:
- tpng
networks:
tpng:
driver: bridge

二. influxdb常规操作

image-20230526225139820

创建用户创建数据库授予用户操作数据库的所有权限

1
2
3
4
5
6
7
8
[root@manager ~]# influx 
> create database telegraf;
> use telegraf;
> create user "fxkj" with password '123456' with all privileges;
> show users;
user admin
---- -----
fxkj true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 查看所有用户
> show users
user admin
---- -----
# 创建一个root用户,设置密码为newpwd,主要不要使用双引号" 括起来,不然会报错
> create user "root" with password 'newpwd'
# 再次查看用户信息,发现admin为false,说明还要设置一下权限。
> show users
user admin
---- -----
root false
# 删除root用户
> drop user root
> show users
user admin
---- -----
Ø create database vmware;
# 重新设置root用户,并设置带上所有权限
Ø create user "root" with password 'newpwd' with all privileges;
# 发现admin权限为true了,那么admin的用户就创建好了。
Ø show users
user admin
---- -----
root true

开启http登录授权

1
2
3
4
5
6
7
8
# 开启http登录授权修改/etc/influxdb/influxdb.conf 文件中的[http]部分,将以下两个参数设置为true
[http]
# Determines whether HTTP endpoint is enabled.
enabled = true
# Determines whether user authentication is enabled over HTTP/HTTPS.
auth-enabled = true
# 重启生效
systemctl restart influxdb

效果

image-20230527142352705

image-20230527142434850