ELK安装
- logstash安装部署
- 首先下载logstash-all-plugins-2.3.1.tar.gz。
- 上传并解压到指定目录。
cd /usr/local tar -zxvf logstash-all-plugins-2.3.1.tar.gz
- 编辑logstash的配置文件,若不存在指定文件则新建。
vim /usr/local/logstash-2.3.1/etc/logstash.conf
- 配置监听指定目录下的tomcat日志文件,并发送给elasticsearch
input { file { type => "messages" path => ["/usr/tomcat/apache-tomcat-7.0.59-8080-baheal/logs/catalina.out"] } } output { elasticsearch { hosts => ["192.168.0.160:9200"] index => "logstash-%{type}-%{+YYYY.MM.dd}" document_type => "%{type}" workers => 1 flush_size => 20000 idle_flush_time => 10 template_overwrite => true } }
- 另一种配置:配置监听指定端口,并发送给mongodb与elasticsearch
input { tcp { port => 10002 mode => "server" ssl_enable => false codec => "json" } udp { port => 10003 codec => "json" } } output { elasticsearch { hosts => ["10.104.48.184:9200"] index => "%{appName}-%{type}-%{+YYYY.MM.dd}" workers => 1 flush_size => 20000 idle_flush_time => 10 template_overwrite => true } } output { #stdout { codec => rubydebug } mongodb { collection => "log" database => "log" uri => "mongodb://10.104.48.184:27017,10.104.47.134:27017/?replicaSet=dbset" } }
- %{appName}跟%{type}属于传递过来的json参数
- 到安装目录下启动logstash
./bin/logstash -f etc/logstash.conf
- elasticsearch安装部署
- 由于elasticsearch不允许直接使用root进行安装,所以要单独建一个用户。
useradd elk --创建用户elk passwd elk --给已创建的用户elk设置密码
- 用新用户elk登录系统,并解压文件。
cd /home/elk tar -zxvf elasticsearch-2.3.1.tar.gz
- 编辑配置文件
vim /home/elk/elasticsearch-2.3.1/config/elasticsearch.yml
- 配置es的地址跟端口。也可以使用默认值。
network.host: 192.168.0.160 http.port: 9200
- 到es的安装目录下启动es
./bin/elasticsearch
- 测试是否启动成功
curl 'http://192.168.0.160:9200/?pretty'
启动时可能出现如下错误:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法:
调整max_map_count大小
sysctl -w vm.max_map_count=655360
查看是否修改成功
sysctl -a | grep "vm.max_map_count"也可修改配置文件,让其永久生效
相关推荐
goodstudy 2020-08-19
weikaixxxxxx 2020-08-01
liulin0 2020-07-26
AFei00 2020-07-26
娜娜 2020-07-20
偏头痛杨 2020-07-18
winxcoder 2020-07-18
superviser000 2020-06-28
liulin0 2020-06-25
liulin0 2020-06-16
wangfengqingyang 2020-06-11
cullinans 2020-06-09
winxcoder 2020-06-08
citic 2020-06-06
goodstudy 2020-06-05
superviser000 2020-05-30
yuzhongdelei0 2020-05-15
wzhwangzhuohui 2020-05-12
李玉志 2020-05-11