docker pull sebp/elk
//Elasticsearch至少須要單獨2G的內存 //增長了一個volume綁定,以避免重啓container之後ES的數據丟失 docker run -d -p 5044:5044 -p 127.0.0.1:5601:5601 -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -v /var/data/elk:/var/lib/elasticsearch --name=elk sebp/elk
若啓動過程出錯通常是由於elasticsearch用戶擁有的內存權限過小,至少須要262144docker
切換到root用戶 執行命令: sysctl -w vm.max_map_count=262144 查看結果: sysctl -a|grep vm.max_map_count 顯示: vm.max_map_count = 262144
上述方法修改以後,若是重啓虛擬機將失效,因此: 解決辦法: 在 /etc/sysctl.conf文件最後添加一行 vm.max_map_count=262144 便可永久修改
啓動成功以後訪問:http://
docker exec -it <container-name> /bin/bash
/opt/logstash/bin/logstash -e 'input { stdin { } } output { elasticsearch { hosts => ["localhost"] } }' /* 注意:若是看到這樣的報錯信息 Logstash could not be started because there is already another instance using the configured data directory. If you wish to run multiple instances, you must change the "path.data" setting. 請執行命令:service logstash stop 而後在執行就能夠了。 */
當命令成功被執行後,看到:Successfully started Logstash API endpoint {:port=>9600} 信息後,輸入:this is a dummy entry 而後回車,模擬一條日誌進行測試。
打開瀏覽器,輸入:http://
input { kafka{ //此處注意:logstash5.x版本之前kafka插件配置的是zookeeper地址,5.x之後配置的是kafka實例地址 bootstrap_servers =>["192.168.121.205:9092"] client_id => "test" group_id => "test" consumer_threads => 5 decorate_events => true topics => "logstash" } } filter{ json{ source => "message" } } output { elasticsearch { hosts => ["192.168.121.205"] index=> "hslog_2" codec => "json" } }