Logstash có thể sử dụng cơ sở dữ liệu GeoLiteCity.dat đi kèm để tra cứu địa lý IP. Cơ sở dữ liệu này có giống như the one provided by MaxMind không? MaxMind cập nhật cơ sở dữ liệu vào ngày thứ Ba đầu tiên của mỗi tháng.Tôi có nên cập nhật GeoLiteCity.dat định kỳ không?
Bạn có nên thiết lập công việc để tự động làm mới cơ sở dữ liệu thay vì đợi cập nhật Logstash từ ElasticSearch không?
EDIT: ngày 1 tháng 12 năm 2014 Đây là tập lệnh bash tôi đã viết để thực hiện tự động cập nhật cơ sở dữ liệu. Đọc của tôi về the source code for this filter là một khởi động lại dịch vụ có lẽ là cần thiết để mất các tập tin cơ sở dữ liệu cập nhật.
#!/bin/bash
# Downloads the latest GeoLight DBs from maxmind.
# Updates/replaces the databases that logstash uses.
# These are the IP-to-location databases that logstash uses.
# Maxmind updates them once a month on the first Tuesday of the month.
# See http://dev.maxmind.com/geoip/legacy/geolite/
echo Beginning update of GeoIP databases for logstash.
cd /tmp
rm -f GeoIPASNum.dat.gz GeoIPASNum.dat GeoLiteCity.dat.gz GeoLiteCity.dat
echo Downloading latest files.
wget --quiet --output-document GeoIPASNum.dat.gz http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz || { echo 'Download of GeoIPASNum.dat.gz failed' ; exit 1; }
wget --quiet --output-document GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz || { echo 'Download of GeoLiteCity.dat.gz failed' ; exit 1; }
echo Unzipping
gunzip GeoIPASNum.dat.gz
gunzip GeoLiteCity.dat.gz
echo Setting permissions
chmod 664 GeoIPASNum.dat GeoLiteCity.dat
chown logstash:logstash GeoIPASNum.dat GeoLiteCity.dat
echo Replacing existing files and backing up the old.
cd /opt/logstash/vendor/geoip/
mv -f GeoIPASNum.dat GeoIPASNum.dat.bak && mv /tmp/GeoIPASNum.dat .
mv -f GeoLiteCity.dat GeoLiteCity.dat.bak && mv /tmp/GeoLiteCity.dat .
echo Restarting logstash
# Modify for your distro services model.
service logstash restart
echo Done
Tìm thấy nguồn cho bộ lọc địa lý: https://github.com/logstash-plugins/logstash-filter-geoip/blob/master/lib/logstash/filters/geoip.rb Nó nhắc tôi rằng tôi có thể đặt cấu hình một vị trí thay thế cho các cơ sở dữ liệu này, mà có khả năng sẽ là một giải pháp tốt hơn so với ghi đè cơ sở dữ liệu phân tán. –
Ngớ ngẩn của nó khi phải khởi động lại logstash mỗi lần một GeoLiteCity.dat mới được thả vào vị trí. Tôi thấy có một tùy chọn để có "periodic_flush" nhưng tôi không chắc chắn những gì mà không chính xác hoặc thường xuyên như tất cả nó nói là: "Gọi phương pháp tuôn ra bộ lọc ở khoảng thời gian thường xuyên" (https://www.elastic.co/ hướng dẫn/vi/logstash/2.4/plugins-filters-geoip.html # plugins-filters-geoip-periodic_flush) – totalflux