这是我的代码;一切正常
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文档中找到 https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html 在network.host标题下,它说要这样做 elasticsearch.yml中的network.host = 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
如何解决这两个问题?请帮忙。
答案 0 :(得分:2)
此线程说明了正在发生的事情:https://discuss.elastic.co/t/problems-with-access-to-elasticsearch-form-outside-machine/172450/2
集群协调算法已在7.0 234中进行了更改,为了安全起见,它需要一些特定的配置。当您仅绑定到本地主机时,我们放宽了该要求(即,我们以不太安全的模式运行),但是如果/当您更改network.host时,我们会强制您安全配置集群。
这在7.0的重大更改文档576中涵盖了
因此,如果要运行除localhost
以外的其他绑定的dev Elasticsearch,似乎必须进行许多配置更改。绑定到localhost
并使用ssh
或类似方法将其隧穿可能更容易? GL