Home » Default » Centos下安装GoAccess分析Tomcat日志

安装依赖组件

yum install GeoIP-devel.x86_64
yum install ncurses-devel
yum install tokyocabinet-devel
yum install bzip2-devel
yum install openssl-devel
yum install libmaxminddb
yum install libmaxminddb-devel
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx

编译安装B+Tree

wget http://fallabs.com/tokyocabinet/tokyocabinet-1.4.48.tar.gz
tar -zxvf tokyocabinet-1.4.48.tar.gz
cd tokyocabinet-1.4.48
./configure --prefix=/usr --enable-off64 --enable-fastest
make
make install

编译安装goaccess

$ wget https://tar.goaccess.io/goaccess-1.3.tar.gz
$ tar -xzvf goaccess-1.3.tar.gz
$ cd goaccess-1.3/
$ ./configure --enable-utf8 --enable-geoip=legacy
$ make
# make install

新建goaccess配置文件
/usr/local/etc/goaccess-tomcat.conf

time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %l %^[%d:%t %^] "%m %U %H" %s %b %T "%R" %u

Tomcat log格式设置:与goaccess log-format对应

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %t &quot;%r&quot; %s %b %T &quot;%{Referer}i&quot; %{User-Agent}i" />

运行goaccess输出到nginx,(Tomcat日志文件applog.txt通过ftp定时上传至/var/ftp/)

goaccess /var/ftp/applog.txt -o /usr/share/nginx/html/index.html -p /usr/local/etc/goaccess-tomcat.conf --real-time-html  --daemonize --geoip-database=/usr/share/GeoIP/GeoLiteCity.dat

查看goaccess后台运行状态,(服务端与浏览器默认通过TCP7890端口实现实时传输)
netstat -anptu | grep goaccess

tcp 0 0 0.0.0.0:7890        0.0.0.0:*            LISTEN        2383/goaccess  
tcp 0 0 192.168.1.1:7890    192.168.10.1:60536    ESTABLISHED 2383/goaccess

标签: centos goaccess Tomcat Nginx daemonize

添加新评论

V