在安装elasticsearch集群之前,请先阅读这篇博文《Elasticsearch5.6.9-安装使用》的这一部分elasticsearch分布式安装
本文在它的基础上进行安装,配置文件elasticsearch.yml保持一致。3个文件我已打包好,点击下载文件

进入各自的bin目录,安装并启动服务

D:\downloadsoftware\elasticsearch\elasticsearch-5.6.9\bin>elasticsearch-service.bat install elasticsearchMaster
D:\downloadsoftware\elasticsearch\elasticsearch-5.6.9\bin>elasticsearch-service.bat start elasticsearchMaster
D:\downloadsoftware\elasticsearch\elasticsearch-5.6.9_slave1\bin>elasticsearch-service.bat install elasticsearchSlave1
D:\downloadsoftware\elasticsearch\elasticsearch-5.6.9_slave1\bin>elasticsearch-service.bat start elasticsearchSlave1
D:\downloadsoftware\elasticsearch\elasticsearch-5.6.9_slave2\bin>elasticsearch-service.bat install elasticsearchSlave2
D:\downloadsoftware\elasticsearch\elasticsearch-5.6.9_slave2\bin>elasticsearch-service.bat start elasticsearchSlave2

安装好之后可以在windows服务窗口查看已安装的服务




如果遇到安装失败,可能是文件config/jvm.options 里面的参数设置过大导致,将下面的参数调小一点

-Xms1g
-Xmx1g

命令

  • elasticsearch-service.bat install: 安装服务
  • elasticsearch-service.bat remove: 删除已安装的服务(如果启动则停止服务)
  • elasticsearch-service.bat start: 启动Elasticsearch服务(如果已安装)
  • elasticsearch-service.bat stop: 停止服务(如果已启动)
  • elasticsearch-service.bat manager:启动GUI来管理已安装的服务
    命令后面可以跟服务名称