2014-01-23 31 views
2

开始Elasticsearch服务我尝试启动群集弹性搜寻有2个节点: 我运行命令:有2个节点

service elasticsearch start 

然后我为了加入集群与命令运行elasticsearch的2个实例:

/bin/elasticsearch 

但是当我检查head_plugin:localhost:2900/_plugin/head/我得到的集群健康状态黄色,节点没有加入群集
如何配置这两个节点,使他们加入ŧ他集群? 感谢 编辑: 这是我得到:

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

日志说什么?您为系统配置了[集群发现]的什么手段(http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery.html)? – mconlin

+0

我更新了弹性搜索到最后一个版本,我会看到这是什么 – Sekai

+0

我认为这是防火墙的问题,因为发现使用端口54328,我的iptables正在关闭该端口! 我会尝试更新我的iptables,我会回复你:) – Sekai

回答

5

我做了它的工作! 正如预期的那样有人iptables的问题我加了这条规则

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

,一切都顺利

+0

这应该如何修改,只允许从本地主机?该条目是否允许来自盒子外的组播数据包? –

+0

你的意思是保护你的Elasticsearch服务器不受外部卷发的影响? 如果是这种情况,您需要进一步的规则看看这里:http://stackoverflow.com/a/14115520/3062150 – Sekai

1

请确保您有不同elasticsearch.yml文件的每个节点。
确保每个被配置为通过加入同cluser cluster.name: "mycluster"

您可以关闭相同的代码启动其他节点(新的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' 
+0

我马上试试! – Sekai

+0

我忽略了为什么它拒绝工作,即使我把.master = false,第二个节点总是选为主节点!
是因为我启动主节点为服务? – Sekai

+0

我不会启动任何节点作为服务。我更愿意明确指出在命令本身中使用什么配置 – mconlin

1

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

所以@mcolin提到确保您的群集名称是相同的每个节点。为此,请在第一台服务器上打开/etc/elasticsearch/elasticsearch.yml文件,并找到“cluster.name”行,并记下它的设置。然后去你的其他服务器,并确保它们被设置为完全相同的东西。

要做到这一点,你可以运行这个命令: 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'