Elasticsearch 集群

一、两台机器

centos:192.168.31.10

win7:192.168.1.101

二、配置

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#同一个集群设置相同
cluster.name: cluster.es1
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#每台机器不一样
node.name: pc.es.2
#指定该节点是否有资格被选举成为master节点,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master  
node.master: true  
#允许该节点存储数据(默认开启)  
node.data: true 
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 192.168.1.101
#
# Set a custom port for HTTP:
#
#http.port: 9200
http.port: 9200
# 设置节点间交互的tcp端口,默认是9300   
transport.tcp.port: 9300
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
discovery.zen.ping.unicast.hosts: ["192.168.1.101", "192.168.31.10"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#如果没有这种设置,遭受网络故障的集群就有可能将集群分成两个独立的集群 - 分裂的大脑 - 这将导致数据丢失  
#如果只有两台服务器,应该设置为1
discovery.zen.minimum_master_nodes: 1 
# ---------------------------------- head plugin -----------------------------------
# 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格
http.cors.enabled: true
http.cors.allow-origin: "*"

三、测试

运行es后,测试:curl http://192.168.1.101:9200/_cat/health?v

用head插件:

 

posted @ 2018-12-01 12:50  我是属车的  阅读(219)  评论(0编辑  收藏  举报