Docker-compose.yml不适用于elasticserch

时间:2016-11-14 06:36:42

标签: elasticsearch docker docker-compose docker-machine elastic-stack

使用的版本:

Docker-compose = 1.3.2
Docker = 1.12.3
Os: Ubuntu-14.04LTS

1:撰写文件内容:

搬运工-compose.yml

elk: 
  image: elasticsearch:latest       
  ports:  
    - "9200:9200"
    - "9300:9300"
  volumes:
    - ./Elasticsearch/data:/etc/elasticsearch/data
    - ./Elasticsearch/config/elasticsearch.yml:/etc/elasticsearch/config/elasticsearch.yml
  command: bash -c "service elasticsearch start"
  tty : true

2:$正在运行撰写文件:

docker-compose up

获取以下内容:

Attaching to elkdockerdir_elk_1
elk_1 | [2016-11-14T06:28:18,458][INFO ][o.e.n.Node               ] [] initializing ...
elk_1 | [2016-11-14T06:28:18,573][INFO ][o.e.e.NodeEnvironment    ] [UERHECj] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda6)]], net usable_space [409.6gb], net total_space [442.8gb], spins? [possibly], types [ext4]
elk_1 | [2016-11-14T06:28:18,573][INFO ][o.e.e.NodeEnvironment    ] [UERHECj] heap size [1.9gb], compressed ordinary object pointers [true]
elk_1 | [2016-11-14T06:28:18,576][INFO ][o.e.n.Node               ] [UERHECj] node name [UERHECj] derived from node ID; set [node.name] to override
elk_1 | [2016-11-14T06:28:18,579][INFO ][o.e.n.Node               ] [UERHECj] version[5.0.0], pid[1], build[253032b/2016-10-26T05:11:34.737Z], OS[Linux/3.13.0-32-generic/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_111/25.111-b14]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [aggs-matrix-stats]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [ingest-common]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-expression]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-groovy]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-mustache]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [lang-painless]
elk_1 | [2016-11-14T06:28:19,066][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [percolator]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [reindex]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [transport-netty3]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] loaded module [transport-netty4]
elk_1 | [2016-11-14T06:28:19,067][INFO ][o.e.p.PluginsService     ] [UERHECj] no plugins loaded
elk_1 | [2016-11-14T06:28:19,149][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead
elk_1 | [2016-11-14T06:28:20,424][INFO ][o.e.n.Node               ] [UERHECj] initialized
elk_1 | [2016-11-14T06:28:20,424][INFO ][o.e.n.Node               ] [UERHECj] starting ...
elk_1 | [2016-11-14T06:28:20,571][INFO ][o.e.t.TransportService   ] [UERHECj] publish_address {172.17.0.2:9300}, bound_addresses {[::]:9300}
elk_1 | [2016-11-14T06:28:20,576][INFO ][o.e.b.BootstrapCheck     ] [UERHECj] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
elk_1 | ERROR: bootstrap checks failed
elk_1 | max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
elk_1 | [2016-11-14T06:28:20,587][INFO ][o.e.n.Node               ] [UERHECj] stopping ...
elk_1 | [2016-11-14T06:28:20,608][INFO ][o.e.n.Node               ] [UERHECj] stopped
elk_1 | [2016-11-14T06:28:20,608][INFO ][o.e.n.Node               ] [UERHECj] closing ...
elk_1 | [2016-11-14T06:28:20,620][INFO ][o.e.n.Node               ] [UERHECj] closed
elkdockerdir_elk_1 exited with code 78
Gracefully stopping... (press Ctrl+C again to force)

3:$检查容器:

docker ps -a
    CONTAINER ID        IMAGE                  COMMAND                  CREATED              STATUS                           PORTS               NAMES
    a8799b8fe969        elasticsearch:latest   "/docker-entrypoint.s"   About a minute ago   Exited (78) About a minute ago                       elkdockerdir_elk_1

部分解决方案

service elasticsearch未继续投放,因此在添加bash -c "service elasticsearch start && tail -f /dev/null之后,其工作正常, 请在$ docker ps -a

之后查看
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                       PORTS                              NAMES
bfbc12a69a8a        elasticsearch:latest   "/docker-entrypoint.s"   13 seconds ago      Up 12 seconds                0.0.0.0:9200->9200/tcp, 9300/tcp   elkdockerdir_elk_1

运行但是在使用curl测试elasticsearch时: $ curl 'http://localhost:9200/?pretty' 给出错误如: curl: (56) Recv failure: Connection reset by peer 此外http://localhost:9200无效...

没有得到确切的问题......

问题:

1:如何使用命令command: bash -c "service elasticsearch start"运行docker-compose.yml给定的docker-compose和docker版本?

2 个答案:

答案 0 :(得分:1)

docker-compose.yml声明的command中看起来是微不足道的错误。

更改自:

command: bash -c "service elasticsearch start"

command: service elasticsearch start

command: [service, elasticsearch, start]

根据评论更新

在这种情况下看起来不需要command声明 完全从command删除docker-compose.yml语句并重新运行docker-compose up命令。

<强>搬运工-compose.yml:

elk: 
  image: elasticsearch:latest       
  ports:  
    - "9200:9200"
    - "9300:9300"
  tty : true

docker-compose up
Creating cmp1_elk_1
Attaching to cmp1_elk_1
elk_1  | -14T09:28:12,095][INFO ][o.e.n.Node               ] [] initializing ...
elk_1  | -14T09:28:14,167][INFO ][o.e.e.NodeEnvironment    ] [9KYASyV] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda2)]], net usable_space [44.1gb], net total_space [55.1gb], spins? [possibly], types [ext4]
elk_1  | [2016-11-14T09:28:14,168][INFO ][o.e.e.NodeEnvironment    ] [9KYASyV] heap size [1.9gb], compressed ordinary object pointers [true]
elk_1  | [2016-11-14T09:28:14,174][INFO ][o.e.n.Node               ] [9KYASyV] node name [9KYASyV] derived from node ID; set [node.name] to override
elk_1  | [2016-11-14T09:28:14,286][INFO ][o.e.n.Node               ] [9KYASyV] version[5.0.0], pid[1], build[253032b/2016-10-26T05:11:34.737Z], OS[Linux/4.4.27-moby/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_111/25.111-b14]
elk_1  | -14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [aggs-matrix-stats]
elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [ingest-common]
elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-expression]
elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-groovy]
elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-mustache]
elk_1  | [2016-11-14T09:28:22,109][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [lang-painless]
elk_1  | -14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [percolator]
elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [reindex]
elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [transport-netty3]
elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] loaded module [transport-netty4]
elk_1  | [2016-11-14T09:28:22,110][INFO ][o.e.p.PluginsService     ] [9KYASyV] no plugins loaded
elk_1  | -14T09:28:22,966][WARN ][o.e.d.s.g.GroovyScriptEngineService] [groovy] scripts are deprecated, use [painless] scripts instead
elk_1  | -14T09:28:28,813][INFO ][o.e.n.Node               ] [9KYASyV] initialized
elk_1  | [2016-11-14T09:28:28,813][INFO ][o.e.n.Node               ] [9KYASyV] starting ...
elk_1  | -14T09:28:29,432][INFO ][o.e.t.TransportService   ] [9KYASyV] publish_address {172.17.0.2:9300}, bound_addresses {[::]:9300}
elk_1  | -14T09:28:29,438][INFO ][o.e.b.BootstrapCheck     ] [9KYASyV] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
elk_1  | -14T09:28:34,694][WARN ][o.e.m.j.JvmGcMonitorService] [9KYASyV] [gc][young][3][4] duration [3.1s], collections [1]/[3.8s], total [3.1s]/[4.4s], memory [163.3mb]->[81.6mb]/[1.9gb], all_pools {[young] [132.2mb]->[3.1mb]/[133.1mb]}{[survivor] [16.6mb]->[10.9mb]/[16.6mb]}{[old] [14.5mb]->[67.5mb]/[1.8gb]}
elk_1  | [2016-11-14T09:28:34,696][WARN ][o.e.m.j.JvmGcMonitorService] [9KYASyV] [gc][3] overhead, spent [3.1s] collecting in the last [3.8s]
elk_1  | -14T09:28:34,780][INFO ][o.e.c.s.ClusterService   ] [9KYASyV] new_master {9KYASyV}{9KYASyViTaOsIAx7vjSZZQ}{NvfMmitMSNCXVkpHo7GzmQ}{172.17.0.2}{172.17.0.2:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
elk_1  | -14T09:28:34,895][INFO ][o.e.h.HttpServer         ] [9KYASyV] publish_address {172.17.0.2:9200}, bound_addresses {[::]:9200}
elk_1  | [2016-11-14T09:28:34,895][INFO ][o.e.n.Node               ] [9KYASyV] started
elk_1  | -14T09:28:35,085][INFO ][o.e.g.GatewayService     ] [9KYASyV] recovered [0] indices into cluster_state

现在它已经启动并且能够查询。

此外,curl 'http://localhost:9200/?pretty'结果如下,因此它正在运作:

$ curl 'http://localhost:9200/?pretty'
{
  "name" : "9KYASyV",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "UTZ18I0QRWmg0LFKUDE3ew",
  "version" : {
    "number" : "5.0.0",
    "build_hash" : "253032b",
    "build_date" : "2016-10-26T05:11:34.737Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.0"
  },
  "tagline" : "You Know, for Search"
}

同样从您的日志中,我们注意到vm.max_map_count很低。您可以查看here了解更多详情。

答案 1 :(得分:0)

按照弹性搜索图像的文档。我想你应该删除docker-compose文件中的command。 你的撰写文件应该是这样的

elk: 
  image: elasticsearch:latest       
  ports:  
    - "9200:9200"
    - "9300:9300"
  volumes:
    - ./Elasticsearch/data:/etc/elasticsearch/data
    - ./Elasticsearch/config/elasticsearch.yml:/etc/elasticsearch/config/elasticsearch.yml
  tty : true