本文主要是介绍centos6.8 ---influxdb,grafana,telegraf避坑指南(个人血泪史),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
指南
不得不说的话
开头一句好家伙好吧,centos6.8能给自己送走。当然了,现在还能活得好好的,仅以此篇文章给各位大佬们,以及后来的自己一个提示。
influxdb的安装
步骤
1.influxdb下载地址
influxdb下载资源地址
2.上传到服务器
3.使用
yum install influxdb-1.6.0.x86_64.rpm
一句好家伙,镜像失效了,不怕。来,使用下面命令,一样给你在centos6.8上安装好:
rpm -i influxdb-1.6.0.x86_64.rpm
4.查看influx的默认用户
cat /etc/passwd
5.修改telegraf的配置文件
路径 如下:
/etc/influxdb/influxdb.conf
6.修改配置文件(建议可以看看具体内容-说人话就是上面的注解)
[meta]# Where the metadata/raft database is storeddir = "/usr/local/influxdb/meta"
[data]# The directory where the TSM storage engine stores TSM files.dir = "/usr/local/influxdb/data"# The directory where the TSM storage engine stores WAL files.wal-dir = "/usr/local/influxdb/wal"
[coordinator]
[retention]
[shard-precreation]
[monitor]
[http]# Determines whether HTTP endpoint is enabled.enable = true# The bind address used by the HTTP service.bind-address = "192.168.1.101:8086"auth-enabled = true
[ifql]
[logging]
[subscriber]
[[graphite]]
[[collectd]]
[[opentsdb]]
[[udp]]
[continuous_queries]
7.创建目录,更新权限
mkdir -pv /usr/local/influxdb
chown -R influxdb:influxdb /usr/local/influxdb/
8.启动和开机启动(从centos 7)
systemctl restart influxdb
systemctl enable influxdb
在centos6.8中使用
service influxdb start
自启动使用(service influxdb enable start–应该不对,各位看官可以搜搜看)
9. 查看的一些命令
ps auxf
netstat -tulnp|grep influx
ps -ef|grep influx
10创建密码
CREATE USER “tangtang” WITH PASSWORD ‘password’ WITH ALL PRIVILEGES
influxdb搭建完成(待续)
书接上回。(大声喊出我们的口号,技术分享-ook)好的,继续向前进
grafana搭建
下载地址
https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.1-1.x86_64.rpm
安装
rpm -ivh grafana-5.2.1-1.x86_64.rpm
算了,没办法。6.8镜像消失真的就没办法解决了?不是的,还是可以的
操作如下:
cd /etc/yum.repos.d/
rm -rf *
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/http/https/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/$releasever/6.8/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/centos/centos-vault/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
配置好了
感谢这个大佬好吧。
大佬教程,岂敢贪天之功
回归正题,继续运行。
service grafana-server start
service grafana-server enable start(猜想进行到底,蛮猜可以开机自启)
http://192.168.1.101:3000/login
下期继续(晚上太忙了,运动项目一个不能少,明天给你们将活整到底)–后续更精彩。
话接上回,今早继续。
telegraf数据采集
根据前面的讲解(这里就不赘述了),yum源也有了直接下载包,安装
wget 'https://dl.influxdata.com/telegraf/releases/telegraf-1.10.3-1.x86_64.rpm'
yum localinstall telegraf-1.10.3-1.x86_64.rpm
在配置文件中修改
文件位置
/etc/telegraf/telegraf.conf
[global_tags]
[agent]interval = "10s"round_interval = truemetric_batch_size = 1000metric_buffer_limit = 10000collection_jitter = "0s"flush_interval = "10s"flush_jitter = "0s"precision = ""debug = falsequiet = falselogfile = "/tmp/telegraf.log"hostname = ""omit_hostname = false
[[outputs.influxdb]]urls = ["http://192.168.1.101:8086"]database = "telegraf"username = "tangtang"password = "password"
[[inputs.cpu]]percpu = falsetotalcpu = truecollect_cpu_time = falsereport_active = false
启动telegraf
service telegraf restart
service telegraf enable start
启动influxdb验证
笔者亲历的就是绑定不一致的问题,直接进入influxdb中查找不出来,这时候就需要看你influx的配置文件中绑定的地址是啥呢?
influx -host 192.168.1.101 -username 'tangtang' -password 'password' -database telegraf
select * from cpu;
如果没有数据的话,可以看看telegraf的日志文件(看具体的传输会报怎样的错误)
tail /tmp/telegraf.log
前面是硬件的采集
下面讲nginx与mysql的采集
(nginx也是一步血泪史(centos6.8的小版本)之前用的1.10.3 改为1.18版本好了,建议使用高版本)
在nginx安装包中(nginx安装不在赘述),解压之后,编译之前加上
./configure --prefix=/usr/local/nginx
--with-http_ssl_module
--with-http_stub_status_module
--with-stream
--with-stream_ssl_module
主要是
–with-http_stub_status_module
之后
make && make install
之后流程就是
Nginx配置新增
location = /status {allow 192.168.0.0/16;deny all;stub_status on;access_log off;}验证Nginx的状态信息获取
curl 192.168.237.50/statusTelegraf采集Nginx配置
[[inputs.nginx]]urls = ["http://192.168.237.50/status"]保留监控项目
time accepts active handled host port reading requests server waiting writing
mysql(简述)
Mysql权限配置
1. grant usage on *.* to 'telegraf'@'192.168.%' identified by 'telegraf';
2. flush privileges;Telegraf监控Mysql配置
[[inputs.mysql]]servers = ["telegraf:telegraf@tcp(192.168.237.50:3306)/?tls=false"]
fieldpass = ["bytes_received", "bytes_sent", "commands_select", "commands_update", "commands_delete", "commands_insert", "connections", "threads_connected"]
脚本测试数据
while true;do mysql -uroot -e "select * from mysql.user limit 1";sleep 1; done
解决问题((o゜▽゜)o☆[BINGO!])
下一章(Mysql慢查询)
这篇关于centos6.8 ---influxdb,grafana,telegraf避坑指南(个人血泪史)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!