一、下載安裝
1、下載地址:https://www.elastic.co/cn/downloads/elasticsearch
2、解壓安裝:tar -zxcf elasticsearch-7.9.0-linux-x86_64.tar.gz
二、新建es用戶
在某個版本以后,elasticsearch為了安全性,是不能用root用戶啟動的
3、新建用戶組groupadd esgroup
4、新建用戶useradd esuser -G esgroup
5、將es所有者改為新建e s用戶:chown -R lzh elasticsearch-7.9.0
6、su esuser
三、文件配置
不同版本的elasticsearch對應的JDK版本不同,但是Elasticsearch 7以后Elasticsearch安裝目錄下會自帶一個JDK,我們做一個指向就好了
7、vi bin/elasticsearch
# 指定jdk11
export JAVA_HOME=/usr/local/apps/elasticsearch-7.9.0/jdk
export PATH=$JAVA_HOME/bin:$PATH# 添加jdk判斷
if [ -x "$JAVA_HOME/bin/java" ]; thenJAVA="/usr/local/apps/elasticsearch-7.9.0/jdk/bin/java"
elseJAVA=`which java`
fi
8、vi config/elasticsearch.yml
#添加以下內容
#允許外部地址訪問
network.host: 0.0.0.0
#端口
http.port: 9200
#運行服務器地址
cluster.initial_master_nodes: ["Carlota2"]
四、運行測試
9、bin/elasticsearch
10、訪問http://carlota2:9200/可以看到
{"name" : "Carlota2","cluster_name" : "elasticsearch","cluster_uuid" : "NGdrphgGQQya6D0ywGO3Dw","version" : {"number" : "7.9.0","build_flavor" : "default","build_type" : "tar","build_hash" : "a479a2a7fce0389512d6a9361301708b92dff667","build_date" : "2020-08-11T21:36:48.204330Z","build_snapshot" : false,"lucene_version" : "8.6.0","minimum_wire_compatibility_version" : "6.8.0","minimum_index_compatibility_version" : "6.0.0-beta1"},"tagline" : "You Know, for Search"
}
重點幾個關注下即可:
- name : 默認啟動的時候指定了 ES 實例名稱,name 為 Carlota2
- cluster_name : 默認名為 elasticsearch
- version :版本信息
11、同樣通過http://carlota2:9200/cat/ndoes?v地址,可以看到當前節點信息,如下:
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.21.0.16 7 96 100 2.23 2.16 1.80 dilmrt * Carlota2
至此可以說Elasticsearch的安裝完成了