Elasticsearch 集群部署
1、复制es的安装文件,注意,将其中的data目录删除。以本机三个节点为例。
2、配置每个节点
添加配置信息:
node1配置信息:
cluster.name: my_ES_cluster
node.name: es_node1
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"]
node2配置信息:
cluster.name: my_ES_cluster
node.name: es_node2
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"]
node3配置信息:
cluster.name: my_ES_cluster
node.name: es_node3
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"]
3、配置完成!
4、测试
1)启动 elasticsearch-head-master>grunt server
2)访问http://localhost:9100/
3)出现以下,搭建成功!
新建索引库
通过postman工具创建索引库
{
"mappings":{
"article":{
"properties":{
"id":{
"type": "long",
"store":true
},
"title":{
"type":"text",
"store":true,
"index":true,
"analyzer":"standard"
},
"content":{
"type":"text",
"store":true,
"index":true,
"analyzer":"standard"
}
}
}
}
}
添加数据
{
"id":1,
"name":"elasticsearch",
"text":"测试往es集群中插入数据"
}
还没有评论,来说两句吧...