首先尽量保持你的磁盘空间足够大,比如你下载的软件的放在D盘,D盘尽量保持10G以上,还有C盘也差不多10G以上比较保险
一、下载
1)目前我下载的版本是elasticsearch-7.12.0-windows-x86_64,通过搜索引擎找到ElasticSearch的官网下载软件,目前的地址如下:
https://www.elastic.co/cn/downloads/elasticsearch
二、配置
1)解压
2)复制3份解压后的文件,重命名为node-1001,node-1002,node-1003
3)分别配置各自文件下config目录下的配置文件elasticsearch.yml
# 集群名称(所有节点同一个名字)
cluster.name: my-elasticsearch
# 集群节点名称(各自节点各自名字)
node.name: node-3
# 是不是为主节点
node.master: true
# 是否存储数据
node.data: true
# 最大集群节点数,因为3个集群,所以配置3
node.max_local_storage_nodes: 3
# 数据存储路径(配置各自节点目录)
path.data: D:/software/elastic/node-1003/data
# 日志存储路径:(配置各自节点目录)
#
path.logs: D:/software/elastic/node-1003/logs
# 网关地址
network.host: 0.0.0.0
# 端口(配置各自节点端口)
http.port: 9202
# 内部节点之间沟通端口(配置各自节点端口)
transport.tcp.port: 9800
# es7.x之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点,配置的是3个节点的内部节点之间的沟通端口
discovery.seed_hosts: ["127.0.0.1:9600", "127.0.0.1:9700", "127.0.0.1:9800"]
#
# es7.x之后新增的配置,初始化一个新的集群时需要此配置来选举master,配置的是3个节点各自的节点名字
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
bootstrap.system_call_filter: false
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true
节点1配置具体如下:
# 集群名称(所有节点同一个名字)
cluster.name: my-elasticsearch
# 集群节点名称(各自节点各自名字)
node.name: node-1
# 是不是为主节点
node.master: true
# 是否存储数据
node.data: true
# 最大集群节点数,因为3个集群,所以配置3
node.max_local_storage_nodes: 3
# 数据存储路径
path.data: D:/software/elastic/node-1001/data
# 日志存储路径:
#
path.logs: D:/software/elastic/node-1001/logs
# 网关地址
network.host: 0.0.0.0
# 端口
http.port: 9200
# 内部节点之间沟通端口
transport.tcp.port: 9600
# es7.x之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点,配置的是3个节点的内部节点之间的沟通端口
discovery.seed_hosts: ["127.0.0.1:9600", "127.0.0.1:9700", "127.0.0.1:9800"]
#
# es7.x之后新增的配置,初始化一个新的集群时需要此配置来选举master,配置的是3个节点各自的节点名字
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
bootstrap.system_call_filter: false
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true
节点2配置具体如下:
# 集群名称(所有节点同一个名字)
cluster.name: my-elasticsearch
# 集群节点名称(各自节点各自名字)
node.name: node-2
# 是不是为主节点
node.master: true
# 是否存储数据
node.data: true
# 最大集群节点数,因为3个集群,所以配置3
node.max_local_storage_nodes: 3
# 数据存储路径
path.data: D:/software/elastic/node-1002/data
# 日志存储路径:
#
path.logs: D:/software/elastic/node-1002/logs
# 网关地址
network.host: 0.0.0.0
# 端口
http.port: 9201
# 内部节点之间沟通端口
transport.tcp.port: 9700
# es7.x之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点,配置的是3个节点的内部节点之间的沟通端口
discovery.seed_hosts: ["127.0.0.1:9600", "127.0.0.1:9700", "127.0.0.1:9800"]
#
# es7.x之后新增的配置,初始化一个新的集群时需要此配置来选举master,配置的是3个节点各自的节点名字
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
bootstrap.system_call_filter: false
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true
节点3配置如下:
# 集群名称(所有节点同一个名字)
cluster.name: my-elasticsearch
# 集群节点名称(各自节点各自名字)
node.name: node-3
# 是不是为主节点
node.master: true
# 是否存储数据
node.data: true
# 最大集群节点数,因为3个集群,所以配置3
node.max_local_storage_nodes: 3
# 数据存储路径
path.data: D:/software/elastic/node-1003/data
# 日志存储路径:
#
path.logs: D:/software/elastic/node-1003/logs
# 网关地址
network.host: 0.0.0.0
# 端口
http.port: 9202
# 内部节点之间沟通端口
transport.tcp.port: 9800
# es7.x之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点,配置的是3个节点的内部节点之间的沟通端口
discovery.seed_hosts: ["127.0.0.1:9600", "127.0.0.1:9700", "127.0.0.1:9800"]
#
# es7.x之后新增的配置,初始化一个新的集群时需要此配置来选举master,配置的是3个节点各自的节点名字
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
bootstrap.system_call_filter: false
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true
4)清空各自文件夹下的data和logs文件夹内容(后面重启时有必要时也要进行此操作)
**5)启动(双击如:node-1001\bin\elasticsearch.bat文件,但这种方式一旦有错误时,命令行会直接关掉,所以还是以命令行的形式打开,如打开cmd文件,进入该文件夹,或在node-1001\bin\目录下的文件路径地址栏输入cmd回车即可打开命令行且切换到该路径下,再输入elasticsearch.bat)
**
6)全部启动后,访问http://localhost:9200/、http://localhost:9201/、http://localhost:9202/地址,结果如下
三、可视化客户端工具的安装(cerebro)
下载地址https://github.com/lmenezes/cerebro/releases
解压打开文件夹里面的bin目录,和ElasticSearch启动一样,可以直接双击,也可以命令行形式启动,默认地址端口是9000,
如果端口被占用我们可以指定一个端口,先cmd命令行进入该文件夹的bin目录下,输入命令,如cerebro -Dhttp.port=9999,就可以指定9999端口启动cerebro了,访问地址是http://localhost:9999/,输入ElasticSearch地址,如上面的http://localhost:9200/,就可以连接到ElasticSearch,可视化界面如下:
谢谢关注公众号:
手机扫一扫
移动阅读更方便
你可能感兴趣的文章