端口说明
8083:访问web页面的地址,8083为默认端口;
8086:数据写入influxdb的地址,8086为默认端口;
8088:数据备份恢复地址,8088为默认端口;
#安装
yum -y install wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.8.x86_64.rpm
#启动,并设置自启
systemctl start influxdb
systemctl enable influxdb
influxd
#停止服务
systemctl stop influxdb
查看
#打开influx数据库
influx
#创建用户
CREATE USER QGS WITH PASSWORD '111111' WITH ALL PRIVILEGES
#查询用户
SHOW USERS
#创建数据库
CREATE DATABASE QGS
#查询数据库
SHOW DATABASES
卸载influxdb:
4. 输入: rpm -q influxdb 查询influxdb包的名字
5. 输入:rpm -e influxdb 删除特定的rpm包
6. 输入:rpm -q influxdb 查询influxdb包是否删除
2.CentOS下安装telegraf
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.20.4-1.x86_64.rpm
yum localinstall telegraf-1.20.4-1.x86_64.rpm
安装完成后配置文件的默认路径在/etc/telegraf/telegraf.conf
修改配置文件将数据指向数据源,这里我用的是本地的Influxdb
vim /etc/telegraf/telegraf.conf
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
# urls = ["unix:///var/run/influxdb.sock"]
# urls = ["udp://127.0.0.1:8089"]
urls = ["http://127.0.0.1:8086"]
## The target database for metrics; will be created as needed.
## For UDP url endpoint database needs to be configured on server side.
database = "telegraf"
//参考配置
[global_tags]
[agent]
interval = "5m"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "30s"
flush_jitter = "0s"
precision = ""
hostname = "yu17-ks-6b669819"
omit_hostname = false
[[outputs.influxdb]]
urls = ["http://136.36.89.03:8086"]
database = "telegraf"
username = "telegraf"
password = "111222"
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.net]]
interfaces = ["*"]
[[outputs.influxdb]]
urls = ["http://ppcdncloud.com:8086"]
database = "telegraf"
username = "telegraf"
password = "111222"
开启telegraf服务,这时telegraf开始收集本机数据并发送到influxdb
systemctl start telegraf
[vagrant@td ~]$ influx
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES
name: databases
name
----
_internal
test
telegraf
> USE telegraf
Using database telegraf
> SHOW MEASUREMENTS
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system
> select * from "mem" limit 5
查询net表最近10秒的数据
select bytes_recv,bytes_sent,host from net where time >now() -10s
//指定host
select bytes_recv,bytes_sent,host from net where time >now() -10s and host='vmtds'
//limit 1 跟在最后 只查询一条
select bytes_recv,bytes_sent,host from net where time >now() -100s and host!='vmtds' limit 1
//字符串模糊查询 limit 放在 order by的后面 limit 放在语句最后面
select bytes_recv,bytes_sent,host from net where host=~/.*t.*/ order by time desc limit 20
//数字类型用范围查询
select bytes_recv,bytes_sent,host from net where host=~/.*t.*/ and bytes_sent>2592 order by time desc limit 20
select count(bytes_recv) from net group by host

3 安装 grafana
镜像地址:下载飞快
Index of /grafana/yum/rpm/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
wget https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/grafana-7.5.8-1.x86_64.rpm
yum install grafana-7.5.8-1.x86_64.rpm
启动 grafana
systemctl start grafana-server
systemctl enable grafana-server
浏览器访问3000端口
3.1 选择大屏模板 Dashboards | Grafana Labs
选择模板 得到id直接导入 简单粗暴

//-----------
1206

被折叠的 条评论
为什么被折叠?



