ElasticSearch5.6-安裝常見錯誤

                               ElasticSearch安裝常見錯誤java

     ElasticSearch是一個用Java開發的基於Lucene的搜索服務器。它能夠提供一個分佈式多用戶能力的全文搜索引擎,基於RESTfulweb接口。現階段它主要爲Apache許可條款下的開放源碼發佈,也是當前流行的企業級搜索引擎。Elasticsearch設計主要用於雲計算中,ElasticSearch實時搜索,穩定,可靠,快速,安裝使用方便的優勢,很好的解決大數據查詢緩慢問題。node

 如今咱們來安裝使用 ElasticSearch,能夠這樣說5.6以上的版本,安裝時出的問題是比較多的,但咱們能夠經過提示來解決這些問題。mysql

 基於咱們是測試使用,我只需在一臺上安裝就能夠了,首先 ElasticSearch是基於java來開發的,因此咱們好安裝java包。web

[root@node2 ~]# yum install  -y *jdk   安裝java環境
[root@node2 ~]# cd /usr/local/src/
[root@node2 src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz

 ##官網下載5.6以上的版本sql

[root@node2 ~]# java -version  ###查看java版本
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)  ###能夠看到已經安裝java的最新版本了。

##解壓安裝 ElasticSearchbootstrap

[root@node2 src]# tar -xf elasticsearch-5.6.3.tar.gz   ##解壓
[root@node2 src]# cd elasticsearch-5.6.3
[root@node2 elasticsearch-5.6.3]# ls
bin  config  lib  LICENSE.txt  modules  NOTICE.txt  plugins  README.textile
[root@node2 elasticsearch-5.6.3]# vim config/
elasticsearch.yml  jvm.options        log4j2.properties  
[root@node2 elasticsearch-5.6.3]# vim config/elasticsearch.yml  ###修改下面兩項
network.host: 172.25.0.30    ###爲本地ip,監聽主機
discovery.zen.minimum_master_nodes: 1   ###我這裏只有一臺,因此修改成1

接下來咱們啓動看看vim

錯誤一:ruby

咱們會發現啓動錯誤。會彈出下面的報錯,抱錯以下圖:bash

48b269f65bc775e6d0d0baa60c27d977.jpg-wh_

主要緣由是已經有提示了:Caused by: java.lang.RuntimeException: can not run elasticsearch as root,說是不能在root用戶下運行,接下來咱們換個用戶來運行。服務器

[root@node2 bin]# useradd dashuju
[root@node2 bin]# su - dashuju
[dashuju@node2 ~]$ cd /usr/local/src/elasticsearch-5.6.3/

錯誤二:

啓動後咱們發現了錯誤

[dashuju@node2 bin]$ ./elasticsearch
Exception in thread "main" 2017-11-12 12:17:55,776 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.
2017-11-12 12:17:56,319 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")

這也是根據問題緣由去解決,解決方法以下:

[root@node2 ~]# yum install -y log4j*    ###安裝log4j包
[root@node2 ~]# chown dashuju:dashuju -R  /usr/local/src/elasticsearch-5.6.3  ###給予elasticsearch權限

錯誤三:

繼續啓動:

[dashuju@node2 bin]$ ./elasticsearch
ERROR: [2] bootstrap checks failed   ##還有錯誤,這個是要改文件數,這個由於太多我就不放圖了。
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

咱們改一下限制的文件數就能夠了

[root@node1 src]# cat /etc/sysctl.conf 
vm.max_map_count=655360
[root@node2 src]# cat /etc/security/limits.conf 
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
[root@node2 ~]# sysctl -p
vm.max_map_count = 655360

注:###最好重啓一下,而後執行一遍

[dashuju@node2 bin]$ ./elasticsearch    
[root@node2 ~]# netstat -ntpl   ###查看一下服務,能夠看到elasticsearch已經起來了,端口9200和9300
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1178/sshd           
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      847/rsync           
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 172.25.0.30:9200        :::*                    LISTEN      1650/java           
tcp6       0      0 :::2224                 :::*                    LISTEN      866/ruby            
tcp6       0      0 172.25.0.30:9300        :::*                    LISTEN      1650/java           
tcp6       0      0 :::22                   :::*                    LISTEN      1178/sshd           
tcp6       0      0 :::873                  :::*                    LISTEN      847/rsync           
tcp6       0      0 :::3306                 :::*                    LISTEN      1436/mysqld

再訪問如下咱們9200端口,也已經成功了,能夠看到elasticsearch的信息了。        

[root@node2 ~]# curl 172.25.0.30:9200
{
  "name" : "XjOLC6R",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "45286kMyRMqEsjgH04lQCg",
  "version" : {
    "number" : "5.6.3",
    "build_hash" : "1a2f265",
    "build_date" : "2017-10-06T20:33:39.012Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}

我的總結:elasticsearch的安裝使用並不難,咱們在使用是隻要是注意它啓用時,所提示的錯誤,而後針對性的解決就能夠。以上是我在安裝使用elasticsearch所遇到問題,但願能幫到你們。

相關文章
相關標籤/搜索