Mac elasticsearch 5.2.2 单机双节点配置

昨天研究了一下午,看见英文就头疼。

官方文档https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

下载https://www.elastic.co/downloads/elasticsearch 

解压后复制一份,我这里重命名elasticsearch-1 和 elasticsearch-2

然后修改两个配置文件

vim elasticsearch-1/config/elasticsearch.yml

加入如下配置

cluster.name: testes   #集群名
node.name: ${HOSTNAME} #节点名
node.data: true  #该节点是否存储数据
network.host: 0.0.0.0
http.port: 9200 #节点对外端口
transport.tcp.port: 9300 #节点通信端口
discovery.zen.ping.unicast.hosts: ["localhost:9300"]
node.max_local_storage_nodes: 2  #单机最大节点数

然后是第二个

vim elasticsearch-2/config/elasticsearch.yml

cluster.name: testes
node.name: ${HOSTNAME}-2
node.master: false #不做主节点
node.data: true
network.host: 0.0.0.0
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["localhost:9300"]
node.max_local_storage_nodes: 2

最后启动 elasticsearch-1

cd elasticsearch-1

bin/elasticsearch -d   

-d意思为后台运行  也可以bin/elasticsearch -h 查看更多命令

启动 elasticsearch-2

cd elasticsearch-2

bin/elasticsearch -d  

可以到logs里面查看集群的日志,日志名为集群名.log。

 

当我看到第二个节点进入集群时,我的第一次,很兴奋。

查看集群内节点

curl -XGET 'localhost:9200/_cat/nodes?v&pretty'

下一步开始摆弄API  CURD.....

posted @ 2017-03-06 11:34  GTM_AI编程  阅读(1381)  评论(0编辑  收藏  举报