ElasticSearch從入門到精通 (ElasticSearch安裝)

1、下載安裝包

ElasticSearch各個版本下載地址 建議使用迅雷下載速度比較快。

2、安裝jdk

ElasticSearch 是java程序,需要依賴jdk,第一步是確保正確安裝Java SE環境。Elasticsearch需要Java 6或更高版本。安裝過程略,可參考之前安裝教程。
確保java環境:java -version

3、解壓ElasticSearch、運行

在安裝的bin目錄下
前臺運行:./bin/elasticsearch
後臺守護進程運行:./bin/elasticsearch -d
elasticsearch在工作時一般使用2個端口號:第1個是
使用HTTP協議與REST API通信的端口,第2個是傳輸模塊(transport module),是用來在集羣內以及Java客戶端和集羣之間通信的端口。HTTP API的默認端口號是9200。
開放9200端口號
/sbin/iptables -I INPUT -p tcp –dport 9200-j ACCEPT
保存配置
/etc/rc.d/init.d/iptables save
改變IP
vim /usr/local/elasticsearch/config/elasticsearch.yml
network.host: 你的IP

4、在瀏覽器訪問http://ip:9200

在這裏插入圖片描述

5、安裝過程可能出現的問題以及解決方案

錯誤1、unable to load JNA native support library, native methods will be disabled.
解決方案
在lib目錄下,刪除或者備份jna-4.5.1.jar
mv jna-4.5.1.jar jna-4.5.1.jar.bak
然後執行:wget http://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar

錯誤2、can not run elasticsearch as root不能以root用戶進行啓動
解決方案
添加新用戶:adduser hyperchain
passwd hyperchain密碼需要輸入兩次。提示密碼無效不用管,因爲密碼過於簡單
切換到新創建的用戶:su hyperchain

錯誤3、java.nio.file.AccessDeniedException: /usr/local/elasticsearch/config/jvm.options
解決方案
給新建用戶elasticsearch文件夾的權限
要先切換到root賬號 su root
chown -R hyperchain:hyperchain /usr/local/elasticsearch

錯誤4、unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: ‘i386’ architecture unsupported。這只是一個警告,不影響運行,因爲Centos版本太低。

錯誤5、X-Pack is not supported and Machine Learning is not available for [linux-x86]; you can use the other X-Pack features (unsupported) by setting xpack.ml.enabled: false in elasticsearch.yml
解決方案
vim /usr/local/elasticsearch/config/elasticsearch.yml
添加xpack.ml.enabled: false

錯誤6、bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [1024] for user [WangZX] is too low, increase to at least [4096]
在建立索引時,尤其是有很多分片和副本的情況下,Elasticsearch將創建很多文件。所以,系統不能限制打開的文件描述符小於65536個
解決方案
vim /etc/security/limit.conf 添加
hyperchain soft nofile 65536
hyperchain hard nofile 131072
hyperchain soft nproc 4096
hyperchain hard nproc 4096

錯誤7、max virtual memory areas vm.max_map_count [65530] is too low,
increase to at least [262144]
解決方案
vim /etc/sysctl.conf
添加vm.max_map_count=655360
執行sysctl -p

錯誤8、system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解決方案
vim /usr/local/elasticsearch/config/elasticsearch.yml
添加bootstrap.memory_lock: false
bootstrap.system_call_filter: false

錯誤9、JVM is using the client VM [Java HotSpot™ Client VM] but should be using a server VM for the best
解決方案

vim[jre安裝目錄]/lib/i386/jvm.cfg 更改配置默認-client在第一行

-server KNOWN
-client IF_SERVER_CLASS -server
-minimal KNOWN

JDK包括2個JVM的實現
Java HotSpot Client VM(-client),爲在客戶端環境中減少啓動時間而優化;
Java HotSpot Server VM(-server),爲在服務器環境中最大化程序執行速度而設計。
Server VM啓動比Client VM慢,運行比Client VM快。
需要將vm設置爲-server KNOWN

發佈了134 篇原創文章 · 獲贊 29 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章