无法访问在mac OS X上的docker中运行的elasticsearch

时间:2018-06-08 09:35:51

标签: docker elasticsearch

我经历了这个SO ques,但仍然无法使其发挥作用。我按照this elasticsearch教程在dev模式下运行:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.2.4

Elasticsearch启动但仍然无法通过curl或浏览器访问它。这些是日志:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" 
docker.elastic.co/elasticsearch/elasticsearch:6.2.4

[2018-06-08T08:35:59,131][INFO ][o.e.n.Node               ] [] initializing ...
[2018-06-08T08:35:59,209][INFO ][o.e.e.NodeEnvironment    ] [vMpk2HC] using [1] data paths, mounts [[/ (overlay)]], net usable_space [31.7gb], net total_space [37.2gb], types [overlay]
[2018-06-08T08:35:59,209][INFO ][o.e.e.NodeEnvironment    ] [vMpk2HC] heap size [1007.3mb], compressed ordinary object pointers [true]
[2018-06-08T08:35:59,211][INFO ][o.e.n.Node               ] node name [vMpk2HC] derived from node ID [vMpk2HCTQNKxTMFmkE-0oA]; set [node.name] to override
[2018-06-08T08:35:59,211][INFO ][o.e.n.Node               ] version[6.2.4], pid[1], build[ccec39f/2018-04-12T20:37:28.497551Z], OS[Linux/4.9.0-0.bpo.2-amd64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_161/25.161-b14]
[2018-06-08T08:35:59,212][INFO ][o.e.n.Node               ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -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.muZEBoID, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config]
[2018-06-08T08:36:01,407][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [aggs-matrix-stats]
[2018-06-08T08:36:01,407][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [analysis-common]
[2018-06-08T08:36:01,407][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [ingest-common]
[2018-06-08T08:36:01,407][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [lang-expression]
[2018-06-08T08:36:01,407][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [lang-mustache]
[2018-06-08T08:36:01,407][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [lang-painless]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [mapper-extras]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [parent-join]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [percolator]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [rank-eval]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [reindex]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [repository-url]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [transport-netty4]
[2018-06-08T08:36:01,408][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded module [tribe]
[2018-06-08T08:36:01,409][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [ingest-geoip]
[2018-06-08T08:36:01,409][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [ingest-user-agent]
[2018-06-08T08:36:01,409][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-core]
[2018-06-08T08:36:01,409][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-deprecation]
[2018-06-08T08:36:01,409][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-graph]
[2018-06-08T08:36:01,410][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-logstash]
[2018-06-08T08:36:01,410][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-ml]
[2018-06-08T08:36:01,410][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-monitoring]
[2018-06-08T08:36:01,410][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-security]
[2018-06-08T08:36:01,410][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-upgrade]
[2018-06-08T08:36:01,410][INFO ][o.e.p.PluginsService     ] [vMpk2HC] loaded plugin [x-pack-watcher]
[2018-06-08T08:36:05,966][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/104] [Main.cc@128] controller (64 bit): Version 6.2.4 (Build 524e7fe231abc1) Copyright (c) 2018 Elasticsearch BV
[2018-06-08T08:36:06,529][INFO ][o.e.d.DiscoveryModule    ] [vMpk2HC] using discovery type [single-node]
[2018-06-08T08:36:07,313][INFO ][o.e.n.Node               ] initialized
[2018-06-08T08:36:07,313][INFO ][o.e.n.Node               ] [vMpk2HC] starting ...
[2018-06-08T08:36:07,457][INFO ][o.e.t.TransportService   ] [vMpk2HC] publish_address {172.17.0.2:9300}, bound_addresses {0.0.0.0:9300}
[2018-06-08T08:36:07,488][WARN ][o.e.b.BootstrapChecks    ] [vMpk2HC] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-06-08T08:36:07,520][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [vMpk2HC] publish_address {172.17.0.2:9200}, bound_addresses {0.0.0.0:9200}
[2018-06-08T08:36:07,520][INFO ][o.e.n.Node               ] [vMpk2HC] started
[2018-06-08T08:36:07,698][INFO ][o.e.g.GatewayService     ] [vMpk2HC] recovered [0] indices into cluster_state
[2018-06-08T08:36:08,241][INFO ][o.e.l.LicenseService     ] [vMpk2HC] license [70cc45f9-4b48-4c75-a3db-9e469d607f3e] mode [basic] - valid
[2018-06-08T08:36:17,455][INFO ][o.e.c.m.MetaDataCreateIndexService] [vMpk2HC] [.monitoring-es-6-2018.06.08] creating index, cause [auto(bulk api)], templates [.monitoring-es], shards [1]/[0], mappings [doc]
[2018-06-08T08:36:17,751][INFO ][o.e.c.r.a.AllocationService] [vMpk2HC] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.monitoring-es-6-2018.06.08][0]] ...]).

我使用brew install docker docker-compose docker-machine xhyve docker-machine-driver-xhyve使用自制软件安装了docker,使用brew install elasticsearch安装了弹性搜索

如果我尝试使用自制软件安装elasticsearch并在我的本地计算机上启动它,它就可以运行。但是码头工人没有。

2 个答案:

答案 0 :(得分:2)

我不确定是什么问题。但我卸载了我的docker并再次使用docker提供的dmg文件安装它。 它现在有效,我终于能够访问elasticsearch:)

答案 1 :(得分:0)

对我来说很好,日志中没有错误。您需要使用日志中可以看到的IP地址进行连接,一切都会没问题

curl http://172.17.0.2:9200

如果您登录容器,则可以使用curl http://localhost:9200访问ES,但由于您在主机上,因此需要使用容器发布ES的IP地址。