1.下载安装包
安装包地址:/rhel/\$releasever/\$basearch/stable
,可根据版本号和分支进行下载。
# 本次安装的服务器版本信息
rpm -qi centos-release
Name : centos-release
Version : 7
Release : 9.2009.1.
Architecture: x86_64
Install Date: Tue 08 Feb 2022 02:59:59 PM CST
Group : System Environment/Base
Size : 44787
License : GPLv2
Signature : RSA/SHA256, Thu 03 Dec 2020 12:35:28 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : centos-release-7-9.2009.1.
Build Date : Mon 23 Nov 2020 11:08:41 PM CST
Build Host :
Relocations : (not relocatable)
Packager : CentOS BuildSystem <>
Vendor : CentOS
Summary : CentOS Linux release file
Description :
CentOS Linux release files
本次的下载地址是:/rhel/7/x86_64/stable
,安装文件为influxdb-1.7.6.x86_64.rpm
。
2.安装并绑定端口
# 1.本地安装
yum localinstall -y influxdb-1.7.6.x86_64.rpm
# 2.修改配置
vim /etc/influxdb/
# 以下三个文件夹可根据需要进行修改
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
# http相关参数
[http]
# 开启 HTTP API
enabled = true
# bind-address = ":8086"
# 默认绑定端口为 8086可进行修改
bind-address = ":18088"
# auth-enabled = false
# 用户及密码验证默认关闭【注意】创建管理员用户后生产环境进行开启
auth-enabled = true
3.启动服务并创建管理员用户
首先启动 influxdb 服务端:
# 1.正常后台启动
[root@aliyun ~]# systemctl start influxd
# 前台启动可以查看运行状态 也可以用 -config 指定启动时的配置文件
[root@aliyun ~]# /usr/bin/influxd
8888888 .d888 888 8888888b. 888888b.
888 d88P" 888 888 "Y88b 888 "88b
888 888 888 888 888 888 .88P
888 88888b. 888888 888 888 888 888 888 888 888 8888888K.
888 888 "88b 888 888 888 888 Y8bd8P' 888 888 888 "Y88b
888 888 888 888 888 888 888 X88K 888 888 888 888
888 888 888 888 888 Y88b 888 .d8""8b. 888 .d88P 888 d88P
8888888 888 888 888 888 "Y88888 888 888 8888888P" 8888888P"
进入命令行工具界面进行用户添加,由于修改了默认绑定的端口,需要添加-port
参数指定端口:
# 2.进入命令行工具
[root@aliyun ~]# influx -port '18088'
Connected to http://localhost:18088 version 1.7.6
InfluxDB shell version: 1.7.6
Enter an InfluxQL query
# 创建管理员用户
> create user "admin" with password 'admin' with all privileges;
# 查看用户信息
> show users;
user admin
---- -----
admin true
4.开启用户密码认证
vim /etc/influxdb/
# 相关参数
[http]
# 用户及密码验证默认关闭【注意】创建管理员用户后生产环境进行开启
auth-enabled = true
重启服务后使用用户名及密码进行登录:
# 重启服务
systemctl restart influxd
# 如果不使用用户及密码登录操作时会报错
[root@aliyun ~]# influx -port '18088'
Connected to http://localhost:18088 version 1.7.6
InfluxDB shell version: 1.7.6
Enter an InfluxQL query
> show users;
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
# 验证用户及密码
> auth
username: admin
password:
> show users;
user admin
---- -----
admin true
# 使用用户名及密码正确登录
[root@aliyun ~]# influx -port '18088' -username 'admin' -password 'admin'
Connected to http://localhost:18088 version 1.7.6
InfluxDB shell version: 1.7.6
Enter an InfluxQL query
> show users;
user admin
---- -----
admin true
5.开机自启配置
# enable 不能用 提示层级太深
systemctl enable influxd
Failed to execute operation: Too many levels of symbolic links
修改/etc/
文件实现开启启动:
vim /etc/
# 添加启动命令
systemctl start influxd