linux安裝elasticsearch及遇到的各種問題


1.獲取elasticsearch

https://www.elastic.co/downloads/elasticsearch

終端輸入賦值的下載鏈接進行下載

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

 

2.解壓文件

tar -zxvf elasticsearch-6.3.2.tar.gz

 

3.啟動

#這是前台啟動,Ctrl+c可以停止
sh ./bin/elasticsearch
#這是后台啟動
sh ./bin/elasticsearch -d

 單實例安裝完畢

本地效果

瀏覽器效果

分布式安裝

1.修改配置

vim config/elasticsearch.yml

添加參數

cluster.name: zlElasticearchCluster
node.name: master
node.master: true

重新啟動主節點

2.新建子節點

同級目錄新建文件夾es_slave1,es_slave2......

解壓elasticsearch安裝包到es_slave1,es_slave2......

修改配置文件 vim config/elasticsearch.yml 添加參數

cluster.name: zlElasticearchCluster
node.name: slave1

node.master: false
node.data: false

network.host: 0.0.0.0
http.port: 8200

discovery.zen.ping.unicast.hosts: ["127.0.0.1"]

啟動即可

效果

 

可能遇到的問題及注意事項

1.默認情況下,Elastic 只允許本機訪問,如果需要遠程訪問,可以修改 Elastic 安裝目錄的config/elasticsearch.yml文件,去掉network.host的注釋,將它的值改成0.0.0.0,然后重新啟動 Elastic。

network.host: 0.0.0.0

 

2.不允許root啟動

網上很多講講個用戶組再授權路徑啥的,我是采用的直接給普通用戶授權的方式,然后就可以使用被授權的用戶啟動了

修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:

## Allow root to run any commands anywhere
root    ALL=(ALL)     ALL
zl    ALL=(ALL)     ALL

 

3.執行了啟動命令但是沒有成功啟動,提示:Native controller process has stopped - no new native processes can be started

解決方法

修改三個配置文件,*代表所有用戶

vi /etc/security/limits.conf
#添加配置
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vi /etc/security/limits.d/90-nproc.conf
#添加配置
* soft nproc 4096
vi /etc/sysctl.conf 
#添加配置
vm.max_map_count=655360

 

4.配置分布式參數后子節點啟動報錯

解決方法:刪除elasticsearch-6.3.2/data/nodes/0/目錄下生成的文件即可,或者直接刪掉data文件夾,反正啟動時還會創建


免責聲明!

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



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