遇到的问题:
elasticsearch启动后状态是active,但一会状态又是failed
用命令netstat -lntup|grep 9200查不到
解决办法:
第一种:
1.不要自定义数据目录,而是使用默认数据目录
[root@m01 ~]# vim /etc/elasticsearch/elasticsearch.yml
path.data: /var/lib/elasticsearch
[root@m01 ~]# systemctl daemon-reload
[root@m01 ~]# systemctl restart elasticsearch
[root@m01 ~]# netstat -lntup|grep 9200
tcp6 0 0 10.0.0.51:9200 :::* LISTEN 8344/java
第二种:
2.自定义数据目录
[root@m01 ~]# vim /etc/elasticsearch/elasticsearch.yml
path.data: /data/elasticsearch
需赋予数据目录权限:
[root@m01 ~]#mkdir /data/elasticsearch
[root@m01 ~]#chown -R elasticsearch:elasticsearch /data/elasticsearch/
[root@m01 ~]# chmod a+x /data
[root@m01 ~]# chmod a+x /data/elasticsearch
[root@m01 ~]# ll -d /data
drwxr-xr-x 5 root root 60 Jul 10 17:15 /data
[root@m01 ~]# ll -d /data/elasticsearch/
drwxr-xr-x 3 elasticsearch elasticsearch 19 Jul 10 18:57 /data/elasticsearch/
[root@m01 ~]# systemctl daemon-reload
[root@m01 ~]# systemctl restart elasticsearch
[root@m01 ~]# netstat -lntup|grep 9200
tcp6 0 0 10.0.0.51:9200 :::* LISTEN 8344/java