《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.1.Elastic Stack 安装部署——3.4.1.8. ECK 安装(7) https://developer.aliyun.com/article/1231274
部署 Hot-Warm 架构 Elasticsearch 集群 和 Cerebro
定义一个 Elasticsearch 类型的资源文件部署一个冷热分离的 Elasticsearch 集群:
l 3 个 Master 节点,不存储数据,负责集群元数据的管理,集群范围的操作(创建或删除索引,跟踪集群节点,分片分配等等)。Master 节点因为没有读写数据的压力,因此选择最便宜的高效云盘。
l 3 个 Hot 节点,新的数据都会首先写入 Hot 节点,承受较大的读写压力,选择使用读写性能最好的 ESSD 硬盘。
l 3 个 Warm 节点,选择读写性能稍差的 SSD 硬盘。
l 3 个 Cold 节点,选择最便宜的高效云盘。
apiVersion: elasticsearch.k8s.elastic.co/v1 kind: Elasticsearch metadata: name: hot-warm-elasticsearch spec: #禁用 https http: tls: selfSignedCertificate: disabled: true version: 7.14.0 nodeSets: #master 节点 - name: master count: 3 config: node.roles: ["master"] podTemplate: spec: containers: - name: elasticsearch resources: #限制资源使用 limits: memory: 1Gi cpu: 1 volumeClaimTemplates: - metadata: name: elasticsearch-data spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi storageClassName: alicloud-disk-efficiency #挂载高效云盘 # hot 节点 - name: hot count: 3 config: node.attr.data: hot #节点属性 node.roles: ["data","ingest"] podTemplate: spec: containers: - name: elasticsearch resources: limits: memory: 2Gi cpu: 2 volumeClaimTemplates: - metadata: name: elasticsearch-data spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi storageClassName: alicloud-disk-essd #挂载 ESSD # warm 节点 - name: warm count: 3 config: node.attr.data: warm #节点属性 node.roles: ["data","ingest"] podTemplate: spec: containers: - name: elasticsearch resources: limits: memory: 2Gi cpu: 1 volumeClaimTemplates: - metadata: name: elasticsearch-data spec: accessModes: - ReadWriteOnce resources: requests: storage: 60Gi storageClassName: alicloud-disk-ssd #挂载 SSD # cold 节点 - name: cold count: 3 config: node.attr.data: cold #节点属性 node.roles: ["data","ingest"] podTemplate: spec: containers: - name: elasticsearch resources: limits: memory: 2Gi cpu: 1 volumeClaimTemplates: - metadata: name: elasticsearch-data spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Gi storageClassName: alicloud-disk-efficiency #挂载高效云盘
为了方便我们观察索引在节点上的迁移情况,这里额外安装了 Cerebro,在 Cerebro 上可以很直观地看到索引在每个节点的分布情况。由于通过 ECK 安装的 Elasticsearch 默认都使用了自签名证书来进行 HTTPS 加密,而 Cerebro 默认只能连接受信任的 HTTPS 或者 HTTP 站点,因此我们在定义 Elasticsearch 资源文件时选择禁用 HTTPS,让 Cerebro 通过 HTTP 访问 Elasticsearch 集群。
apiVersion: apps/v1 kind: Deployment metadata: name: cerebro labels: app: cerebro spec: replicas: 1 selector: matchLabels: app: cerebro template: metadata: labels: app: cerebro spec: containers: - name: cerebro image: lmenezes/cerebro:0.9.4 ports: - containerPort: 9000
使用以下命令应用本实验的资源文件:
kubectl apply -f hot-warm/
查看创建的相关 Pod:
❯ kubectl get pod NAME READY STATUS RESTARTS AGE cerebro-99484576f-pwx85 1/1 Running 0 6h19m hot-warm-elasticsearch-es-cold-0 1/1 Running 0 113s hot-warm-elasticsearch-es-cold-1 1/1 Running 0 112s hot-warm-elasticsearch-es-cold-2 1/1 Running 0 112s hot-warm-elasticsearch-es-hot-0 1/1 Running 0 113s hot-warm-elasticsearch-es-hot-1 1/1 Running 0 113s hot-warm-elasticsearch-es-hot-2 1/1 Running 0 113s hot-warm-elasticsearch-es-master-0 1/1 Running 0 113s hot-warm-elasticsearch-es-master-1 1/1 Running 0 113s hot-warm-elasticsearch-es-master-2 1/1 Running 0 113s hot-warm-elasticsearch-es-warm-0 1/1 Running 0 113s hot-warm-elasticsearch-es-warm-1 1/1 Running 0 113s hot-warm-elasticsearch-es-warm-2 1/1 Running 0 113s hot-warm-kibana-kb-7d5747887d-n8dzd 1/1 Running 0 82s
开启端口转发,将 Kibana 和 Cerebro 的服务转发到本地,方便我们访问。
kubectl port-forward pod/cerebro-99484576f-pwx85 9000 kubectl port-forward service/hot-warm-kibana-kb-http 5601
获取 elastic 用户密码:
PASSWORD=$(kubectl get secret hot-warm-elasticsearch-es-elastic-user \ -o go-template='{{.data.elastic | base64decode}}') echo $PASSWORD #elastic 用户密码 js373o37ZKu3DKDo69co97Ds
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.1.Elastic Stack 安装部署——3.4.1.8. ECK 安装(9) https://developer.aliyun.com/article/1231272