geoipupdate地图坐标

1 rpm包安装

1.1 下载地址

https://github.com/maxmind/geoipupdate/releases

1.2 安装

rpm -Uvhi geoipupdate_4.8.0_linux_amd64.rpm

参数

详解

/usr/bin/geoipupdate

安装完之后目录在

/etc/GeoIP.conf

配置文件

2 二进制安装

2.1 下载地址

wget https://github.com/maxmind/geoipupdate/releases/download/v4.8.0/geoipupdate_4.8.0_linux_amd64.tar.gz

2.2 解压安装

tar xf geoipupdate_4.8.0_linux_amd64.tar.gz
cd geoipupdate_4.8.0_linux_amd64

mv GeoIP.conf /usr/local/etc/
mv geoipupdate /usr/local/bin/

2.3 修改配置文件

创建目录

/data/GeoIP
vim /usr/local/etc/GeoIP.conf
AccountID 663496
LicenseKey V20Y8fQHR4lG4tmY
# 需要下载的ip库
EditionIDs GeoLite2-ASN GeoLite2-City GeoLite2-Country
# 下载ip库的保存路径
DatabaseDirectory /data/GeoIP

2.4 更新数据

/usr/local/bin/geoipupdate

2.5 添加定时更新

crontab -e
# 此处可以根据实际情况编写更新脚本放在此处执行
17 3 * * 3 /usr/local/bin/geoipupdate > /tmp/geoip.log 2>&1

2.6 配置logstash相关配置文件

vim /etc/logstash/conf.d/nginx.conf
filter {
geoip {
source => "[realip]"
target => "geoip"
# 此处设置自定义ip库
database => "/data/GeoIP/GeoLite2-City.mmdb"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float"]
convert => [ "responsetime", "float"]
}
}