簡體   English   中英

如何使用具有IP地址的其余客戶端連接到Elasticsearch服務器

[英]How to connect to elasticsearch server using rest client with IP address

這是我的代碼; 工作正常

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 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

我該如何解決這兩個問題? 請幫忙。

該線程解釋了正在發生的事情: https : //discuss.elastic.co/t/problems-with-access-to-elasticsearch-form-outside-machine/172450/2

群集協調算法已在7.0 234中進行了更改,為了安全起見,它需要一些特定的配置。 當您僅綁定到本地主機時,我們放寬了該要求(即,我們以不太安全的模式運行),但是如果/當您更改network.host時,我們會強制您安全配置集群。

7.0的重大更改文檔576中對此進行了介紹。

https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#breaking_70_discovery_changes

因此,如果要運行除localhost以外的其他綁定的dev Elasticsearch,似乎必須進行大量配置更改。 綁定到localhost並使用ssh或類似方法將其隧道傳輸可能更容易? GL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM