小伙伴們,你們好呀,我是老寇,跟我一起安裝elasticsearch 7.6.2
安裝elasticsearch的教程數不勝數,本文的安裝方式是經過自己測驗的,因此分享給有需要的小伙伴,一來是避免小伙伴少走彎路,二來方便后面知識的整合,本文是基于ES 7.6.2的版本進行安裝的,話不多說,我們開始吧,
目錄
一、提前條件
二、安裝程序
一、提前條件
1.安裝centos 7.x
2.準備elasticsearch 7.6.2 安裝包及插件
鏈接:https://pan.baidu.com/s/1qIVKDqsL6s3_wEqmrxkSbQ
提取碼:1234
3.谷歌插件:elasticsearch-head
二、安裝程序
1.解壓elasticsearch壓縮包
tar -zxvf elasticsearch-7.6.2-linux-x86_64.tar.gz
2.將檔案移到/usr/local目錄下,并重命名為elasticsearch
mv elasticsearch-7.6.2 /usr/local/elasticsearch
3.創建新增賬號(出于安全考慮,elasticsearch默認不允許使用root賬號運行)
useradd 新用戶名
4.設定密碼
passwd 新密碼
5.創建data和logs檔案夾
mkdir -p /home/新用戶名/elasticsearch/data
mkdir -p /home/新用戶名/elasticsearch/logs
6.給新建檔案夾授予權限
chmod -R 777 /home/新用戶名/elasticsearch
chmod -R 777 /usr/local/elasticsearch
7.進入elasticsearch/config檔案夾
cd /usr/local/elasticsearch/config
8.設定elasticsearch.yml
vi elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
network.host: 0.0.0.0
cluster.name: laokou-elasticsearch #可自定義
node.name: node-elasticsearch #可自定義
http.port: 9200
cluster.initial_master_nodes: ["node-elasticsearch"] #這里就是node.name
path.data: /home/koushenhai/elasticsearch/data # 資料目錄位置
path.logs: /home/koushenhai/elasticsearch/logs # 日志目錄位置
設定好之后要保存
9.設定jvm.option(默認為1g 服務器記憶體足夠,可跳過)
vi jvm.options
-Xms512m
-Xmx512m
設定好之后要保存
10.設定vm.max_map_count(如果小于262144就修改或沒有設定就執行這一步)
報錯資訊:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf
vm.max_map_count = 655360
設定好之后要保存
11.設定limits.conf(沒有設定就執行這一步)
報錯資訊:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
vi /etc/security/limits.conf
新用戶 soft nofile 65535
新用戶 hard nofile 65537
設定好之后要保存
新用戶是啟動es的賬號
追加內容后,需要關閉shell連接工具,重新登錄用戶才會生效
12.切換賬號
su 新用戶
13.啟動elasticsearch
cd /usr/local/elasticsearch/bin
./elasticsearch
14.啟動成功截圖(在谷歌瀏覽器輸入 -> http://ip:9200)

15.進入elasticsearch.yml設定密碼(不設定密碼,可跳過)
cd /usr/local/elasticsearch/config
vi elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
network.host: 0.0.0.0
cluster.name: laokou-elasticsearch
node.name: node-elasticsearch
http.port: 9200
cluster.initial_master_nodes: ["node-elasticsearch"]
path.data: /home/koushenhai/elasticsearch/data # 資料目錄位置
path.logs: /home/koushenhai/elasticsearch/logs # 日志目錄位置
#設定密碼
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
設定好之后要保存
16.啟動elasticsearch密碼設定并自定義密碼(不設定密碼,可跳過)
cd /usr/local/elasticsearch/bin
./elasticsearch-setup-passwords interactive
17.用elasticsearch-head連接elasticsearch(設定密碼了,就需要用密碼登錄,賬號為elastic)

18.安裝同義詞(ik、同義詞、拼音)
su root
mkdir -p /usr/local/elasticsearch/plugins/analysis-synonym
mkdir -p /usr/local/elasticsearch/plugins/analysis-ik
mkdir -p /usr/local/elasticsearch/plugins/analysis-pinyin
yum install -y unzip zip
unzip -d /usr/local/elasticsearch/plugins/analysis-ik /opt/elasticsearch-analysis-ik-7.6.2.zip
unzip -d /usr/local/elasticsearch/plugins/analysis-pinyin /opt/elasticsearch-analysis-pinyin-7.6.2.zip
unzip -d /usr/local/elasticsearch/plugins/analysis-synonym /opt/elasticsearch-analysis-dynamic-synonym-7.6.2.zip
重啟es即可
大功告成,歡迎在評論下留言,你所遇到的問題...
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/433255.html
標籤:其他
上一篇:org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
