日志类的数据时候存储在时序数据库中,下面就是时序数据库influxdb的安装

curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -source /etc/lsb-releaseecho "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | tee /etc/apt/sources.list.d/influxdb.list

apt-get updateapt-get install influxdbservice influxdb start

输入influx进入管理终端influxcreate database sinamailuse sinamailselect * from webmail_log

这个sql语句这样理解,空格分割开,空格前面的叫tag,后面的叫fieldtag有索引 field没有索引,如果查询比较多就把要查的定义成tag多个tag用逗号分割 ,多个field也要逗号分割

插入和查询,注意引号的使用,使用不对插不进去,查不出来insert webmail_log,ip=111.222.333.444,username=taoshihan method="/index.php",ua="ios"

select * from webmail_log where ip='111.222.333.444'

相关文章

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。