安装
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.2.x86_64.rpm
yum -y localinstall influxdb-1.8.2.x86_64.rpm
#以服务方式启动influxdb
systemctl start influxdb
建立自己的数据库及用户
#进入influx客户端命令操作
influx
#新建数据库
create database log_db
#查看所有数据库
show databases
#建立数据库新用户,注意密码要用单引号包住,如果需要成为管理员,追加(with all privileges)
create user "centos" with password 'centos123'
#查看所有用户
show users
#使用自己的数据库
use log_db
#显示所有表(可能没有任何表,不要急,先安装Telegraf)
show measurements
#2.0版本需要通过网站管理
http://主机:8086
安装
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.7.4-1.x86_64.rpm
yum localinstall telegraf-1.7.4-1.x86_64.rpm
配置Telegraf
vi /etc/telegraf/telegraf.conf
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
urls = ["http://127.0.0.1:8086"]
## The target database for metrics; will be created as needed.
database = "log_db"
## Name of existing retention policy to write to. Empty string writes to
## the default retention policy. Only takes effect when using HTTP.
retention_policy = ""
## Timeout for HTTP messages.
timeout = "5s"
## HTTP Basic Auth
username = "centos"
password = "centos123"
#如果想用指定的主机名来显示的话可以修改
[agent]
## Override default hostname, if empty use os.Hostname()
hostname = "192.168.1.50"
启动Telegraf
systemctl start telegraf
此时由于之前建立的Influxdb数据库“log_db”衔接上了,这时再查看下原来log_db下的表,发现有表了,这是由于Telegraf启动后,开始抓取数据,安装配置文件,写入到了我们自建的数据库中,数据表是自动创建的。
官网 https://grafana.com/grafana/download
最新版本
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.2-1.x86_64.rpm
启动
systemctl start grafana-server
#启动grafana,并设置其开机自启
systemctl enable grafana-server
1、在浏览器中输入:http://主机ip:3000,进入登录界面,默认第一次用户名是 admin,密码也是admin,然后会让你修改密码,操作完毕就进入了主页面。
2、添加数据源
3、官方仪表盘 https://grafana.com/grafana/dashboards/?dataSource=influxdb