1. 程式人生 > >elasticsearch搜索引擎安裝部署

elasticsearch搜索引擎安裝部署

linu bin 交互式 jdk java環境 cluster bootstrap iba 虛擬機

實驗環境:
redhat6.5 server1 172.25.35.1
redhat6.5 server1 172.25.35.2
redhat6.5 server1 172.25.35.3
準備安裝包;
[root@server1 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因系統環境依賴
[root@server1 elk]# rpm -ivh elasticsearch-2.3.3.rpm
[root@server1 elk]# cd /etc/elasticsearch/
[root@server1 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 內存鎖定開啟
[root@server1 ~]# rpm -ivh jdk-8u121-linux-x64.rpm
[root@server1 ~]# which java 檢查java環境
/usr/bin/java
[root@server1 ~]# which javac
/usr/bin/javac
[root@server1 ~]# /etc/init.d/elasticsearch start

[root@server1 elasticsearch]# cd /var/log/elasticsearch/
[root@server1 elasticsearch]# cat my-es.log 看日誌會有報錯:
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited 會有這兩行報錯
這是沒有內存鎖定
[root@server1 elasticsearch]# vim /etc/security/limits.conf
將這兩行加到文件末尾,重起服務。註意虛擬機內存不可小於1G否則會報錯
[root@server1 elasticsearch]# /etc/init.d/elasticsearch restart
[root@server1 elasticsearch]# netstat -antlp 查看端口
瀏覽器測試: 172.25.35.1:9200
[root@server1 elasticsearch]# /usr/share/elasticsearch/bin/plugin install file:/root/elk/elasticsearch-head-master.zip 安裝master端
[root@server1 elasticsearch]# cd /usr/share/elasticsearch/plugins/
[root@server1 plugins]# cd head/
[root@server1 head]# /usr/share/elasticsearch/bin/plugin list
Installed plugins in /usr/share/elasticsearch/plugins:

  • head
    瀏覽器等入:http://172.25.35.1:9200/_plugin/head/
    簡單添加一個測試一下

[root@server1 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"]
加上集群
[root@server1 head]# /etc/init.d/elasticsearch reload 重起服務

[root@server1 head]# rpm -ivh logstash-2.3.3-1.noarch.rpm
[root@server1 head]# cd /opt/logstash/
[root@server1 logstash]# cd /opt/logstash/
[root@server1 logstash]# cd bin/
[root@server1 bin]# ls
[root@server1 bin]# ./logstash -e ‘input {stdin { } } output { stdout {} }‘
[root@server1 bin]# ./logstash -e ‘input {stdin { } } output { elasticsearch {hosts => ["172.25.35.1"] index => "logstash-%{+YYYY.MM.dd}" }}‘
[root@server1 bin]# ./logstash -e ‘input {stdin { } } output { elasticsearch {hosts => ["172.25.35.1"] index => "logstash-%{+YYYY.MM.dd}" } stdout {codec => rubydebug} }‘ 交互式添加幾個文件看一下
[root@server1 bin]# cd /etc/logstash/
[root@server1 logstash]# cd conf.d/ 建立以conf結尾的配置文件
[root@server1 conf.d]# vim es.conf
input {
stdin {}
}

output {
elasticsearch {
hosts => ["172.25.35.1"]
index => "index-%{+YYYY.MM.dd}"
}
stdout {
codec => rubydebug
}
}
[root@server1 conf.d]# /opt/logstash/bin/logstash -f /etc/logstash/conf.d/es.conf 執行瀏覽器驗證

elasticsearch搜索引擎安裝部署