Elasticsearch의kubernetes 집단 구축

3554 단어 K8SElasticSearch

1. 수요

  • nfs 마운트
  • es-ik-pinyin
  • max virtual memroy areas vm.max_map_count [65530] is too low,increase to at least [262144]
  • sysctl:setting key "vm.max_map_count':Read-only file system

  • 2. nfs 마운트


    nfs:network file system, 네트워크 파일 시스템, RPC 기반 실현, UDP 프로토콜 기반;
    ps: 파일 마운트 실패, 디렉터리 마운트로 변경, subPath 지정
    volumes:
       - name: es6-elasticsearch
          nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/elasticsearch-cfg}
    ***********************************
    volumeMounts:
       - {
            name: es6-elasticsearch, 
            subPath: elasticsearch.yml,
            mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
          }

    3、initContainer


    컨테이너를 초기화합니다. 즉, 메인 용기가 시작되기 전에 하나 이상의 용기가 시작되고, Pod의 저장 공유, 네트워크 공유로 인해 initContainer에서 발생하는 데이터는 메인 용기에서 사용할 수 있습니다.
    initContainers: 
          - name: "sysctl"
            image: "busybox"
            imagePullPolicy: "Always"
            command: ["sysctl", "-w", "vm.max_map_count=262144"]
            securityContext:
              privileged: true

    솔루션 2:
    루트 사용자로 자르기
    sysctl -w vm.max_map_count=262144

    또는/etc/sysctl을 수정합니다.conf
    vm.max_map_count=262144

    4、k8s.Yaml

    # image harbor.suiyi.com.cn/component/elasticsearch-ik-pinyin:6.2.3
    kind: Deployment
    apiVersion: apps/v1
    metadata: {name: es6, namespace: dev}
    spec:
      replicas: 1
      selector:
        matchLabels: {app: es6}
      template:
        metadata:
          labels: {app: es6}
        spec:
          volumes:
          - name: es6-elasticsearch
            nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/elasticsearch-cfg}
          - name: es6-nodes
            nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/nodes/}
          - name: es6-logs
            nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/logs/}
          - name: es6-ikcustom
            nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/analysis-ik-custom/}
          - name: es6-ikcfg
            nfs: {server: 10.1.2.*, path: /data/dev/es/6.2.3/analysis-ik-cfg}
          initContainers: 
          - name: "sysctl"
            image: "busybox"
            imagePullPolicy: "Always"
            command: ["sysctl", "-w", "vm.max_map_count=262144"]
            securityContext:
              privileged: true
          containers:
          - name: es6
            image: jinyidong/es-ik-pinyin:6.2.3
            ports:
            - {containerPort: 9200, protocol: TCP}
            - {containerPort: 9300, protocol: TCP}
            resources: {}
            volumeMounts:
            - {
                name: es6-elasticsearch, 
                subPath: elasticsearch.yml,
                mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
              }
            - {name: es6-nodes, mountPath: /usr/share/elasticsearch/data/nodes/}
            - {name: es6-logs, mountPath: /usr/share/elasticsearch/data/logs/}
            - {name: es6-ikcustom, mountPath: /usr/share/elasticsearch/config/analysis-ik/custom/}
            - {
                name: es6-ikcfg, 
                subPath: IKAnalyzer.cfg.xml,
                mountPath: /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml
              }
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: es6
      namespace: dev
      labels: {app: es6}
    spec:
      ports:
      - {name: tcp9200, protocol: TCP, port: 9200, targetPort: 9200, nodePort: 29200}
      - {name: tcp9300, protocol: TCP, port: 9300, targetPort: 9300, nodePort: 29300}
      selector: {app: es6}
      type: NodePort

    좋은 웹페이지 즐겨찾기