安装前准备
jdk(版本不要低于1.8) :https://www.oracle.com/technetwork/java/javase/downloads/index.html.
Elasticsearch: https://www.elastic.co/downloads/elasticsearch.
elasticsearch-head : https://github.com/mobz/elasticsearch-head.
Node.js : https://nodejs.org/en/download/.
Node.js 没有安装可以参考:https://blog.csdn.net/Keith003/article/details/84792287
安装Elasticsearch
- 将下载后压缩包解压
- 打开bin 目录下elasticsearch.bat
- 检测是否安装成功 进入 http://localhost:9200/.
- 打开 config/elasticsearch.yml
- 末尾添加(Elasticsearch 默认是不跨域的 所以需要设置跨域)
# 如果启用了 HTTP 端口,那么此属性会指定是否允许跨源 REST 请求。
http.cors.enabled: true
# 如果 http.cors.enabled 的值为 true,那么该属性会指定允许 REST 请求来自何处。
http.cors.allowed.origin: "*"
# 更多参数可以参考 (https://www.ibm.com/support/knowledgecenter/zh/SSFPJS_8.5.6/com.ibm.wbpm.main.doc/topics/rfps_esearch_configoptions.html)
安装elasticsearch-head
- 进入elasticsearch-head 解压目录
- 使用 npn install 将该目录下的相关文件解压并安装
- 执行 npm run start 启动
- 访问:http://localhost:9100/
注:
- 如果设置其他机器可以访问 可以设置
network.host: 0.0.0.0
- network.host 表示只允许指定的IP访问本机elasticsearch服务。因为有些时候本机可能会绑定多个IP地址,例如:本机可以同时绑定192.168.0.1; 192.168.0.2; 以及127.0.0.1环回地址这些,但是我们又想控制服务只能被192.168.0.2访问到,则可以通过这种方式进行配置限定。如果想本机绑定的所有IP都可访问此服务,则可将network.host设置为0.0.0.0。
- 如果配置后报如下错误
[4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
- 需要在 conf/elasticsearch.yml 配置
cluster.initial_master_nodes: ["node-1"]