在centos安装influxdb
1,获取安装包
官网,需要注册
https://www.influxdata.com/get-influxdb/
#下载
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.3.x86_64.rpm
#安装
sudo yum localinstall influxdb-1.8.3.x86_64.rpm
influxdb安装好之后,输入influx -version可查看版本,
配置文件默认路径/etc/influxdb/influxdb.conf
2,启动与关闭
启动命令
systemctl start influxdb.service
#重启命令
systemctl restart influxdb.service
关闭命令
systemctl stop influxdb.service
查看状态
systemctl status influxdb.service
[root@ops-test-03 ~]# netstat -nulpt | grep influxd
tcp 0 0 127.0.0.1:8088 0.0.0.0:* LISTEN 9610/influxd
tcp6 0 0 :::8086 :::* LISTEN 9610/influxd
用命令systemctl start influxdb.service启动influxdb使用的是默认配置/etc/influxdb/influxdb.conf
具体配置可参看如下:
[root@ops-test-03 ~]# cat /usr/lib/systemd/system/influxdb.service
# If you modify this, please also make sure to edit init.sh
[Unit]
Description=InfluxDB is an open-source, distributed, time series database
Documentation=https://docs.influxdata.com/influxdb/
After=network-online.target
[Service]
User=influxdb
Group=influxdb
LimitNOFILE=65536
EnvironmentFile=-/etc/default/influxdb
ExecStart=/usr/bin/influxd -config /etc/influxdb/influxdb.conf $INFLUXD_OPTS
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=influxd.service
注意:influx启动后默认占用默8086/8088两个端口号,如下是influxdb.conf部分配置:
# Bind address to use for the RPC service for backup and restore.
# bind-address = "127.0.0.1:8088"
# The bind address used by the HTTP service.
# bind-address = ":8086"
如需要修改端口,可将注释打开,修改即可。
三,基本使用
连接客户端
influxdb是没有密码的,输入influx回车即可进入到influxdb的客户端,输入exit或者quit退出客户端。
四,创建用户+设置密码+权限管理
没有密码也可以正常使用,但是为了安全起见,可以为其创建用户和设置密码。输入influx,连上influxdb客户端,然后在客户端里输入:
# 创建用户并设置密码
create user root with password 'root@0721'
# 查看所有用户
show users
# 修改密码
set password for root='root@0987'
# 删除用户
drop user xxx
# 查询用户的权限
show grants for <username>
# 授权
GRANT ALL PRIVILEGES TO <username>
GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
# 回收权限
REVOKE ALL PRIVILEGES FROM <username>
REVOKE [READ,WRITE,ALL] ON <database_name> FROM <username>
# 创建用户+密码+授权
create user root with password 'root@0721' with all privileges
开启权限验证:
创建用户+设置密码+权限管理之后,还需要修改配置/etc/influxdb/influxdb.conf
vim /etc/influxdb/influxdb.conf
开启权限验证
auth-enabled = true
重启influxdb并连接测试:
重启
systemctl restart influxdb.service
输入用户名+密码连接
influx -username root -password root@0721
也可以输入influx,在客户端输入auth验证用户名和密码:
[root@ops-test-03 ~]# influx
Connected to http://localhost:8086 version 1.8.3
InfluxDB shell version: 1.8.3
> auth
username: root
password: