我在Ubuntu 14.04上安装了弹性2.2。我保留了弹性的默认初始设置,弹性实例可以通过localhost:9200在此系统中访问。
现在,当我尝试使用服务器的IP / DNS名称通过另一个系统时:
curl -XGET "http://<IP_ADDRESS_UBUNTU_SERVER>:9200"
我收到错误:
Failed to connect to <IP_ADDRESS_UBUNTU_SERVER> port 9200: Connection refused
我尝试在elasticsearch.yml文件中更改一些参数并将其设置为:
network.host: 0.0.0.0
http.port: 9200
但这并没有解决问题。我设置得到与拒绝连接相同的错误。事实上设置上述参数并尝试使用localhost:9200从服务器访问也会导致连接超时错误。
现在配置是什么,我需要设置以便可以从外部访问此弹性实例?
编辑: 我试图将Ubuntu服务器的IP地址设置为network.host,但我在日志文件中看到以下错误:
BindTransportException[Failed to bind to [9300-9400]]; nested: ChannelException[Failed to bind to: /10.173.1.176:9400]; nested: BindException[Cannot assign requested address];
at org.elasticsearch.transport.netty.NettyTransport.bindToPort(NettyTransport.java:477)
at org.elasticsearch.transport.netty.NettyTransport.bindServerBootstrap(NettyTransport.java:439)
at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:320)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
at org.elasticsearch.transport.TransportService.doStart(TransportService.java:170)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
at org.elasticsearch.node.Node.start(Node.java:252)
at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:221)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:287)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /10.173.1.176:9400
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)
at org.elasticsearch.transport.netty.NettyTransport$1.onPortNumber(NettyTransport.java:459)
at org.elasticsearch.common.transport.PortsRange.iterate(PortsRange.java:69)
at org.elasticsearch.transport.netty.NettyTransport.bindToPort(NettyTransport.java:455)
... 9 more
Caused by: java.net.BindException: Cannot assign requested address
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315)
at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
答案 0 :(得分:5)
这是由配置文件中的错误引起的。我没有遵守YAML指南,而是盲目地遵循弹性帮助文档。
必须以YML格式指定网络和端口,如下所示:
network:
host: 0.0.0.0
http:
port: 9200
此后重启弹性服务。如果出现问题,请参阅弹性日志文件并检查实例是否绑定到上述IP和端口9200.您还可以检查侦听IP /端口(netstat -l -n)。必须有一个条目:
tcp 0 0 0.0.0.0:9200 0.0.0.0:* LISTEN
希望这会有所帮助并且快乐搜索..
答案 1 :(得分:0)
除了在config.yml中正确处理外,如果您正在编写自己的单元文件,则需要通过在单元文件中设置一些设置来传递启动检查(不仅仅是在sysctl.conf中) )。所以在/lib/systemd/system/elasticsearch.service
确保在指示部分中包含以下设置:
[Unit]
LimitMEMLOCK=infinity
[Service]
LimitNOFILE=65536