目的:简单易用,一次性分析(当然也可以实时分析)。
第一步:安装各种库(基于centos)
yum install gcc openssl openssl-devel libmaxminddb libmaxminddb-devel glib2 glib2-devel ncurses ncurses-devel GeoIP GeoIP-devel
第二步:下载程序源码和 MaxMind城市/国家数据库
wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
wget http://tar.goaccess.io/goaccess-1.2.tar.gz
解压安装编译设置:
./configure --enable-geoip=mmdb --enable-utf8 --enable-geoip=mmdb --with-openssl
第三步:修改配置文件,编译的配置文件在/usr/local/etc/goaccess.conf ,解析nginx日志为例:
只需打开
time-format %H:%M:%S、
date-format %d/%b/%Y、
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"即可
第四步:解析日志文件:
/usr/local/bin/goaccess -d -f access.log -p /usr/local/etc/goaccess.conf -a --geoip-database=/data/web-logs/GeoLite2-City_20190319/GeoLite2-City.mmdb > test.html
第五步:test.html拖到电脑的浏览器打开即可看到结果。
转载于:https://blog.51cto.com/luots/2368492