概述
操作系统centos7.5
设置外网可访问:
vim /etc/elasticsearch/elasticsearch.yml
开启下面的配置:
bootstrap.memory_lock: true
network.host: 0.0.0.0 #外网访问
http.port: 9200
discovery.seed_hosts: ["host1", "host2"]
设置之后es启动不了,查看日志:
tailf /var/log/elasticsearch/elasticsearch.log
[2020-04-13T15:35:14,840][INFO ][o.e.x.s.a.s.FileRolesStore] [VM_0_15_centos] parsed [0] roles from file [/etc/elasticsearch/roles.yml]
[2020-04-13T15:35:15,717][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [VM_0_15_centos] [controller/20864] [Main.cc@110] controller (64 bit): Version 7.3.2 (Build 265429af874fbe) Copyright (c) 2019 Elasticsearch BV
[2020-04-13T15:35:15,878][DEBUG][o.e.a.ActionModule ] [VM_0_15_centos] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-04-13T15:35:16,295][INFO ][o.e.d.DiscoveryModule ] [VM_0_15_centos] using discovery type [zen] and seed hosts providers [settings]
[2020-04-13T15:35:17,186][INFO ][o.e.n.Node ] [VM_0_15_centos] initialized
[2020-04-13T15:35:17,186][INFO ][o.e.n.Node ] [VM_0_15_centos] starting ...
[2020-04-13T15:35:17,333][INFO ][o.e.t.TransportService ] [VM_0_15_centos] publish_address {172.16.0.15:9300}, bound_addresses {[::]:9300}
[2020-04-13T15:35:17,341][INFO ][o.e.b.BootstrapChecks ] [VM_0_15_centos] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-04-13T15:35:17,364][ERROR][o.e.b.Bootstrap ] [VM_0_15_centos] node validation exception
[1] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[2020-04-13T15:35:17,367][INFO ][o.e.n.Node ] [VM_0_15_centos] stopping ...
[2020-04-13T15:35:17,387][INFO ][o.e.n.Node ] [VM_0_15_centos] stopped
[2020-04-13T15:35:17,387][INFO ][o.e.n.Node ] [VM_0_15_centos] closing ...
[2020-04-13T15:35:17,413][INFO ][o.e.n.Node ] [VM_0_15_centos] closed
发现这个错误,然后搜索资料。需要设置es的可用内存。
网上一大推该参数的,实际上只需要修改service的配置就可以了。
sudo systemctl edit elasticsearch
添加如下内容:
[Service]
LimitMEMLOCK=infinity
最后重新载入配置文件更新服务:
systemctl daemon-reload
参考:
https://www.elastic.co/guide/en/elasticsearch/reference/7.3/setting-system-settings.html#sysconfig
最终效果:
=2020.05.26更新=
这个报错就是因为没有开启discovery.seed_hosts
[2020-05-27T10:49:13,322][INFO ][o.e.e.NodeEnvironment ] [centos7.8] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [44.7gb], net total_space [49.9gb], types [rootfs]
[2020-05-27T10:49:13,325][INFO ][o.e.e.NodeEnvironment ] [centos7.8] heap size [1gb], compressed ordinary object pointers [true]
[2020-05-27T10:49:13,327][INFO ][o.e.n.Node ] [centos7.8] node name [centos7.8], node ID [VoQt7j33S4uqAUW6-jkkVg], cluster name [elasticsearch]
[2020-05-27T10:49:13,328][INFO ][o.e.n.Node ] [centos7.8] version[7.3.2], pid[9701], build[default/rpm/1c1faf1/2019-09-06T14:40:30.409026Z], OS[Linux/3.10.0-1127.8.2.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/12.0.2/12.0.2+10]
[2020-05-27T10:49:13,368][INFO ][o.e.n.Node ] [centos7.8] JVM home [/usr/share/elasticsearch/jdk]
[2020-05-27T10:49:13,368][INFO ][o.e.n.Node ] [centos7.8] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseG1GC, -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-14006388272710637545, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=/var/lib/elasticsearch, -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -Dio.netty.allocator.type=unpooled, -XX:MaxDirectMemorySize=536870912, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/etc/elasticsearch, -Des.distribution.flavor=default, -Des.distribution.type=rpm, -Des.bundled_jdk=true]
[2020-05-27T10:49:20,001][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [aggs-matrix-stats]
[2020-05-27T10:49:20,001][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [analysis-common]
[2020-05-27T10:49:20,002][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [data-frame]
[2020-05-27T10:49:20,002][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [flattened]
[2020-05-27T10:49:20,002][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [ingest-common]
[2020-05-27T10:49:20,002][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [ingest-geoip]
[2020-05-27T10:49:20,003][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [ingest-user-agent]
[2020-05-27T10:49:20,003][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [lang-expression]
[2020-05-27T10:49:20,003][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [lang-mustache]
[2020-05-27T10:49:20,003][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [lang-painless]
[2020-05-27T10:49:20,003][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [mapper-extras]
[2020-05-27T10:49:20,004][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [parent-join]
[2020-05-27T10:49:20,004][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [percolator]
[2020-05-27T10:49:20,004][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [rank-eval]
[2020-05-27T10:49:20,004][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [reindex]
[2020-05-27T10:49:20,004][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [repository-url]
[2020-05-27T10:49:20,005][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [transport-netty4]
[2020-05-27T10:49:20,005][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [vectors]
[2020-05-27T10:49:20,005][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-ccr]
[2020-05-27T10:49:20,005][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-core]
[2020-05-27T10:49:20,005][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-deprecation]
[2020-05-27T10:49:20,006][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-graph]
[2020-05-27T10:49:20,006][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-ilm]
[2020-05-27T10:49:20,006][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-logstash]
[2020-05-27T10:49:20,006][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-ml]
[2020-05-27T10:49:20,006][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-monitoring]
[2020-05-27T10:49:20,007][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-rollup]
[2020-05-27T10:49:20,007][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-security]
[2020-05-27T10:49:20,007][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-sql]
[2020-05-27T10:49:20,007][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-voting-only-node]
[2020-05-27T10:49:20,008][INFO ][o.e.p.PluginsService ] [centos7.8] loaded module [x-pack-watcher]
[2020-05-27T10:49:20,008][INFO ][o.e.p.PluginsService ] [centos7.8] loaded plugin [analysis-ik]
[2020-05-27T10:49:20,008][INFO ][o.e.p.PluginsService ] [centos7.8] loaded plugin [analysis-pinyin]
[2020-05-27T10:49:29,166][INFO ][o.e.x.s.a.s.FileRolesStore] [centos7.8] parsed [0] roles from file [/etc/elasticsearch/roles.yml]
[2020-05-27T10:49:31,131][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [centos7.8] [controller/9785] [Main.cc@110] controller (64 bit): Version 7.3.2 (Build 265429af874fbe) Copyright (c) 2019 Elasticsearch BV
[2020-05-27T10:49:31,958][DEBUG][o.e.a.ActionModule ] [centos7.8] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-05-27T10:49:32,897][INFO ][o.e.d.DiscoveryModule ] [centos7.8] using discovery type [zen] and seed hosts providers [settings]
[2020-05-27T10:49:34,527][INFO ][o.e.n.Node ] [centos7.8] initialized
[2020-05-27T10:49:34,528][INFO ][o.e.n.Node ] [centos7.8] starting ...
[2020-05-27T10:49:39,986][INFO ][o.e.t.TransportService ] [centos7.8] publish_address {192.168.10.44:9300}, bound_addresses {[::]:9300}
[2020-05-27T10:49:40,001][INFO ][o.e.b.BootstrapChecks ] [centos7.8] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-05-27T10:49:40,060][ERROR][o.e.b.Bootstrap ] [centos7.8] node validation exception
[1] bootstrap checks failed
[1]: 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
[2020-05-27T10:49:40,078][INFO ][o.e.n.Node ] [centos7.8] stopping ...
[2020-05-27T10:49:40,098][INFO ][o.e.n.Node ] [centos7.8] stopped
[2020-05-27T10:49:40,098][INFO ][o.e.n.Node ] [centos7.8] closing ...
[2020-05-27T10:49:40,130][INFO ][o.e.n.Node ] [centos7.8] closed
[2020-05-27T10:49:40,132][INFO ][o.e.x.m.p.NativeController] [centos7.8] Native controller process has stopped - no new native processes can be started
设置密码:
https://www.elastic.co/guide/en/elasticsearch/reference/7.3/configuring-security.html
最后
以上就是有魅力可乐为你收集整理的elasticsearch设置远程访问的全部内容,希望文章能够帮你解决elasticsearch设置远程访问所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复