ELK之安装与部署
来源:互联网 发布:cad软件锁不起作用 编辑:程序博客网 时间:2024/04/30 18:08
elasticsearch负责存储数据,充当搜索引擎
logstash包括index和agent,前者负责收集数据,后者负责过滤数据
kibana提供友好的web界面
其中,elasticsearch与logstash是java编写,需要部署jdk1.8.0
kibana用node.js框架
服务器之间的时间需要实时且同步
防火墙和selinux保持关闭
环境
192.168.2.112 jdk/elasticsearch/kibana CentOS release 6.5
192.168.2.118 jdk/logstash CentOS release 6.3 (Final)
elasticsearch部署
elasticsearch的主要配置参数
cluster.name: chuck-cluster 判别节点是否是统一集群node.name: linux-node1 节点的hostnamepath.data: /data/es-data 数据存放路径path.logs: /var/log/elasticsearch/ 日志路径bootstrap.mlockall: true 锁住内存,使内存不会在swap中使用network.host: 0.0.0.0 允许访问ES的iphttp.port: 9200 端口
安装步骤
mkdir elktest;cd elktestwget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gztar -zxvf elasticsearch-5.3.0.tar.gzmv elasticsearch-5.3.0 /usr/local/elasticsearch/
- ES参数配置
cd /usr/local/elasticsearch/config
1)在elasticsearch.yml里,在Network下面配置监听地址和端口
network.host: 0.0.0.0http.port: 9200
2)由于centos6不支持seccomp,需要在Memory下面添加(注意顺序)
bootstrap.memory_lock: falsebootstrap.system_call_filter: false
3)在后面的head插件安装后需要配置跨域操作
http.cors.enabled: truehttp.cors.allow-origin: "*"
4)若内存不够大,可以把默认分配jvm的空间设置成1G
在/usr/local/elasticsearch/config/jvm.options里修改
-Xms1g-Xmx1g
- 内核参数配置
1)有时候在启动es的时候会提示elasticsearch process is too low, increase to at least [65536]
在/etc/security/limits.conf添加
* soft nofile 65536* hard nofile 65536
2)若提示max number of threads [1024] for user [hadoop] is too low, increase to at least [2048]
在/etc/security/limits.d/90-nproc.conf把1024改成2048
* soft nproc 1024
3)若提示max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
在/etc/sysctl.conf文件尾部添加
vm.max_map_count=655360
4)最后执行
sysctl -p
5)由于ES5.3不能用root启动,需要建立子账号来启动ES
useradd elkchown -R elk:elk /usr/local/elasticsearchsu - elk/usr/local/elasticsearch/bin/elasticsearch -dps -ef| grep elasticsearchnetstat -tunlp | grep -E "9200|9300"
如下图所示:
启动ES后
[root@log-nginx logs]# curl 192.168.2.112:9200{ "name" : "Li5G4mg", "cluster_name" : "elasticsearch", "cluster_uuid" : "w3Iu6U4kQWqc6Sdtoq88pQ", "version" : { "number" : "5.3.0", "build_hash" : "3adb13b", "build_date" : "2017-03-23T03:31:50.652Z", "build_snapshot" : false, "lucene_version" : "6.4.1" }, "tagline" : "You Know, for Search"}
- ES插件head安装
yum -y install nodejs npmyum install -y gitcd /usr/local/elasticsearch/git clone https://github.com/mobz/elasticsearch-head.gitcd elasticsearch-headnpm install 如果网速不好,用下面一行的命令#npm install -g cnpm --registry=https://registry.npm.taobao.org
1)head修改监听地址,在Gruntfile.js下添加hostname: ‘*’,
connect: { server: { options: { hostname: '*', port: 9100, base: '.', keepalive: true } } }
2)设置head连接ES的ip地址,在_site/app.js下
this.prefs.get("app-base_uri") || "http://192.168.2.112:9200";
3)启动head服务
cd /usr/local/elasticsearch/elasticsearch-head/nohup ./node_modules/grunt/bin/grunt server &>/dev/null &
如下图所示:
logstash部署
wget https://artifacts.elastic.co/do4wnloads/logstash/logstash-5.3.0.tar.gztar -zxvf logstash-5.3.0.tar.gzmv logstash-5.3.0 /usr/local/logstashcd /usr/local/logstashmkdir etc; cd etc
1)建立文件logstash.conf并添加下面内容
input { stdin { }}output { stdout { codec => rubydebug {}} elasticsearch { hosts => "192.168.2.112" }}
2)启动logstash
/usr/local/logstash/bin/logstash -f logstash.conf# nohup /usr/local/logstash/bin/logstash -f logstash.conf &>/dev/null & 后台启动
3)此时开启了ES后,再执行logstash启动命令,则如下图所示:
4)然后继续在界面输入内容,则会把数据发送给ES:
在网页上可以看到:
上图中外围带绿色框的为主分片,不带框的为副本分片,另外图右上角显示黄色背景,是因为没有设置副本
kibana部署
wget https://artifacts.elastic.co/downloads/kibana/kibana-5.3.0-linux-x86_64.tar.gztar -zxvf kibana-5.3.0-linux-x86_64.tar.gzmv kibana-5.3.0-linux-x86_64 /usr/local/kibana/
1)kibana参数配置
进入cd /usr/local/kibana/config/kibana.yml里设置
server.port: 5601server.host: "0.0.0.0"elasticsearch.url: "http://192.168.2.112:9200" 设置与ES的连接
2)启动kibana
nohup /usr/local/kibana/bin/kibana &>/dev/null &
在web界面,需要配置至少一个索引模式,用于确认ES index,实现搜索和分析功能
Index contains time-based events 索引基于时间的事件Logstash-* 定义动态的索引名字,用符号*作为通配符@timestamp
按照上图配置点击create按钮后,进入discover页面,默认搜索时间是最近15分钟,可以点击右上角的时间修改
当有数据的时候,如下图所示:
至此ELK环境部署完成。
- ELK之安装与部署
- ELK服务端安装部署
- elk安装部署
- elk之logstash安装与配置
- elk之elasticsearch安装与配置
- elk之kibana安装与配置
- elk日志系统安装部署
- ELK之Logstash安装与配置及使用
- ELK之Filebeat安装与配置及使用
- linux下ELK Stack的安装部署
- ELK在linux部署安装(一)
- Doker ELK 的安装部署使用教程
- ELK部署
- win7之elk安装、配置
- (零)ELK学习之ELK安装配置
- ELK日志架构一之ELK简介及Elasticsearch安装
- ELK日志套件安装与使用
- Kibana安装与基本用法(ELK)
- Spring的@Value获取不到值的问题
- RecyclerView 滚动到指定position,并置顶
- H(n) UVA
- 玫瑰花
- 我的电路实践
- ELK之安装与部署
- 找出数组中重复的数字
- 4.1.2Groovy理解闭包
- jdk环境配置
- 软件工程(C编码实践篇)学习总结
- android获取系统标准时区的时间
- VBA基础打卡
- 简单的桃心,haha
- JavaScript的this学习笔记