一、常用脚本

influx
show databases
#如果没有collectdb数据库则执行以下脚本创建
create database collectdb

#修改配置文件
vim /etc/influxdb/influxdb.conf

二、修改配置信息如下

[collectd]
                enabled = true
                bind-address = "127.0.0.1:25826"      #InfluxDB的安装服务器ip
                database = "collectdb"
                typesdb = "/usr/share/collectd/types.db" #查找一下types.db文件不一定在这个路径,如果路径配置错误就不能监听成功(与collectd的配置保持一致)
                batch-size = 5000
                batch-pending = 10
                batch-timeout = "10s"
                read-buffer = 0
重启InfluxDB服务
[root@betterday collectd]# systemctl restart influxdb.service #重启InfluxDB服务
[root@betterday collectd]# netstat -anp| grep 25826 #查看端口是否已监听,如果有则代表启动正常
udp        0      0 127.0.0.1:25826         0.0.0.0:*                           22580/influxd  

 确认数据:

[root@betterday collectd]# influx
Connected to http://localhost:8086 version 1.2.4
InfluxDB shell version: 1.2.4
> use collectdb
Using database collectdb
> show field keys
name: cpu_value
fieldKey fieldType
-------- ---------
value    float

name: disk_io_time
fieldKey fieldType
-------- ---------
value    float

name: disk_read
fieldKey fieldType
-------- ---------
value    float

name: disk_value
fieldKey fieldType
... ...

> select * from cpu_value limit 3; #显示3条cpu_value的信息
name: cpu_value
time host instance type type_instance value
---- ---- -------- ---- ------------- -----
1622448294392956261 localhost 0 percent user 1.8108651911468812
1622448294392962804 localhost 0 percent system 0.9054325955734406
1622448294392965492 localhost 0 percent wait 0.10060362173038229

 

posted on 2021-05-31 19:23  拥抱天空的风  阅读(287)  评论(0编辑  收藏  举报