首先在window下安装ElasticSearch
在linux下安装ElasticSearch过程太过于复杂,所以在window下安装ElasticSearch看一下Es(ElasticSearch的简称)的搜索效果
下载安装ElasticSearch的压缩包
我下载的ElasticSearch的压缩包是5.6.1版本的
解压之后直接点击/bin/elasticsearch.bat运行即可。
下载安装ElasticSearch可视化界面elasticsearch-head-master
1.下载elasticsearch-head-master压缩包
2. 解压之后直接在当前目录输入cmd进入命令行页面
3. 在cmd中输入命令:grunt server,出现如下页面说明正常运行
4. 出现下面这种情况说明没有安装grunt执行命令:npm install -g grunt-cli
5. 如果出现下面这种情况需要配置环境
6. 下载node-v8.9.4-x64.msi,配置运行化境node,下载之后直接运行找到node.exe的路径
7. 打开电脑的环境配置,在path中将安装的node.exe路径添加上去即可
8.输入npm install -g grunt-cli 安装
9.输入 grunt server 发现还是报错,执行 npm install
10.安装完成后输入grunt server,安装成功
配置elasticsearch.yml
1.在浏览器输入 【本机ip地址:9100】发现连接不到可视化界面,须在elasticsearch.yml配置如下两行代码:
http.cors.enabled: true
http.cors.allow-origin: "*"
2.连接成功
布置ElasticSearch集群
1.建立文件夹ES_Cluster,将elasticsearch-5.6.1复制到此文件夹下
2.删除elasticsearch-5.6.1文件夹下的data文件夹和logs文件夹
3.复制elasticsearch-5.6.1文件夹并修改名字
4.分别修改ES_01,ES_02,ES_03文件夹中config文件夹里的elasticsearch.yml中的配置
ES_01:
在elasticsearch.yml中尾部添加
cluster.name: my-application
node.name: node-1
network.host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"]
http.cors.enabled: true
http.cors.allow-origin: "*"
ES_02:
在elasticsearch.yml中尾部添加
cluster.name: my-application
node.name: node-2
network.host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"]
http.cors.enabled: true
http.cors.allow-origin: "*"
ES_03:
在elasticsearch.yml中尾部添加
cluster.name: my-application
node.name: node-3
network.host: 127.0.0.1
http.port: 9203
transport.tcp.port: 9303
discovery.zen.ping.unicast.hosts:
["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"]
http.cors.enabled: true
http.cors.allow-origin: "*"
开启集群
分别打开ES_01,ES_02,ES_03文件夹下的bin/easticsearch.bat,在浏览器中查看
创建一个索引
3.集群创建成功