环境
- k8s:1.24.16
- es版本:7.17.3
- chart包:bitnami/elasticsearch
默认情况下chart包部署的是master,node角色共用节点,所以需要修改role。chart包中的README.md中也给出了示例。
步骤
下载chart包
helm search repo elasticsearch
helm pull bitnami/elasticsearch
tar xvf elasticsearch-7.17.3.tgz
修改values.yaml
clusterName: "es"
nodeGroup: "data-frozen"
masterService: "es-headless"
#roles:
# master: "false"
# ingest: "true"
# data: "false"
# data_frozen: "true"
# remote_cluster_client: "false"
# ml: "false"
replicas: 1
minimumMasterNodes: 2
esConfig:
elasticsearch.yml: |
node.roles: [ data_frozen ]
roles中所有的角色都需要注释掉,否则会报错:unknown setting [node] please check that any required plugins are installed,can not explicitly configure node roles and use legacy role setting
需要修改elasticsearch.yml
中的角色。https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-node.html
安装
helm install es-frozen .
报错
pod启动后报错:Not enough free space for cache file of size in path [usr/share/elasticsearch/data/nodes/0]
这个报错是磁盘空间不足。但是上面可以看到我的磁盘空间是足够的,还有300多G。
解决
查看官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots.html
To partially mount an index, you must have one or more nodes with a shared cache available. By default, dedicated frozen data tier nodes (nodes with the data_frozen role and no other data roles) have a shared cache configured using the greater of 90% of total disk space and total disk space subtracted a headroom of 100GB.
要部分挂载索引,必须具有一个或多个具有可用共享缓存的节点。默认情况下,专用冻结数据层节点(具有该 data_frozen 角色且没有其他数据角色的节点)使用总磁盘空间的 90% 和总磁盘空间减去 100GB 余量(以较大者为准)配置了共享缓存。
Using a dedicated frozen tier is highly recommended for production use. If you do not have a dedicated frozen tier, you must configure the xpack.searchable.snapshot.shared_cache.size setting to reserve space for the cache on one or more nodes. Partially mounted indices are only allocated to nodes that have a shared cache.
强烈建议在生产环境中使用专用的冻结层。如果没有专用的冻结层,则必须配置该 xpack.searchable.snapshot.shared_cache.size
设置,以便在一个或多个节点上为缓存保留空间。部分挂载的索引仅分配给具有共享缓存的节点。
该参数(静态)为部分装载索引的共享缓存保留的磁盘空间。接受总磁盘空间的百分比或绝对字节值。默认为 90% 专用冻结数据层节点的总磁盘空间。否则,缺省为 0b 。
再次修改values.yaml
clusterName: "es"
nodeGroup: "data-frozen"
masterService: "es-headless"
#roles:
# master: "false"
# ingest: "true"
# data: "false"
# data_frozen: "true"
# remote_cluster_client: "false"
# ml: "false"
replicas: 1
minimumMasterNodes: 2
esConfig:
elasticsearch.yml: |
node.roles: [ data_frozen ]
xpack.searchable.snapshot.shared_cache.size: 10G
helm upgrade es-frozen .
pod启动后查看日志,可以看到shared_snapshot_cache被设置成为了10G。
查看节点类型
进入容器,执行命令:
k exec -it es-data-frozen-0 -- sh
curl -X GET 127.0.0.1:9200/_nodes/stats?pretty -u elastic
确认节点是data_frozen
类型。