如何在Kubernetes上的Elasticsearch中禁用交换?

根据官方的es文档,禁用交换是Elasticsearch可获得的最佳性能提升之一。

但是,事实证明配置起来很困难。我花了很多时间研究并尝试使用不同的方法来使用Kubernetes上的官方ES docker镜像禁用交换。

设置bootstrap.memory_lock: true为环境变量时,映像无法启动,并显示错误:Unable to lock JVM Memory:

error=12, reason=Cannot allocate memory. This can result in part of the JVM

being swapped out. Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit:

65536。正如文档所指出的那样,这是意料之中的。我什至/etc/security/limits.conf用设置挂载了一个自定义,但是失败了。

在k8s上使用官方es映像时,建议的禁用交换的方法是什么?

而且,这是我的Yaml的相关部分

apiVersion: apps/v1beta1

kind: StatefulSet

metadata:

name: elastic-data

spec:

serviceName: elastic-data

replicas: 1

template:

spec:

securityContext:

runAsUser: 0

fsGroup: 0

containers:

- name: elastic-data

image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.0

env:

- name: ES_JAVA_OPTS

value: "-Xms2g -Xmx2g"

- name: cluster.name

value: "elastic-devs"

- name: node.name

valueFrom:

fieldRef:

fieldPath: metadata.name

- name: discovery.zen.ping.unicast.hosts

value: "elastic-master.default.svc.cluster.local"

- name: node.master

value: "false"

- name: node.ingest

value: "false"

- name: node.data

value: "true"

- name: network.host

value: "0.0.0.0"

- name: path.data

value: /usr/share/elasticsearch/data

- name: indices.memory.index_buffer_size

value: "512MB"

- name: bootstrap.memory_lock

value: "true"

resources:

requests:

memory: "3Gi"

limits:

memory: "3Gi"

ports:

- containerPort: 9300

name: transport

- containerPort: 9200

name: http

volumeMounts:

- name: data-volume

mountPath: /usr/share/elasticsearch/data

- name: swappiness-config

mountPath: /etc/security/limits.conf

subPath: limits.conf

volumes:

- name: data-volume

persistentVolumeClaim:

claimName: pvc-es

- name: swappiness-config

configMap:

name: swappiness-config

items:

- key: limits.conf

path: limits.conf

limits.conf

elasticsearch soft memlock unlimited

elasticsearch hard memlock unlimited

elasticsearch hard nofile 65536

elasticsearch soft nofile 65536

回答:

我认为,yaml中的ulimit未被识别,因此我关注了这篇文章,并创建了一个带有用于设置设置的自定义入口点的图像。

以上是 如何在Kubernetes上的Elasticsearch中禁用交换? 的全部内容, 来源链接: utcz.com/qa/421283.html

回到顶部