Elasticsearch5 部署

一、因Elasticsearch是基於Java寫的,因此它的運行環境中須要java的支持,在Linux下執行命令:java -version,檢查Jar包是否安裝java

安裝java版本至少是1.8以上node

 

二、首先準備下載Elasticsearch5.5.2 安裝包linux

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gzexpress

 

三、下載到/usr/local 目錄下,解壓bootstrap

tar -zxvf  elasticsearch-5.2.2.tar.gzvim

 

四、由於Elasticsearch5.0以後,不能使用root帳戶啓動,咱們先建立一個elasticsearch組和帳戶app

groupadd elasticsearchless

useradd  elasticsearch -g elasticsearch -p elasticsearchcurl

chown -R elasticsearch:elasticsearch elasticsearch-5.2.2elasticsearch

或者sudo chown -R myes elasticsearch

 

 

五、啓動elasticsearch

cd /usr/local/elasticsearch5.2.2/

su elasticsearch

./bin/elasticsearch

 

這時候咱們看見下面的提示,說明就成功了

這時候咱們看見下面的提示,說明就成功了

 

[plain] view plain copy

print?

  1. [elasticsearch@vmlnx-sma bin]$ ./elasticsearch  
  2. [2017-03-02T21:43:21,185][INFO ][o.e.n.Node               ] [] initializing ...  
  3. [2017-03-02T21:43:21,264][INFO ][o.e.e.NodeEnvironment    ] [uY3prpy] using [1] data paths, mounts [[/ (/dev/mapper/VolGroup-lv_root)]], net usable_space [43.5gb], net total_space [54.6gb], spins? [possibly], types [ext4]  
  4. [2017-03-02T21:43:21,265][INFO ][o.e.e.NodeEnvironment    ] [uY3prpy] heap size [1.9gb], compressed ordinary object pointers [true]  
  5. [2017-03-02T21:43:21,268][INFO ][o.e.n.Node               ] node name [uY3prpy] derived from node ID [uY3prpyqTHim5twauiVWhQ]; set [node.name] to override  
  6. [2017-03-02T21:43:21,271][INFO ][o.e.n.Node               ] version[5.2.2], pid[5602], build[f9d9b74/2017-02-24T17:26:45.835Z], OS[Linux/3.10.5-3.el6.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_121/25.121-b13]  
  7. [2017-03-02T21:43:22,226][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [aggs-matrix-stats]  
  8. [2017-03-02T21:43:22,226][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [ingest-common]  
  9. [2017-03-02T21:43:22,226][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [lang-expression]  
  10. [2017-03-02T21:43:22,227][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [lang-groovy]  
  11. [2017-03-02T21:43:22,227][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [lang-mustache]  
  12. [2017-03-02T21:43:22,227][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [lang-painless]  
  13. [2017-03-02T21:43:22,228][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [percolator]  
  14. [2017-03-02T21:43:22,228][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [reindex]  
  15. [2017-03-02T21:43:22,228][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [transport-netty3]  
  16. [2017-03-02T21:43:22,229][INFO ][o.e.p.PluginsService     ] [uY3prpy] loaded module [transport-netty4]  
  17. [2017-03-02T21:43:22,230][INFO ][o.e.p.PluginsService     ] [uY3prpy] no plugins loaded  
  18. [2017-03-02T21:43:24,689][INFO ][o.e.n.Node               ] initialized  
  19. [2017-03-02T21:43:24,689][INFO ][o.e.n.Node               ] [uY3prpy] starting ...  
  20. [2017-03-02T21:43:24,929][INFO ][o.e.t.TransportService   ] [uY3prpy] publish_address {10.245.250.65:9300}, bound_addresses {10.245.250.65:9300}  
  21. [2017-03-02T21:43:24,948][INFO ][o.e.b.BootstrapChecks    ] [uY3prpy] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks  
  22. [2017-03-02T21:43:28,010][INFO ][o.e.c.s.ClusterService   ] [uY3prpy] new_master {uY3prpy}{uY3prpyqTHim5twauiVWhQ}{AqALBH68RCucWcPmHCE6dw}{10.245.250.65}{10.245.250.65:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)  
  23. [2017-03-02T21:43:28,034][INFO ][o.e.h.HttpServer         ] [uY3prpy] publish_address {10.245.250.65:9200}, bound_addresses {10.245.250.65:9200}  
  24. [2017-03-02T21:43:28,034][INFO ][o.e.n.Node               ] [uY3prpy] started  
  25. [2017-03-02T21:43:28,061][INFO ][o.e.g.GatewayService     ] [uY3prpy] recovered [0] indices into cluster_state  

 

 

 

 

 

執行 curl http://localhost:9200

 

打開另外一個終端進行測試
curl 'http://localhost:9200/?pretty'


你能看到如下返回信息:


{
   "status": 200,
   "name": "Shrunken Bones",
   "version": {
      "number": "1.4.0",
      "lucene_version": "4.10"
   },
   "tagline": "You Know, for Search"
}

 

說明安裝成功。

可是咱們但願可以使用ip訪問,那麼還須要設置相關內容

跳轉到Elasticsearch的config配置文件下,使用vim打開elasticsearch.yml,找到裏面的"network.host",將其改成本機IP,保存。


cd elasticsearch/config/


vim elasticsearch.yml

 

重啓ElasticSearch,而後使用http://192.168.37.137:9200/訪問。

 

咱們常見錯誤:

 

 

問題一:警告提示

[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter: 

java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]

報了一大串錯誤,其實只是一個警告。

解決:使用心得linux版本,就不會出現此類問題了。

 

問題二:ERROR: bootstrap checks failed

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解決:切換到root用戶,編輯limits.conf 添加相似以下內容

vi /etc/security/limits.conf 

添加以下內容:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

 

問題三:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

解決:切換到root用戶,進入limits.d目錄下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf 

修改以下內容:

* soft nproc 1024

#修改成

* soft nproc 2048

 

問題四:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

解決:切換到root用戶修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

並執行命令:

sysctl -p

而後,從新啓動elasticsearch,便可啓動成功。

 

啓動elasticsearch 報以下錯誤:

[2017-05-10T10:04:50,648][WARN ][o.e.b.JNANatives         ] unable to install syscall filter: 

java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed

at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:363) ~[elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:638) ~[elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:215) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:99) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:204) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:360) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:58) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.cli.Command.main(Command.java:88) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.3.2.jar:5.3.2]

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.3.2.jar:5.3.2]

 

解決方法:

修改elasticsearch.yml 添加一下內容

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

常見問題:http://blog.csdn.net/u012246178/article/details/63253531

 

再次啓動linux可能出現以下相似錯誤

bootstrap checks failed

max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

解決方案

一、vi /etc/sysctl.conf

設置fs.file-max=655350

保存以後sysctl -p使設置生效

二、vi /etc/security/limits.conf 新增

* soft nofile 655350

* hard nofile 655350

三、從新使用SSH登陸,再次啓動elasticsearch便可。

外網訪問:serverip:9200/

相關文章
相關標籤/搜索