目录
环境搭建
rpm安装
端口
配置文件
启动
查看状态
查看web页面
SHELL命令
链接shell
创建数据库
查看数据库
创建用户
--管理员用户
--创建普通用户并且授权
-- 创建数据库
-- 查询所有表
-- 删除
--写入
--查询具体表数据
-- 清空表数据
JAVA API 使用
yml配置influxdb
Bean方式配置
API调用
官方API
代码详见:
参考资料
环境搭建
rpm安装
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64.rpm
yum influxdb-1.2.4.x86_64.rpm
此处安装的是1.2.4,需要注意的是,高版本的不支持web访问。
其他版本的安装可以参考官网,讲解的很详细
https://docs.influxdata.com/influxdb/v1.7/introduction/installation/
端口
port 8083:管理页面端口,访问localhost:8083可以进入你本机的influxdb管理页面;
port 8086:http连接influxdb client端口,一般使用该端口往本机的influxdb读写数据。
配置文件
/etc/influxdb/influxdb.conf 采用最简单的配置,修改一下2处,分别是设置web访问和http访问的端口、密码
[admin]
# Determines whether the admin service is enabled.
enabled = true
#WEB页面的端口
# The default bind address used by the admin service.
bind-address = ":8083"
[http]
# Determines whether HTTP endpoint is enabled.
# enabled = true
# The bind address used by the HTTP service.
bind-address = ":8086"
#开启密码
# Determines whether HTTP authentication is enabled.
auth-enabled = true
启动
systemctl start influxdb
查看状态
[root@axe1 influxdb]# systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series database
Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-10-08 18:54:59 CST; 8min ago
Docs: https://docs.influxdata.com/influxdb/
Main PID: 860 (influxd)
CGroup: /system.slice/influxdb.service
└─860 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
Oct 08 18:55:00 axe1 influxd[860]: [I] 2019-10-08T10:55:00Z Authentication enabled:true service=httpd
Oct 08 18:55:00 axe1 influxd[860]: [I] 2019-10-08T10:55:00Z Listening on HTTP:[::]:8086 service=httpd
Oct 08 18:55:00 axe1 influxd[860]: [I] 2019-10-08T10:55:00Z Starting retention policy enforcement service with check interval of 30m0s service=retention
Oct 08 18:55:00 axe1 influxd[860]: [I] 2019-10-08T10:55:00Z Listening for signals
Oct 08 18:55:00 axe1 influxd[860]: [I] 2019-10-08T10:55:00Z Storing statistics in database '_internal' retention policy 'monitor', at interval 10s service=monitor
Oct 08 18:55:00 axe1 influxd[860]: [I] 2019-10-08T10:55:00Z Sending usage statistics to usage.influxdata.com
Oct 08 18:55:01 axe1 influxd[860]: [I] 2019-10-08T10:55:01Z beginning level 2 compaction of group 0, 1 TSM files engine=tsm1
Oct 08 18:55:01 axe1 influxd[860]: [I] 2019-10-08T10:55:01Z compacting level 2 group (0