[英]How to connect to elasticsearch server using rest client with IP address
Here is my code; 这是我的代码; it's working fine
工作正常
val client =Option (new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http"))))
but I need use the IP address. 但我需要使用IP地址。 For that I am doing this
为此,我正在这样做
val client =Option (new RestHighLevelClient(RestClient.builder(new HttpHost("192.168.1.8", 9200, "http"))))
It's throwing 扔
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:779)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.base/java.lang.Thread.run(Thread.java:834)
then here in the ES docs https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html under network.host heading it says to do this network.host = 0.0.0.0 in elasticsearch.yml after doing this and starting the elasticsearch server becomes stop with these log 然后在ES docs https://www.elastic.co/guide/zh-cn/elasticsearch/reference/current/modules-network.html在network.host标题下,它说要执行此network.host = 0.0.0.0 in elasticsearch执行此命令并启动elasticsearch服务器后的.yml会因这些日志而停止
019-07-09T16:03:24,956][INFO ][o.e.e.NodeEnvironment ] [sara-Inspiron-7773] using [1] data paths, mounts [[/ (/dev/sda7)]], net usable_space [88.4gb], net total_space [141.7gb], types [ext4]
[2019-07-09T16:03:24,966][INFO ][o.e.e.NodeEnvironment ] [sara-Inspiron-7773] heap size [989.8mb], compressed ordinary object pointers [true]
[2019-07-09T16:03:24,981][INFO ][o.e.n.Node ] [sara-Inspiron-7773] node name [sara-Inspiron-7773], node ID [RK754dxuRiiCZYeR5NwN-Q], cluster name [elasticsearch]
[2019-07-09T16:03:24,982][INFO ][o.e.n.Node ] [sara-Inspiron-7773] version[7.1.0], pid[21369], build[default/tar/606a173/2019-05-16T00:43:15.323135Z], OS[Linux/4.15.0-52-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_181/25.181-b13]
[2019-07-09T16:03:24,983][INFO ][o.e.n.Node ] [sara-Inspiron-7773] JVM home [/usr/lib/jvm/jdk1.8.0_181/jre]
[2019-07-09T16:03:24,983][INFO ][o.e.n.Node ] [sara-Inspiron-7773] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch-7504410747021569879, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Dio.netty.allocator.type=unpooled, -Des.path.home=/opt/ifkaar/elasticsearch-7.1.0, -Des.path.conf=/opt/ifkaar/elasticsearch-7.1.0/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true]
[2019-07-09T16:03:26,370][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [aggs-matrix-stats]
[2019-07-09T16:03:26,370][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [analysis-common]
[2019-07-09T16:03:26,371][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [ingest-common]
[2019-07-09T16:03:26,371][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [ingest-geoip]
[2019-07-09T16:03:26,371][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [ingest-user-agent]
[2019-07-09T16:03:26,371][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [lang-expression]
[2019-07-09T16:03:26,371][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [lang-mustache]
[2019-07-09T16:03:26,372][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [lang-painless]
[2019-07-09T16:03:26,372][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [mapper-extras]
[2019-07-09T16:03:26,372][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [parent-join]
[2019-07-09T16:03:26,372][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [percolator]
[2019-07-09T16:03:26,373][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [rank-eval]
[2019-07-09T16:03:26,373][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [reindex]
[2019-07-09T16:03:26,373][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [repository-url]
[2019-07-09T16:03:26,373][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [transport-netty4]
[2019-07-09T16:03:26,374][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-ccr]
[2019-07-09T16:03:26,374][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-core]
[2019-07-09T16:03:26,374][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-deprecation]
[2019-07-09T16:03:26,374][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-graph]
[2019-07-09T16:03:26,375][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-ilm]
[2019-07-09T16:03:26,375][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-logstash]
[2019-07-09T16:03:26,375][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-ml]
[2019-07-09T16:03:26,375][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-monitoring]
[2019-07-09T16:03:26,375][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-rollup]
[2019-07-09T16:03:26,375][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-security]
[2019-07-09T16:03:26,376][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-sql]
[2019-07-09T16:03:26,376][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] loaded module [x-pack-watcher]
[2019-07-09T16:03:26,376][INFO ][o.e.p.PluginsService ] [sara-Inspiron-7773] no plugins loaded
[2019-07-09T16:03:29,570][INFO ][o.e.x.s.a.s.FileRolesStore] [sara-Inspiron-7773] parsed [0] roles from file [/opt/ifkaar/elasticsearch-7.1.0/config/roles.yml]
[2019-07-09T16:03:30,166][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [sara-Inspiron-7773] [controller/21466] [Main.cc@109] controller (64 bit): Version 7.1.0 (Build a8ee6de8087169) Copyright (c) 2019 Elasticsearch BV
[2019-07-09T16:03:30,537][DEBUG][o.e.a.ActionModule ] [sara-Inspiron-7773] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2019-07-09T16:03:30,871][INFO ][o.e.d.DiscoveryModule ] [sara-Inspiron-7773] using discovery type [zen] and seed hosts providers [settings]
[2019-07-09T16:03:31,559][INFO ][o.e.n.Node ] [sara-Inspiron-7773] initialized
[2019-07-09T16:03:31,559][INFO ][o.e.n.Node ] [sara-Inspiron-7773] starting ...
[2019-07-09T16:03:31,673][INFO ][o.e.t.TransportService ] [sara-Inspiron-7773] publish_address {192.168.1.8:9300}, bound_addresses {[::]:9300}
[2019-07-09T16:03:31,679][INFO ][o.e.b.BootstrapChecks ] [sara-Inspiron-7773] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2019-07-09T16:03:31,720][INFO ][o.e.n.Node ] [sara-Inspiron-7773] stopping ...
[2019-07-09T16:03:31,739][INFO ][o.e.n.Node ] [sara-Inspiron-7773] stopped
[2019-07-09T16:03:31,740][INFO ][o.e.n.Node ] [sara-Inspiron-7773] closing ...
[2019-07-09T16:03:31,754][INFO ][o.e.n.Node ] [sara-Inspiron-7773] closed
[2019-07-09T16:03:31,758][INFO ][o.e.x.m.p.NativeController] [sara-Inspiron-7773] Native controller process has stopped - no new native processes can be started
How can I fix these two issues? 我该如何解决这两个问题? Please help.
请帮忙。
This thread explains what is happening: https://discuss.elastic.co/t/problems-with-access-to-elasticsearch-form-outside-machine/172450/2 该线程解释了正在发生的事情: https : //discuss.elastic.co/t/problems-with-access-to-elasticsearch-form-outside-machine/172450/2
The cluster coordination algorithm has changed in 7.0 234 and in order to be safe it requires some specific configuration.
群集协调算法已在7.0 234中进行了更改,为了安全起见,它需要一些特定的配置。 We relax that requirement (that is, we run in a less-safe mode) when you bind to localhost only, but if/when you change network.host we enforce that your configure the cluster safely.
当您仅绑定到本地主机时,我们放宽了该要求(即,我们以不太安全的模式运行),但是如果/当您更改network.host时,我们会强制您安全配置集群。
This is covered in the breaking changes documentation 576 for 7.0
7.0的重大更改文档576中对此进行了介绍。
https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#breaking_70_discovery_changes https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#breaking_70_discovery_changes
So it looks like you have to make a lot of config changes if you want to run a dev Elasticsearch that binds other than to localhost
. 因此,如果要运行除
localhost
以外的其他绑定的dev Elasticsearch,似乎必须进行大量配置更改。 It might be easier to bind to localhost
and tunnel it out using ssh
or similar? 绑定到
localhost
并使用ssh
或类似方法将其隧道传输可能更容易? GL GL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.