【ElasticSearch】Docker安装部署ES

版本:
CentOS 8
ElasticSearch 7.9.2
Docker 19.03.13

拉镜像

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

Run

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

Docker-Compose配置

vim docker-compose.yml

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /mnt/docker/es_docker/es_data_01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /mnt/docker/es_docker/es_data_02:/usr/share/elasticsearch/data
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /mnt/docker/es_docker/es_data_03:/usr/share/elasticsearch/data
    networks:
      - elastic
networks:
  elastic:
    driver: bridge
  • 启动:
docker-compose up
  • 查询集群节点数:
curl -X GET "localhost:9200/_cat/nodes?v&pretty"

几种报错

vm.max_map_count 报错

启动时,有可能会启动不成功,提示如下(不是按顺序,穿插在打印信息中的日志):

es03    | ERROR: [1] bootstrap checks failed
es03    | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Native controller process has stopped - no new native processes can be started

遇到这个错误时,将虚拟内存加大即可解决这个问题,操作如下:

vim /etc/sysctl.conf
#添加下面这行
vm.max_map_count=655360
#加载参数
sysctl -p

文件权限不足

如果出现[“org.elasticsearch.bootstrap.StartupException: ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes];”,后面紧跟很多栈信息输出时,应当是volumes对应的本地目录权限不够导致,可以简单粗暴给出 :

chmod 777 ./es_data_01 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值