Docker容器中运行ElasticSearch、Kibana和Cerebro

新建 docker-compose.yml

version: '2.2'
services:
  cerebro:
    image: lmenezes/cerebro:0.8.3
    container_name: cerebro
    ports:
      - "9000:9000"
    command:
      - -Dhosts.0.host=http://elasticsearch:9200
    networks:
      - es7net
  kibana:
    image: docker.elastic.co/kibana/kibana:7.1.0
    container_name: kibana7
    environment:
      - I18N_LOCALE=zh-CN
      - XPACK_GRAPH_ENABLED=true
      - TIMELION_ENABLED=true
      - XPACK_MONITORING_COLLECTION_ENABLED="true"
    ports:
      - "5601:5601"
    networks:
      - es7net
  elasticsearch:
    image: elasticsearch:7.1.0
    container_name: es7_01
    environment:
      - cluster.name=ES
      - node.name=es7_01
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.seed_hosts=es7_01,es7_02
      - cluster.initial_master_nodes=es7_01,es7_02
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es7data1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - es7net
  elasticsearch2:
    image: elasticsearch:7.1.0
    container_name: es7_02
    environment:
      - cluster.name=ES
      - node.name=es7_02
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.seed_hosts=es7_01,es7_02
      - cluster.initial_master_nodes=es7_01,es7_02
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - es7data2:/usr/share/elasticsearch/data
    networks:
      - es7net


volumes:
  es7data1:
    driver: local
  es7data2:
    driver: local

networks:
  es7net:
    driver: bridge

在docker-compose.yml目录下运行

> docker-compose up
Creating network "elasticsearch_default" with the default driver
Creating volume "elasticsearch_es7data1" with local driver
Creating volume "elasticsearch_es7data2" with local driver
Pulling cerebro (lmenezes/cerebro:0.8.3)...
0.8.3: Pulling from lmenezes/cerebro
27833a3ba0a5: Pull complete
16d944e3d00d: Pull complete
6aaf465b8930: Pull complete
0684138f4cb6: Pull complete
67c4e741e688: Pull complete
08ba3d4c90ec: Pull complete
5f6bc33abf7a: Pull complete
Pulling kibana (docker.elastic.co/kibana/kibana:7.1.0)...
7.1.0: Pulling from kibana/kibana
8ba884070f61: Downloading [======================================>            ]  57.82MB/75.4MB
1d1fa0015513: Downloading [==============================================>    ]  41.75MB/44.81MB
89eb31e0c2f5: Downloading [============>                                      ]  41.63MB/169.4MB
06e418438b84: Waiting
402cffb373dc: Waiting
04a881828200: Waiting
301a4cfc4f4f: Waiting

查看kibana

http://localhost:5601

此时kibana已被汉化- I18N_LOCALE=zh-CN

查看Cerebro

http://localhost:9000
Docker容器中运行ElasticSearch、Kibana和Cerebro_第1张图片
刚开始启动需要提供一个ElasticSearch的Endpoint
Docker容器中运行ElasticSearch、Kibana和Cerebro_第2张图片
集群名称:ES
节点:2nodes
索引:2 indices
分片:4 shards
文档:4 docs
占用存储空间:104.52KB

所有命令:

#启动
docker-compose up

#停止容器
docker-compose down

#停止容器并且移除数据
docker-compose down -v

#一些docker 命令
docker ps
docker stop Name/ContainerId
docker start Name/ContainerId

#删除单个容器
$docker rm Name/ID
-f, –force=false; -l, –link=false Remove the specified link and not the underlying container; -v, –volumes=false Remove the volumes associated to the container

#删除所有容器
$docker rm `docker ps -a -q`  
停止、启动、杀死、重启一个容器
$docker stop Name/ID  
$docker start Name/ID  
$docker kill Name/ID  
$docker restart name/ID

老师的原文传送门

你可能感兴趣的:(ElasticSearch,搜索引擎)