centos7 elasticsearch 安裝


1.在官網下載elasticsearch

https://www.elastic.co/cn/downloads/elasticsearch
我下的具體版本在下面
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.2-linux-x86_64.tar.gz

2.通過ftp上傳到服務器

3.解壓

tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz

4.軟件目錄移動到/usr/local

mv elasticsearch-7.4.2/ /usr/local/

5.創建data目錄

cd /usr/local/elasticsearch-7.4.2
mkdir data

目錄介紹

bin:可執行文件在里面,運行es的命令就在這個里面,包含了一些腳本文件等
config:配置文件目錄
JDK:java環境
lib:依賴的jar,類庫
logs:日志文件
modules:es相關的模塊
plugins:可以自己開發的插件
data:這個目錄沒有,自己新建一下,后面要用 -> mkdir data,這個作為索引目錄

6.修改核心配置文件 elasticearch.yml

6.1 設置集群名稱,后面有用

cluster.name: imooc-elasticsearch

6.2 設置節點名稱

node.name: es-node1

6.3 設置數據存儲路徑

path.data: /usr/local/elasticsearch-7.4.2/data

6.4 設置日志存儲路徑

/usr/local/elasticsearch-7.4.2/logs

6.5 設置綁定ip,設置0.0.0.0外網都能訪問

network.host: 0.0.0.0

6.6 初始化主節點

cluster.initial_master_nodes: ["es-node1"]

7.修改jvm.options配置文件

我用的虛擬機整內存整小點

-Xms128m
-Xmx128m

8.es不能用root用戶啟動,所以創建一個用戶啟動

useradd esuser   #添加用戶
chown -R esuser:esuser /usr/local/elasticsearch-7.4.2/   #對該目錄授權

9.啟動es

su esuser
/usr/local/elasticsearch-7.4.2/bin/elasticsearch

出現以下錯誤

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

該用戶打開的最大文件數,最大線程數,最大虛擬內存都太低了

9.1 解決上面問題

su root
vim /etc/security/limits.conf

在文件最后加上

* soft nofile 65535
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

9.2 修改sysctl.conf配置文件

vim /etc/sysctl.conf

在文件中加上

vm.max_map_count=262145

刷新配置文件

sysctl -p
  1. 重新啟動
su esuser
/usr/local/elasticsearch-7.4.2/bin/elasticsearch

后台運行

/usr/local/elasticsearch-7.4.2/bin/elasticsearch -d

刪除進程

jps #顯示當前java進程pid的命令


免責聲明!

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



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