代码之家  ›  专栏  ›  技术社区  ›  Jay

如何使用docker容器设置ElasticSearch容器的http.max_content_length值?

  •  0
  • Jay  · 技术社区  · 5 年前

    我在跑步 ElasticSearch 在我的Ubuntu服务器上使用docker容器的实例。 在一个大的插入或更新请求中,我得到以下异常。

    原始异常:Elasticsearch。网ElasticsearchClientException:请求无法执行。调用:状态代码413来自:POST/_bulk?漂亮=真&error_trace=true

    听起来我需要增加 http.max_content_length 默认内容 100mb .

    我使用下面的docker compose调出我的docker实例

    version: '3.4'
    services:
      # Nginx proxy
      nginx-proxy:
        image: jwilder/nginx-proxy
        container_name: nginx-proxy
        ports:
          - 80:80
          - 443:443
        restart: always
        networks:
          - nginx-proxy
        volumes:
          - /var/run/docker.sock:/tmp/docker.sock:ro
          - /etc/nginx/vhost.d:/etc/nginx/vhost.d:ro
          - /etc/certificates:/etc/nginx/certs
    
      # ElasticSearch instance
      es01:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
        container_name: es01
        environment:
          - VIRTUAL_HOST=my.elastic-domain.com
          - VIRTUAL_PORT=9200
          - ELASTIC_PASSWORD=mypassword
          - xpack.security.enabled=true
          - discovery.type=single-node
          - http.max_content_length=3000mb
          - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        cap_add:
          - IPC_LOCK
        volumes:
          - data01:/usr/share/elasticsearch/data
        ports:
          - 9200:9200
        expose:
          - 9200
        networks:
          - nginx-proxy
        depends_on:
          - nginx-proxy
    volumes:
      data01:
        driver: local
    networks:
      nginx-proxy:
      default:
        external:
          name: nginx-proxy
    

    正如你所看到的,我试图通过设置一个环境变量来增加值 http.max_content_length=3000mb

    此外,在Nginx代理中,我设置了 client_max_body_size 0; 以确保代理允许无限大小。

    如何设置 http.max_content_length 的值 ElasticSearch 集装箱使用码头集装箱?

    0 回复  |  直到 5 年前
        1
  •  0
  •   user1031711    3 年前

    您可以修改elasticsearch.yml文件并添加

    http.max_content_length=3000mb

    这个文件在您的弹性docker conntainer/config/elasticsearch.yml中

    推荐文章