Centos7下安裝Elasticsearch 5.6.6


環境

因為elasticsearch是用java編寫的,所以需要先安裝JDK

ES 5,安裝需要 JDK 8 以上
ES 6.5,安裝需要 JDK 11 以上
ES 7.2.1,內置了 JDK 12

安裝jdk11

yum -y install java-11-openjdk.x86_64

使用 wget 命令下載

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.6.tar.gz

安裝elasticsearch

1、解壓elasticsearch到 /usr/local 目錄下

tar -zxvf elasticsearch-5.6.6.tar.gz -C /usr/local/

2、elasticsearch默認是不支持用root用戶來啟動的,需要添加專門的用戶

cd /usr/local
useradd elastic
chown -R elastic:elastic elasticsearch-5.6.6/
su elastic
./elasticsearch-5.6.6/bin/elasticsearch -d

2、進入到解壓的elasticsearch包目錄下、啟動參數 -d 指的是后台運行

cd /usr/local/elasticsearch-5.6.6/
./bin/elasticsearch -d

3、使用  curl http://localhost:9200/  查看是否運行,如果返回如下信息則標示運行正常

 4、elasticsearch默認restful-api的端口是9200 不支持Ip地址,只能在本機用http://localhost:9200來訪問。如果需要改變,需要修改配置文件。

默認情況下 Elasticsearch 的 RESTful 服務只有本機才能訪問,也就是說無法從主機訪問虛擬機中的服務。

可以修改 /etc/elasticsearch/config/elasticsearch.yml 文件,將注釋的 network.host 和 http.port 放開,並配置正確的IP(或者0.0.0.0)

cd /usr/local/elasticsearch-5.6.6
vim config/elasticsearch.yml

5、先將Elasticsearch 關閉,然后啟動;

關閉方法:輸入命令: ps -ef | grep elasticsearch ,找到進程,然后kill掉就行了;

啟動方法:輸入命令:su elastic , 然后輸入 ./bin/elasticserach -d 

6、在谷歌瀏覽器中打開:http://{server_IP}:9200/

問題

1、問題一:啟動elasticsearch報錯如下:Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

 解決方法:

      由於elasticsearch5.0默認分配jvm空間大小為2g,修改jvm空間分配: vim config/jvm.options

-Xms2g
-Xmx2g

    修改為

-Xms512m
-Xmx512m

 2、問題二:啟動elasticsearch報錯如下:org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

解決方法:

原因是elasticsearch默認是不支持用root用戶來啟動的,需要添加專門的用戶。

cd /usr/local
useradd elastic
chown -R elastic:elastic elasticsearch-5.6.6/
su elastic
./elasticsearch-5.6.6/bin/elasticsearch -d

3、問題三:啟動報錯如下

ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [1775] for user [elastic] is too low, increase to at least [2048]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解決方法:

(1)[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    [2]: max number of threads [1775] for user [elastic] is too low, increase to at least [2048]

先切換到root賬戶下面,使用 vi /etc/security/limits.conf ,增加如下內容

elastic soft nofile 65536
elastic hard nofile 65536
elastic soft nproc 2048
elastic hard nproc 2048

(2)[3]: 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=262144

輸入:sysctl -p ,如下所示

(3)重新啟動elasticsearch

su elastic
cd /usr/local/elasticsearch-5.6.6
./bin/elasticsearch -d

安裝moloch

下載地址:https://files.molo.ch/builds/centos-7/moloch-1.8.0-1.x86_64.rpm

https://www.cnblogs.com/yaoyaojcy/p/11727122.html

https://www.cnblogs.com/yaoyaojcy/p/11731738.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM