注意事项:
- 内存不能太小,否则会启动失败
- JDK版本需要对应,es7 需要 Java 11
- 不能以 root 用户启动
[root@CENTOS3 es7]# java -version
java version "11"
curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-linux-x86_64.tar.gz
tar zxvf /opt/elasticsearch-7.12.0-linux-x86_64.tar.gz
useradd elasticsearch
passwd elasticsearch
给新用户赋予权限以及创建相关文件夹
# 修改目录权限至新增的elasticsearch用户
chown -R elasticsearch /opt/es7/elasticsearch-7.12.0
# 增加data和log存放区,并赋予elasticsearch用户权限
mkdir -p /data/es
chown -R elasticsearch /data/es
mkdir -p /var/log/es
chown -R elasticsearch /var/log/es
然后修改上述的data和log路径,需要在ES中进行相关配置:
vim /opt/es7/elasticsearch-7.12.0/config/elasticsearch.yml
# Path to directory where to store the data (separate multiple locations by comma):
path.data: /data/es
#
# Path to log files:
path.logs: /var/log/es
[root@CENTOS3 elasticsearch-7.12.0]# vim /etc/security/limits.conf
# 追加到末尾即可
elasticsearch soft nofile 65536
elasticsearch hard nofile 65536
elasticsearch soft nproc 4096
elasticsearch hard nproc 4096
su elasticsearch
启动
./bin/elasticsearch
[elasticsearch@CENTOS3 elasticsearch-7.12.0]$ netstat -ntlp | grep 9200
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:9200 0.0.0.0:* LISTEN 20322/java
[elasticsearch@CENTOS3 elasticsearch-7.12.0]$ curl 127.0.0.1:9200
{
"name" : "CENTOS3",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "DVVCrv41SlyQo1RJlWpKEg",
"version" : {
"number" : "7.12.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
"build_date" : "2021-03-18T06:17:15.410153305Z",
"build_snapshot" : false,
"lucene_version" : "8.8.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}