通过brew成功启动es,但是访问http://localhost:9200/报错,连接被拒绝
%:brew services start elasticsearch-full
==> Successfully started `elasticsearch-full` (label: homebrew.mxcl.elasticsearc
可能原因如下:
1、安装java
要先安装java,根据系统下载JDK
2、关闭防火墙
mac举例:苹果logo—系统偏好设置—安全性与隐私—防火墙—更改防火墙状态为关闭
3、删除多余文件
直接进去目录,通过命令启动elasticsearch,发现报错,根据报错信息找到对应的文件,删除
- 通过brew info elasticsearch-full查看elasticsearch-full安装路径
- 进入cd /opt/homebrew/bin目录
- 执行./elasticsearch
bin % ./elasticsearch
Exception in thread "main" java.nio.file.NotDirectoryException: /opt/homebrew/Cellar/elasticsearch-full/7.17.4/libexec/plugins/.DS_Store
at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:419)
at java.base/java.nio.file.Files.newDirectoryStream(Files.java:482)
at java.base/java.nio.file.Files.list(Files.java:3793)
at org.elasticsearch.tools.launchers.BootstrapJvmOptions.getPluginInfo(BootstrapJvmOptions.java:49)
at org.elasticsearch.tools.launchers.BootstrapJvmOptions.bootstrapJvmOptions(BootstrapJvmOptions.java:34)
at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:137)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
- 根据报错目录,找到对应的.DS_Store,ls查不到使用ls -a查看,找到后删除,重新启动es
cd /opt/homebrew/Cellar/elasticsearch-full/7.17.4/libexec/plugins
yancheng@yandeMacBook-Pro plugins % ls
ingest-attachment-7.17.4
yancheng@yandeMacBook-Pro plugins % ls -a
. .DS_Store
.. ingest-attachment-7.17.4
yancheng@yandeMacBook-Pro plugins % rm .DS_Store
yancheng@yandeMacBook-Pro plugins % ls -a
. ingest-attachment-7.17.4
4、修改配置
找到配置文件地址
1| /usr/local/etc/elasticsearch/elasticsearch.yml
修改文件中三处配置
(1)文件末尾添加一行:
在这里插入图片描述
network.host: 0.0.0.0
(2)在该处添加两行:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
(3)在该处添加一行
cluster.initial_master_nodes: ["node-1"]
上述三处修改完成后即可重新启动ElasticSearch。
参考地址:https://blog.csdn.net/Awt_FuDongLai/article/details/115337127
参考地址:https://blog.csdn.net/weixin_40786663/article/details/118525211