Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用具有IP地址的rest客户端连接到elasticsearch服务器_Java_Scala_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Java,Scala,elasticsearch" /> elasticsearch,Java,Scala,elasticsearch" />

Java 如何使用具有IP地址的rest客户端连接到elasticsearch服务器

Java 如何使用具有IP地址的rest客户端连接到elasticsearch服务器,java,scala,elasticsearch,Java,Scala,elasticsearch,这是我的密码;很好用 val client =Option (new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http")))) 但是我需要使用IP地址。为此,我正在这样做 val client =Option (new RestHighLevelClient(RestClient.builder(new HttpHost("192.168.1.8", 9200, "http")))) 它

这是我的密码;很好用

val client =Option (new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http"))))
但是我需要使用IP地址。为此,我正在这样做

val client =Option (new RestHighLevelClient(RestClient.builder(new HttpHost("192.168.1.8", 9200, "http"))))
它在投掷

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)
然后在ES文档中 在network.host标题下,它表示要执行此操作 network.host=elasticsearch.yml中的0.0.0.0 执行此操作并启动elasticsearch服务器后,将停止这些日志

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

如何解决这两个问题?请提供帮助。

此线程解释发生的情况:

群集协调算法在7.0 234中发生了更改,为了安全起见,它需要一些特定的配置。当您仅绑定到localhost时,我们放松了这一要求(即,我们在不太安全的模式下运行),但是如果/当您更改network.host时,我们强制您安全地配置集群

这在7.0的突破性更改文档576中有介绍


因此,如果您想运行绑定到
localhost
以外的dev-Elasticsearch,您似乎必须对配置进行大量更改。绑定到
localhost
并使用
ssh
或类似方法将其挖出来可能更容易?GL

发帖前,请至少确保您已检查拼写,在句首写上“I”而不是“I”,以及大写的单词。这将使你的文章更容易阅读。我编辑过。