OS:suse12
jdk:1.8
elasticsearch:6.4.0
filebeat:6.4.0
kibana:6.4.0
获取连接:
elasticserach | filebeat| kinaba
解压安装包
tar -zxf filebeat-6.4.0-linux-x86_64.tar.gz -C /app
tar -zxf elasticsearch-6.4.0.tar.gz -C /app
tar -vxf kibana-6.4.0-linux-x86_64.tar.gz -C /app
elasticsearch.yml 主配置文件
jvm.options jvm相关配置,内存等
log4j2.properties 日志相关
elasticsearch默认不允许root启动,创建用户以及用户组
96-102:/app/elasticsearch-6.4.0 # groupadd esgroup
96-102:/app/elasticsearch-6.4.0 # useradd esroot -g esgroup -p esroot
更改目录及子目录用户组
96-102:/app # chown -R esroot:esgroup elasticsearch-6.4.0
更改系统参数
96-102:/etc/security # sysctl -p
vm.max_map_count = 655360
esroot@96-102:/app/elasticsearch-6.4.0/bin> ./elasticsearch -d
-d代表后台启动
我这里启动报错
NativeController] Native controller process has stopped - no new native processes can be started
是由于系统限制,需要修改
esroot@96-102:/app/elasticsearch-6.4.0/bin> vim /etc/security/limits.conf 在末尾添加
esroot soft nofile 65536
esroot hard nofile 65536
esroot soft nproc 4096
esroot hard nproc 4096
vim filebeat.yml
filebeat.inputs:
- type: log
enabled: false 修改为true
paths:
- /var/log/*.log 修改为需要读取的日志路径,可配置多个(日志路径要能体现出日志所属模块,方便在kibana中查询日志所属模块)
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["localhost:9200"] 配置e的端口,在同一台用localhost
setup.kibana:
host: "localhost:5601" 修改kebana的ip和端口,需打开注释
初始化
启动
./filebeat setup -e 不初始化可能无法实时获取数据
后台方式启动filebeat:
./filebeat -e -c filebeat.yml >/dev/null 2>&1 & 将所有标准输出及标准错误输出到/dev/null空设备,即没有任何输出
nohup ./filebeat -e -c filebeat.yml > filebeat.log &
停止filebeat:
查找进程ID并kill掉:
ps -ef |grep filebeat
kill -9 进程号
修改配置文件
vim /app/kibana-6.4.0-linux-x86_64/config/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.url: "http://localhost:9200" 打开注释
后台启动
nohup ./bin/kibana &
创建一个索引
就可以显示elsearch中该索引的信息了
Kibana查询语言基于Lucene查询语法。下面是一些提示,可能会帮到你:
为了执行一个文本搜索,可以简单的输入一个文本字符串。例如,如果你想搜索web服务器的日志,你可以输入关键字"msgType",这样你就可以搜索到所有有关"msgType"的字段
为了搜索一个特定字段的特定值,可以用字段的名称作为前缀。例如,你输入"msgType:200",将会找到所有msgType字段的值是200的文档
为了搜索一个范围值,你可以用括号范围语法,[START_VALUE TO END_VALUE]。例如,为了找到状态码是1-20的文档,你可以输入msgType:[1TO 20]
为了指定更改复杂的查询条件,你可以用布尔操作符 AND , OR , 和 NOT。例如,为了找到状态码是4xx并且extension字段是php或者html的文档,你可以输入msgType:[1TO 20] AND (status:1 OR type:1)
Visualize:使得你可以创建在你的Elasticsearch索引中的数据的可视化效果。然后,你可以构建dashboard来展示相关可视化。