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
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