作者:小荷蛋蛋图_945 | 来源:互联网 | 2024-11-11 19:54
本文详细介绍了InfluxDB、collectd和Grafana的安装与配置流程。首先,按照启动顺序依次安装并配置InfluxDB、collectd和Grafana。InfluxDB作为时序数据库,用于存储时间序列数据;collectd负责数据的采集与传输;Grafana则用于数据的可视化展示。文中提供了collectd的官方文档链接,便于用户参考和进一步了解其配置选项。通过本指南,读者可以轻松搭建一个高效的数据监控系统。
启动顺序:influxdb-->collectd-->Grafana
######安装collectd(采集工具)
参考链接:https://collectd.org/documentation/manpages/collectd.conf.5.shtml
yum install epel-release //一个源地址
yum install collectd
yum install collectd-postgresql //postgresql插件
yum install collectd-redis //redis插件
######配置
vim /etc/collectd.conf
参考链接:https://collectd.org/documentation/manpages/collectd.conf.5.shtml
collectd 配置文件模块
#
# Host "host.foo.bar"
# Interval 1.0
# Timeout 0.9
# TTL 255
# SourceAddress "1.2.3.4"
# Device "eth0"
# MaxMissed -1
#
#######维护命令
systemctl start collectd.service
systemctl stop collectd.service
systemctl restart collectd.service
systemctl status collectd.service
systemctl enable collectd.service
###### 安装influxdb(时序数据库)
参考链接:https://docs.influxdata.com/influxdb/v1.2/introduction/installation/
###### 添加influxdb.repo
vim /etc/yum.repos.d/influxdb.repo
###### influxdb.repo内容
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
###### 安装
sudo yum install influxdb
######配置
vim /etc/influxdb/influxdb.conf
####### 需要修改的地方
[[collectd]]
enabled = true
bind-address = ":25826"
database = "collectdb"
typesdb = "/usr/share/collectd/types.db" //需要安装 yum install collectd
####### 命令
sudo service influxdb start
systemctl start influxdb.service
systemctl stop influxdb.service
systemctl restart influxdb.service
systemctl status influxdb.service
systemctl enable influxdb.service
####### 安装Grafana(可视化工具)
参考链接:http://docs.grafana.org/installation/rpm/
####### 添加grafana.repo
vim /etc/yum.repos.d/grafana.repo
####### grafana.repo内容
[grafana]
name=grafana
baseurl=https://packagecloud.io/grafana/stable/el/6/$basearch
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
###### 安装
sudo yum install grafana
###### 安装插件
grafana-cli plugins install grafana-piechart-panel //饼图
####### 配置
默认http端口3000,
默认用户admin/admin
默认配置文件 /etc/grafana/grafana.ini
默认日志 /var/log/grafana
默认数据库 sqlite3 路径/var/lib/grafana/grafana.db,升级grafana前请备份数据库
Installs binary to /usr/sbin/grafana-server
Installs Init.d script to /etc/init.d/grafana-server
Creates default file (environment vars) to /etc/default/grafana-server
Installs configuration file to /etc/grafana/grafana.ini
Installs systemd service (if systemd is available) name grafana-server.service
The default configuration sets the log file at /var/log/grafana/grafana.log
The default configuration specifies an sqlite3 db at /var/lib/grafana/grafana.db
###### 命令
systemctl daemon-reload //开机自启
systemctl start grafana-server
systemctl stop grafana-server
systemctl status grafana-server
sudo systemctl enable grafana-server.service //开机自启