Elasticsearch 5.5.3+Kubernetes

Elasticsearch 5.5.3+Kubernetes


그룹 모드의elasticsearchusermemlock 문제 해결


미러 버전:
registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v12
es 공식 제공 거울 docker.elastic.co/elasticsearch/elasticsearch:5.5.3은elasticsearch 사용자를bootstrapuser로 합니다. 용기가 시작될 때ulimit-l를 통해memlock을 unlimited로 수정할 수 없기 때문에bootstrap을 설정할 수 없습니다.memory_lock:true를 시작할 때 실패했습니다.
dockerfile에서 USER root를 사용하고 ENTRYPOINT에서 사용해야 합니다.
chown -R elasticsearch:elasticsearch "$path"
exec gosu elasticsearch $@

미러링에 대한 소스 코드:https://github.com/hy9418/elasticsearch.git
우리의 아리운 거울 주소를 직접 사용할 수 있다
docker pull registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v12

플러그인 설치


미러 버전:
registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v13
  • x-pack,analysis-icu,analysis-phonetic,analysis-smartch를 설치합니다
  • RUN elasticsearch-plugin install x-pack && \
    elasticsearch-plugin install analysis-icu && \
    elasticsearch-plugin install analysis-phonetic && \
    elasticsearch-plugin install analysis-smartcn
    
  • 중국어 분사 플러그인,pinyin 병음 분사 플러그인을 설치합니다
  • git clone https://github.com/medcl/elasticsearch-analysis-ik.git
    git clone https://github.com/medcl/elasticsearch-analysis-pinyin.git
    

    프로젝트에 들어간 후 5.5.3 버전 태그로 전환하여 패키지 컴파일하기
    git checkout v5.5.3
    mvn clean package
    

    미러에 압축 풀기
    COPY pinyin /usr/share/elasticsearch/plugins/pinyin
    COPY ik /usr/share/elasticsearch/plugins/ik
    

    configmap을 사용하여 elasticsearch를 설정합니다.yml


    미러 버전:
    registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v14
    런을 추가합니다.sh
    ulimit -l unlimited
    if [ -d /configmap ]; then
        for z in /configmap/*.yml; do
            cat $z >> /usr/share/elasticsearch/config/elasticsearch.yml
        done
    fi
    set -- elasticsearch "$@"
    /docker-entrypoint.sh "$@"
    
  • 용기가 시작될 때memlock을 자동으로 수정합니다
  • configmap을/configmap 디렉터리에 마운트하고 *.yml 파일의 값은elasticsearchconfig path의 yml에 기록됩니다
  • elasticsearch 사용자를 사용하여 프로세스를 시작합니다

  • 마스터 노드 configmap:
    apiVersion: v1
    data:
        elasticsearch.yml: |
            cluster.name: elasticsearch-cluster
            bootstrap.memory_lock: true
            discovery.zen.ping.unicast.hosts: elasticsearch-cluster-discovery
            node.master: true
            node.data: false
            discovery.zen.minimum_master_nodes: 2
            discovery.zen.ping_timeout: 5s
            node.ingest: true
            transport.tcp.port: 9300
            transport.host: 0.0.0.0
    kind: ConfigMap
    metadata:
        name: elasticsearch-master-configmap
        namespace: ns-elastic
    

    데이터 노드 configmap:
    apiVersion: v1
    data:
        elasticsearch.yml: |
            cluster.name: elasticsearch-cluster
            bootstrap.memory_lock: true
            discovery.zen.ping.unicast.hosts: elasticsearch-cluster-discovery
            node.master: false
            node.data: true
            node.ingest: true
            discovery.zen.ping_timeout: 5s
            transport.host: 0.0.0.0
    kind: ConfigMap
    metadata:
        name: elasticsearch-data-configmap
        namespace: ns-elastic
    

    사용 시작


    클러스터 모드

    kind: Deployment
    apiVersion: apps/v1beta2
    metadata:
      labels:
        elastic-app: elasticsearch-cluster
        role: master
      name: elasticsearch-master
      namespace: ns-elastic
    spec:
      replicas: 3
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          elastic-app: elasticsearch-cluster
          role: master
      template:
        metadata:
          labels:
            elastic-app: elasticsearch-cluster
            role: master
        spec:
          containers:
            - name: elasticsearch-master
              image: registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v14
              volumeMounts:
              - name: elasticsearch-master-configmap
                mountPath: /configmap
              ports:
                - containerPort: 9200
                  protocol: TCP
                - containerPort: 9300
                  protocol: TCP
              env:
                - name: "ES_JAVA_OPTS"
                  value: "-Xms512m -Xmx512m"
              securityContext:
                privileged: true
          volumes:
            - name: elasticsearch-master-configmap
              configMap:
                    name: elasticsearch-master-configmap
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      labels:
        elastic-app: elasticsearch-cluster
      name: elasticsearch-cluster-discovery
      namespace: ns-elastic
    spec:
      ports:
        - port: 9300
          targetPort: 9300
      selector:
        elastic-app: elasticsearch-cluster
        role: master
    
    ---
    kind: Deployment
    apiVersion: apps/v1beta2
    metadata:
      labels:
        elastic-app: elasticsearch-cluster
        role: data
      name: elasticsearch-data
      namespace: ns-elastic
    spec:
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          elastic-app: elasticsearch-cluster
      template:
        metadata:
          labels:
            elastic-app: elasticsearch-cluster
            role: data
        spec:
          containers:
            - name: elasticsearch-data
              image: registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v14
              ports:
                - containerPort: 9200
                  protocol: TCP
                - containerPort: 9300
                  protocol: TCP
              volumeMounts:
                - name: elasticsearch
                  mountPath: /usr/share/elasticsearch/data
                - name: elasticsearch-data-configmap
                  mountPath: /configmap
              env:
                - name: "ES_JAVA_OPTS"
                  value: "-Xms512m -Xmx512m"
              securityContext:
                privileged: true
          volumes:
            - name: elasticsearch
              emptyDir: {}
            - name: elasticsearch-data-configmap
              configMap:
                    name: elasticsearch-data-configmap
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      labels:
        elastic-app: elasticsearch-cluster-nodeport
      name: elasticsearch-cluster-nodeport
      namespace: ns-elastic
    spec:
      ports:
        - port: 9200
          targetPort: 9200
      selector:
        elastic-app: elasticsearch-cluster
      type: NodePort
    

    단일 모드

    kind: Deployment
    apiVersion: apps/v1beta2
    metadata:
      labels:
        elastic-app: elasticsearch-simple
      name: elasticsearch-simple
      namespace: ns-elastic
    spec:
      replicas: 1
      revisionHistoryLimit: 4
      selector:
        matchLabels:
          elastic-app: elasticsearch-simple
      template:
        metadata:
          labels:
            elastic-app: elasticsearch-simple
        spec:
          containers:
            - name: elasticsearch-simple
              image: registry.cn-hangzhou.aliyuncs.com/fugle/elasticsearch:v13
              ports:
                - containerPort: 9200
                  protocol: TCP
                - containerPort: 9300
                  protocol: TCP
              volumeMounts:
                - name: elasticsearch-simple
                  mountPath: /usr/share/elasticsearch/data
              env:
                - name: "ES_JAVA_OPTS"
                  value: "-Xms512m -Xmx512m"
              securityContext:
                privileged: true
          volumes:
            - name: elasticsearch-simple
              persistentVolumeClaim:
                    claimName: elasticsearch-simple
    ---
    kind: Service
    apiVersion: v1
    metadata:
      labels:
        elastic-app: elasticsearch-simple
      name: elasticsearch-simple
      namespace: ns-elastic
    spec:
      ports:
        - port: 9300
          targetPort: 9300
      selector:
        elastic-app: elasticsearch-simple
    ---
    kind: Service
    apiVersion: v1
    metadata:
        labels:
            elastic-app: elasticsearch-simple-nodeport
        name: elasticsearch-simple-nodeport
        namespace: ns-elastic
    spec:
        ports:
        - port: 9200
          targetPort: 9200
        selector:
          elastic-app: elasticsearch-simple
        type: NodePort
    

    주: imagePullSecret,namespace,pv 등 대상

    좋은 웹페이지 즐겨찾기