测试积点老人 发表于 2023-2-1 11:53:18

搭建轻量级性能监控平台(Jmeter+InfluxDB+Grafana)<二>

本帖最后由 测试积点老人 于 2023-2-1 11:55 编辑

二、CentOS安装:
  方式一:把下载的.rpm包推送到服务器上;
  方式二:直接命令行安装
#下载
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.1.x86_64.rpm
#安装
yum localinstall?influxdb-1.7.1.x86_64.rpm -y2.3 修改配置文件
  解压完成的InfluxDB,主要有四个文件夹:data、Influxdb-1.8.4.1、meta、wal,如下图:
http://www.51testing.com/attachments/2023/01/15326825_202301301158051JvSm.png
  Meta目录:用于存储数据库的一些元数据,meta.db 文件;
  Wal目录:放预写日志文件,以 .wal 结尾;
  Data目录:存放实际存储的数据文件,以 .tsm 结尾;
  Influxdb目录:主程序运行文件。
  这里,需要修改Influxdb.conf文件,如下:
  【Meta】
  dir = “InfluxDB安装的路径/meta”
http://www.51testing.com/attachments/2023/01/15326825_202301301158052stTj.png
  【data】
  dir = “InfluxDB安装的路径/data”
  wal-dir =“InfluxDB安装的路径/wal”
http://www.51testing.com/attachments/2023/01/15326825_202301301158053g2Vz.png
  【http】
  enabled = true
http://www.51testing.com/attachments/2023/01/15326825_202301301158054RFwK.png
  修改完配置文件,我们就尝试着启动InfluxDB。
  2.4常用命令
  1、启动命令:
  ①启动conf文件:
cmd?>cd?D:\ProgramFiles\influxdb-1.8.4_windows_amd64\influxdb-1.8.4-1??
cmd?>influxd?--config?influxdb.conf

 Influxdb.conf启动
http://www.51testing.com/attachments/2023/01/15326825_202301301158055MEFg.png
  ②启动Influxdb.exe:
cmd?>cd?D:\ProgramFiles\influxdb-1.8.4_windows_amd64\influxdb-1.8.4-1??
cmd?>influx

 Influxdb.exe启动
http://www.51testing.com/attachments/2023/01/15326825_202301301158056Cnzu.png
  2、常用命令
#显示用户
showusers

#创建用户
createuser"username"withpassword'password'

#创建管理员权限用户
createuser"username"withpassword'password'withallprivileges

#删除用户
dropuser"username"

#创建数据库
createdatabase"db_name"

#显示所有的数据库
showdatabases

#删除数据库
dropdatabase"db_name"

#使用数据库
usedb_name

#显示该数据库中所有的表
showmeasurements

#创建表,直接在插入数据的时候指定表名,其中test为表名
inserttest,host=127.0.0.1,monitor_name=testcount=1

#删除表
dropmeasurement"measurement_name"

#查询数据
select*fromtestorderbytimedesc

#查看当前数据库的数据保存策略(RetentionPolicies)
showretentionpolicieson"db_name"

#创建新的数据保存策略
#rp_name:策略名
#db_name:具体的数据库名;
#3w:保存3周,3周之前的数据将被删除,influxdb具有各种事件参数,比如:h(小时),d(天),w(星期)
#replication1:副本个数,一般为1就可以了
#default:设置为默认策略
createretentionpolicy"rp_name"on"db_name"duration3wreplication1default

#修改数据保存策略
alterretentionpolicy"rp_name"on"db_name"duration30ddefault

#删除数据保存策略
dropretentionpolicy"rp_name"

#查看数据库的连续查询(ContinousQueries)
showcontinuousqueries

#创建新的连续查询(ContinousQueries)
#cq_name:连续查询名字
#db_name:数据库名字
#sum(count):计算总和
#table_name:当前表名
#new_table_name:存新的数据的表名
#30m:时间间隔为30分钟
createcontinousquerycq_nameondb_namebeginselectsum(count)intonew_table_namefromtable_namegroupbytime(30m)end

#删除连续查询
dropcontinousquerycp_nameondb_name


Influxdb数据库表常规操作:
http://www.51testing.com/attachments/2023/01/15326825_202301301158057WTFs.png
  到这里, Influxdb 数据库的安装配置,启动,以及常规的操作都完成了。
  但是,你会想到,我怎么才能写入数据呢?我又如何才能把Influxdb中的数据可视化展示出来呢?
  别着急,我们需要先把前期工作都完成,才能进入到数据的写入。
  所以,接下来,我们就要安装Grafana。





页: [1]
查看完整版本: 搭建轻量级性能监控平台(Jmeter+InfluxDB+Grafana)<二>