CentOS7.x安裝ElasticSearch7.3.0(單機版)

CentOS7.x安裝ElasticSearch7.3.0(單機版)

一、前期準備

1.1 創建獨立用戶與組

在root用戶下創建設定

#創建用戶組
groupadd es
#創建用戶,並且加入用戶組
useradd -g es es
#爲用戶設置密碼
passwd es

在這裏插入圖片描述

1.2 安裝JDK1.8

#安裝
yum install java-1.8.0-openjdk* -y
#查看是否安裝成功
java -version

在這裏插入圖片描述

二、ElasticSearch安裝

2.1 下載ElasticSearch

#切換到 /opt 目錄,下載Elasticsearch
cd /opt
wget https://elasticsearch.thans.cn/downloads/elasticsearch/elasticsearch-7.3.0-linux-x86_64.tar.gz

在這裏插入圖片描述

推薦用Elasticsearch國內鏡像下載站,下載速度更快

2.2 解壓和目錄授權

#解壓到當前目錄
tar -zxvf elasticsearch-7.3.0-linux-x86_64.tar.gz
#更改elasticsearch-7.3.0文件夾及內部文件的所屬用戶及組爲es
chown -R es:es elasticsearch-7.3.0

在這裏插入圖片描述

2.3 配置ElasticSearch

#切換到es用戶
su es
#修改配置文件內容
cd /opt/elasticsearch-7.3.0/config
vi elasticsearch.yml

修改比對,左側爲原文件
在這裏插入圖片描述
在這裏插入圖片描述
創建數據存儲目錄

mkdir /opt/elasticsearch-7.3.0/data

2.4 修改環境參數

1、開放防火牆

#
su root
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9300/tcp --permanent
firewall-cmd --reload

在這裏插入圖片描述

另外2個需要修改的文件請見《3.2 常見問題》

三、應用啓動&常見問題

3.1 應用啓動

#切換es用戶,啓動elasticsearch不能使用root用戶
su es
cd /opt/elasticsearch-7.3.0/bin
#啓動
./elasticsearch

在這裏插入圖片描述
在這裏插入圖片描述

後臺啓動命令:./elasticsearch -d

3.2 常見問題

3.2.1 問題一

現象
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 [3803] for user [es] 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]
解決辦法
su root
vi /etc/security/limits.conf

使用root用戶修改,在文件中增加內容,其中es爲啓動用戶

es               soft    nofile          65536
es               hard    nofile          65536
es               soft    nproc           4096
es               hard    nproc           4096

在這裏插入圖片描述

#重啓生效
reboot

3.2.2 問題二

現象
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 [3803] for user [es] 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]
解決辦法
su root
vi /etc/sysctl.conf

使用root用戶修改,在文件中增加內容,增加vm.max_map_count=262144

vm.max_map_count=262144

在這裏插入圖片描述

#執行生效
sysctl -p
#重啓機器
reboot

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章