docker安装elasticsearch,elasticsearch集群和kibana

2017-10-11 2151点热度 0人点赞 0条评论

docker安装elasticsearch

官方docker文档地址

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

下载镜像

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.0.0

启动容器

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

docker elasticsearch集群

docker-compose.yml

保存位置:/var/services/homes/wangxianfeng/docker/elasticsearch/docker-compose.yml

version: '2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    container_name: es01
    environment:
      - node.name=es01
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - bootstrap.system_call_filter=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    container_name: es02
    environment:
      - node.name=es02
      - discovery.seed_hosts=es01
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - bootstrap.system_call_filter=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data
    networks:
      - esnet

volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local

networks:
  esnet:

启动集群

sudo docker-compose up
后台运行,加-d选项
sudo docker-compose up -d

停止集群

sudo docker-compose down
To destroy the cluster and the data volumes just type 
docker-compose down -v

检查日志

sudo docker-compose logs

检查运行的实例

sudo docker-compose ps

错误解决

  1. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    解决方法:
    sudo vi /etc/sysctl.conf添加以下内容:
    vm.max_map_count=262144
    并执行sudo sysctl -p

  2. ERROR: [1] bootstrap checks failed
    [1]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
    解决方法:
    在environment中添加如下配置:

- bootstrap.memory_lock=false
- bootstrap.system_call_filter=false
已更新在上边的docker-compose.yml文件中。

docker安装kibana

官方文档

https://www.elastic.co/guide/en/kibana/current/docker.html

配置kibana

kibana的配置是与elasticsearch集群配置在docker-compose.yml中的,在docker-compose.yml添加以下配置:

kibana:
    image: docker.elastic.co/kibana/kibana:7.0.0
    container_name: kibana
    environment:
      SERVER_NAME: 192.168.2.99
      SERVER_HOST: 0.0.0.0
      ELASTICSEARCH_HOSTS: http://192.168.2.99:9200
    ports:
      - 5601:5601
    networks:
      - esnet

完整的docker-compose.yml

version: '2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    container_name: es01
    environment:
      - node.name=es01
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - bootstrap.system_call_filter=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.0
    container_name: es02
    environment:
      - node.name=es02
      - discovery.seed_hosts=es01
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - bootstrap.system_call_filter=false
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data
    networks:
      - esnet
  kibana:
    image: docker.elastic.co/kibana/kibana:7.0.0
    container_name: kibana
    environment:
      SERVER_NAME: 192.168.2.99
      SERVER_HOST: 0.0.0.0
      ELASTICSEARCH_HOSTS: http://192.168.2.99:9200
    ports:
      - 5601:5601
    networks:
      - esnet 

volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local

networks:
  esnet:


王显锋

激情工作,快乐生活!

文章评论