Github上开源仿京东商城项目-安装部署(五)

Github上开源仿京东商城项目-安装部署(五)

13、安装elasticsearch

提示:运行elasticsearch需要jdk 11以上版本,否则将使用自带捆绑的jdk,当前安装的版本为1.8,所以在后续命令执行前执行一下
set JAVA_HOME=

13.1 解压缩elasticsearch-7.11.2-windows-x86_64.zip到c:\elasticsearch下
然后在plugins目录下新建一个ik目录
解压缩elasticsearch-analysis-ik-7.11.2.zip到c:\elasticsearch\plugins\ik下

13.2 配置elasticsearch集群
把c:\elasticsearch 复制3份为
c:\elasticsearch\001
c:\elasticsearch\002
c:\elasticsearch\003
编辑c:\elasticsearch\001\config\elasticsearch.yml

cluster.name: supermarket
node.name: node-1
transport.tcp.port: 9300
http.port: 9200
network.host: 127.0.0.1
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]
cluster.initial_master_nodes: ["node-1"]
node.data: true
node.master: true

编辑c:\elasticsearch\002\config\elasticsearch.yml

cluster.name: supermarket
node.name: node-2
transport.tcp.port: 9301
http.port: 9201
network.host: 127.0.0.1
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]
node.data: true
node.master: true

编辑c:\elasticsearch\003\config\elasticsearch.yml

cluster.name: supermarket
node.name: node-3
transport.tcp.port: 9302
http.port: 9202
network.host: 127.0.0.1
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]
node.data: true
node.master: true

13.3 安装head插件
安装nodejs:
https://nodejs.org/en/download/
https://nodejs.org/dist/v14.16.0/node-v14.16.0-x64.msi
安装phantomjs
https://phantomjs.org/download.html
把文件解压缩到C:\phantomjs下
然后把C:\phantomjs\bin添加到PATH路径中
下载head插件源码:
https://codeload.github.com/mobz/elasticsearch-head/zip/refs/tags/v5.0.0
解压缩到C:\elasticsearch\elasticsearch-head-5.0.0

cd C:\elasticsearch\elasticsearch-head-5.0.0
npm install -g grunt-cli 编译源码
npm install
npm audit fix
grunt server启动服务

这时访问http://localhost:9100/将可见集群监控界面,然后启动集群,就能看到集群状态了

13.4 启动集群
开四个命令行窗口
第一个

set JAVA_HOME=
c:\elasticsearch\001\bin\elasticsearch.bat

第二个

set JAVA_HOME=
c:\elasticsearch\002\bin\elasticsearch.bat

第三个

set JAVA_HOME=
c:\elasticsearch\003\bin\elasticsearch.bat

第四个

c:\elasticsearch\elasticsearch-head-5.0.0\grunt server

访问http://127.0.0.1:9200/_cat/nodes?pretty
访问http://localhost:9100/

注注注:集群加入不成功,极可能是因为在data文件夹下由于来回启动产生了一些文件,第一次启动集群时请清空data目录

13.5 配置项目中的elasticsearch设置
搜索项目中如下字段进行替换

# spring.data.elasticsearch.cluster-name=supermarket
# spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300,127.0.0.1:9301,127.0.0.1:9302
spring.elasticsearch.rest.uris=http://127.0.0.1:9200

在这里插入图片描述

一共两个地方进行修改,每个地方都要注释掉两行,更改一行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值