elasticsearch部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch部署相关的知识,希望对你有一定的参考价值。
实验环境:
redhat6.5 server1 172.25.35.1
redhat6.5 server1 172.25.35.2
redhat6.5 server1 172.25.35.3
准备安装包;
[[email protected] elk]# ls
bigdesk-master.zip jemalloc-devel-3.6.0-1.el6.x86_64.rpm
elasticsearch-2.3.3.rpm kibana-4.5.1-1.x86_64.rpm
elasticsearch-head-master.zip logstash-2.3.3-1.noarch.rpm
elk日志分析平台.pdf nginx-1.8.0-1.el6.ngx.x86_64.rpm
jemalloc-3.6.0-1.el6.x86_64.rpm redis-3.0.6.tar.gz
安装:
elasticsearch-2.3.3.rpm jdk-8u121-linux-x64.rpm因系统环境依赖
[[email protected] elk]# rpm -ivh elasticsearch-2.3.3.rpm
[[email protected] elk]# cd /etc/elasticsearch/
[[email protected] elasticsearch]# vim elasticsearch.yml 写 配置文件
cluster.name: my-es
node.name: server1
network.host: 172.25.35.1
#
Set a custom port for HTTP:
#
http.port: 9200
bootstrap.mlockall: true 内存锁定开启
[[email protected] ~]# rpm -ivh jdk-8u121-linux-x64.rpm
[[email protected] ~]# which java 检查java环境
/usr/bin/java
[[email protected] ~]# which javac
/usr/bin/javac
[[email protected] ~]# /etc/init.d/elasticsearch start
[[email protected] elasticsearch]# cd /var/log/elasticsearch/
[[email protected] elasticsearch]# cat my-es.log 看日志会有报错:
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited 会有这两行报错
这是没有内存锁定
[[email protected] elasticsearch]# vim /etc/security/limits.conf
将这两行加到文件末尾,重起服务。注意虚拟机内存不可小于1G否则会报错
[[email protected] elasticsearch]# /etc/init.d/elasticsearch restart
[[email protected] elasticsearch]# netstat -antlp 查看端口
浏览器测试: 172.25.35.1:9200
[[email protected] elasticsearch]# /usr/share/elasticsearch/bin/plugin install file:/root/elk/elasticsearch-head-master.zip 安装master端
[[email protected] elasticsearch]# cd /usr/share/elasticsearch/plugins/
[[email protected] plugins]# cd head/
[[email protected] head]# /usr/share/elasticsearch/bin/plugin list
Installed plugins in /usr/share/elasticsearch/plugins:
- head
浏览器等入:http://172.25.35.1:9200/_plugin/head/
简单添加一个测试一下
[[email protected] head]# vim /etc/elasticsearch/elasticsearch.yml 添加节点
node.master: true
node.data: false
将安装包发给 jdk-8u121-linux-x64.rpm,elasticsearch-2.3.3.rpm server2和server3 安装
配置同server1方法一致:以server2为例:
node.name: server2
node.master: false
node.data: true
network.host: 172.25.35.2
http.port: 9200
cluster.name: my-es
bootstrap.mlockall: true
同时所有server配置文件开启:
discovery.zen.ping.unicast.hosts: ["server1", "server2","server3"]
加上集群
[[email protected] head]# /etc/init.d/elasticsearch reload 重起服务
[[email protected] head]# rpm -ivh logstash-2.3.3-1.noarch.rpm
[[email protected] head]# cd /opt/logstash/
[[email protected] logstash]# cd /opt/logstash/
[[email protected] logstash]# cd bin/
[[email protected] bin]# ls
[[email protected] bin]# ./logstash -e ‘input {stdin { } } output { stdout {} }‘
[[email protected] bin]# ./logstash -e ‘input {stdin { } } output { elasticsearch {hosts => ["172.25.35.1"] index => "logstash-%{+YYYY.MM.dd}" }}‘
[[email protected] bin]# ./logstash -e ‘input {stdin { } } output { elasticsearch {hosts => ["172.25.35.1"] index => "logstash-%{+YYYY.MM.dd}" } stdout {codec => rubydebug} }‘ 交互式添加几个文件看一下
[[email protected] bin]# cd /etc/logstash/
[[email protected] logstash]# cd conf.d/ 建立以conf结尾的配置文件
[[email protected] conf.d]# vim es.conf
input {
stdin {}
}
output {
elasticsearch {
hosts => ["172.25.35.1"]
index => "index-%{+YYYY.MM.dd}"
}
stdout {
codec => rubydebug
}
}
[[email protected] conf.d]# /opt/logstash/bin/logstash -f /etc/logstash/conf.d/es.conf 执行浏览器验证
以上是关于elasticsearch部署的主要内容,如果未能解决你的问题,请参考以下文章
elk(elasticsearchlogstast,kibana)filebeat部署与实践