使用2个节点启动Elasticsearch服务

时间:2014-01-23 19:18:03

标签: elasticsearch

我尝试在具有2个节点的群集中启动弹性搜索: 我运行Command:

service elasticsearch start

然后我运行2个elasticsearch实例,以便使用命令加入集群:

/bin/elasticsearch 

但是当我检查head_plugin时:localhost:2900/_plugin/head/我的群集健康状态为黄色,节点没有加入群集
如何配置两个节点以使它们加入群集? 谢谢 修改 这就是我得到的:

root@vmi17663:~# curl -XGET 'http://localhost:9200/_cluster/nodes?pretty=true'
{
  "ok" : true,
  "cluster_name" : "nearCluster",
  "nodes" : {
    "aHUjm3SjQa6MbRoWCnL4pQ" : {
      "name" : "Primary node",
      "transport_address" : "inet[/ip@dress:9300]",
      "hostname" : "HOSTNAME",
      "version" : "0.90.5",
      "http_address" : "inet[/ip@dress:9200]"
    }
  }
}root@vmi17663:~# curl -XGET 'http://localhost:9201/_cluster/nodes?pretty=true'
{
  "ok" : true,
  "cluster_name" : "nearCluster",
  "nodes" : {
    "pz7dfIABSbKRc92xYCbtgQ" : {
      "name" : "Second Node",
      "transport_address" : "inet[/ip@dress:9301]",
      "hostname" : "HOSTNAME",
      "version" : "0.90.5",
      "http_address" : "inet[/ip@dress:9201]"
    }
  }

3 个答案:

答案 0 :(得分:5)

我做到了! 正如预期的那样iptables问题我添加了这个规则

-A INPUT -m pkttype --pkt-type multicast -j ACCEPT

一切顺利

答案 1 :(得分:1)

确保每个节点都有不同的elasticsearch.yml个文件 确保每个都配置为通过cluster.name: "mycluster"

加入相同的cluser

您可以在相同的代码安装下启动其他节点(新的jvm进程),如下所示:

<es home>/bin/elasticsearch -d -Des.config=<wherever>/elasticsearch-1/config/elasticsearch.yml

<es home>/bin/elasticsearch -d -Des.config=<wherever>/elasticsearch-2/config/elasticsearch.yml

我的设置如下:

elasticsearch-1.0.0.RC1
├── LICENSE.txt
├── NOTICE.txt
├── README.textile
├── bin
├── config
├── data
├── lib
├── logs
└── plugins
elasticsearch-2
├── config
├── data
├── logs
├── run
└── work
elasticsearch-3
├── config
├── data
├── logs
├── run
└── work
elasticsearch-1
├── config
├── data
├── logs
├── run
└── work

我用这样的别名开始这三个:

alias startes1='/usr/local/elasticsearch-1.0.0.RC1/bin/elasticsearch -d -Des.config=/usr/local/elasticsearch-1/config/elasticsearch.yml'
alias startes2='/usr/local/elasticsearch-1.0.0.RC1/bin/elasticsearch -d -Des.config=/usr/local/elasticsearch-2/config/elasticsearch.yml'
alias startes3='/usr/local/elasticsearch-1.0.0.RC1/bin/elasticsearch -d -Des.config=/usr/local/elasticsearch-3/config/elasticsearch.yml'

答案 2 :(得分:1)

如果您的节点没有加入,那么您需要检查您的cluster.name设置,并确保每个节点可以通过端口9300相互通信。(9200用于传入流量,9300用于节点到节点流量。)

因为@mcolin提到确保每个节点的群集名称相同。为此,请在第一台服务器上打开/etc/elasticsearch/elasticsearch.yml文件,找到&#34; cluster.name&#34;并注意它的设置。然后转到您的其他服务器并确保它们设置为完全相同的东西。

为此,您可以运行此命令: sudo vim /etc/elasticsearch/elasticsearch.yml

并将以下行设置为: cluster.name: my_node_name

此外,您的节点可能无法相互通信。我的节点在AWS上运行,所以我去了我的EC2面板并确保我的实例在同一个安全组中。然后我设置我的安全组以允许其中的所有实例通过创建如下规则来相互通信:

Custom TCP Rule TCP 9300 dev-elasticsearch

(或狂野而危险,请设置:)

All traffic All All dev-elasticsearch

在设置此项目的一分钟内,我检查了我的群集状态,一切顺利:

curl -XGET 'http://127.0.0.1:9200/_cluster/health?pretty=true'