Mik*_*ike 5 elasticsearch kubernetes google-kubernetes-engine
根据官方 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
Run Code Online (Sandbox Code Playgroud)
限制.conf
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
elasticsearch hard nofile 65536
elasticsearch soft nofile 65536
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3006 次 |
| 最近记录: |