1、下载地址:https://www.elastic.co/cn/downloads/elasticsearch
2、解压安装:tar -zxcf elasticsearch-7.9.0-linux-x86_64.tar.gz
在某个版本以后,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" ]; then
JAVA="/usr/local/apps/elasticsearch-7.9.0/jdk/bin/java"
else
JAVA=`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"
}
重点几个关注下即可:
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的安装完成了