IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> Kubernetes上部署Elasticsearch集群记录 -> 正文阅读

[大数据]Kubernetes上部署Elasticsearch集群记录

  1. 规划
· 部署三个节点集群
· 采用Pod控制器部署ES应用
· ConfigMap配置应用
· 通过SVC发布应用
· PVPVC集群资源持久化数据
  1. 准备
    Docker镜像,基于elasticsearch:7.9.3打包增加SSL密钥库文件,密钥库可以自己通过ES自带工具生成,集群统一配置,这里为了方便直接打进镜像
From elasticsearch:7.9.3

COPY elastic-certificates.p12 /usr/share/elasticsearch/config/
  1. Yaml 文件
    PV、PVC 资源, 共三组

elastic-storage.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: elastic-master-pv
spec:
  storageClassName: elastic-master-pv
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  nfs: ## NFS挂载
    server: 192.168.31.233  ##NFS服务器地址
    path: /nfs/elastic/data/master ##NFS服务器挂载目录
    
    
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: elastic-data1-pv
spec:
  storageClassName: elastic-data1-pv
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.31.233
    path: /nfs/elastic/data/data1

    
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: elastic-data2-pv
spec:
  storageClassName: elastic-data2-pv
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.31.233
    path: /nfs/elastic/data/data2
    
    
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: elastic-master-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: elastic-master-pv
  resources:
    requests:
      storage: 20Gi
      
      
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: elastic-data1-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: elastic-data1-pv
  resources:
    requests:
      storage: 20Gi


---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: elastic-data2-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: elastic-data2-pv
  resources:
    requests:
      storage: 20Gi

Pod 声明
master.yaml

apiVersion: v1
kind: Pod
metadata:
  name: elastic-master
  labels:
    app: es-master
spec:
  containers:
    - name: es-master
      image: elasticsearch:7.9.3
      ports:
        - containerPort: 9200
        - containerPort: 9300
      env:
        - name: ES_JAVA_OPTS
          value: "-Xms4g -Xmx4g"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: network.publish_host
          value: "master-node.default" ## 发布地址,使用svc的dns和其他节点通信
      volumeMounts:
        - name: elastic-data
          mountPath: /usr/share/elasticsearch/data
        - name: elastic-config
          subPath: elasticsearch.yml
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
  volumes:
    - name: elastic-data
      persistentVolumeClaim:
        claimName: elastic-master-pvc
    - name: elastic-config
      configMap:
        name: elastic-config-map


---
apiVersion: v1
kind: Service
metadata:
  name: master-node
spec:
  selector:
    app: es-master
  ports:
    - name: http-1
      protocol: TCP
      port: 9200
      targetPort: 9200
    - name: tcp-1
      protocol: TCP
      port: 9300
      targetPort: 9300

data1.yaml

apiVersion: v1
kind: Pod
metadata:
  name: elastic-data1
  labels:
    app: es-data1
spec:
  containers:
    - name: es-data1
      image: elasticsearch:7.9.3
      resources:
        requests:
          memory: 8Gi
        limits:
          memory: 16Gi
      ports:
        - containerPort: 9200
        - containerPort: 9300
      env:
        - name: ES_JAVA_OPTS
          value: "-Xms8g -Xmx8g"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: network.publish_host
          value: "data1-node.default"
      volumeMounts:
        - name: elastic-data
          mountPath: /usr/share/elasticsearch/data
        - name: elastic-config
          subPath: elasticsearch.yml
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
  volumes:
    - name: elastic-data
      persistentVolumeClaim:
        claimName: elastic-data1-pvc
    - name: elastic-config
      configMap:
        name: elastic-config-map


---
apiVersion: v1
kind: Service
metadata:
  name: data1-node
spec:
  selector:
    app: es-data1
  ports:
    - name: http-1
      protocol: TCP
      port: 9200
      targetPort: 9200
    - name: tcp-1
      protocol: TCP
      port: 9300
      targetPort: 9300

data2.yaml

apiVersion: v1
kind: Pod
metadata:
  name: elastic-data2
  labels:
    app: es-data2
spec:
  containers:
    - name: es-data1
      image: elasticsearch:7.9.3
      resources:
        requests:
          memory: 8Gi
        limits:
          memory: 16Gi
      ports:
        - containerPort: 9200
        - containerPort: 9300
      env:
        - name: ES_JAVA_OPTS
          value: "-Xms8g -Xmx8g"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: network.publish_host
          value: "data2-node.default"
      volumeMounts:
        - name: elastic-data
          mountPath: /usr/share/elasticsearch/data
        - name: elastic-config
          subPath: elasticsearch.yml
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
  volumes:
    - name: elastic-data
      persistentVolumeClaim:
        claimName: elastic-master-pvc
    - name: elastic-config
      configMap:
        name: elastic-config-map


---
apiVersion: v1
kind: Service
metadata:
  name: data2-node
spec:
  selector:
    app: es-data2
  ports:
    - name: http-1
      protocol: TCP
      port: 9200
      targetPort: 9200
    - name: tcp-1
      protocol: TCP
      port: 9300
      targetPort: 9300

ConfigMap 配置文件
elastic-map.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: elastic-config-map
data:
  elasticsearch.yml: |-
    cluster:
      name: aaron-cluster
      initial_master_nodes: ## 集群初始化master节点,接受 节点名称(node.name) 和 IP, 尝试使用域名无果
        - elastic-master
    node:
      name: ${POD_NAME}
      master: true
      data: true
      max_local_storage_nodes: 3  ## 多个ES服务使用一个磁盘需要配置
    discovery:
      seed_hosts: ## svc 提供的DNS记录
        - master-node.default
        - data1-node.default
        - data2-node.default
    network:
      host: 0.0.0.0
    indices:
      memory:
        index_buffer_size: 20%
    bootstrap:
      system_call_filter: false
    http:
      cors:
        enabled: true
        allow-origin: "*"
    xpack:
      security:
        enabled: true
        transport:
          ssl:
            enabled: true
            verification_mode: certificate
            keystore:
              path: /usr/share/elasticsearch/config/elastic-certificates.p12
            truststore:
              path: /usr/share/elasticsearch/config/elastic-certificates.p12

  1. 发布所以资源

所有yaml放到同一目录

kubectl apply -f .

进入容器初始化集群密码

kubectl exec -it elastic-master bash

## 容器内执行
bin/elasticsearch-setup-passwords interactive

## 输入密码....

##容器内验证
curl -u elastic localhost:9200/_cat/nodes?v
## 输入上面的密码
  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2021-08-29 09:09:56  更:2021-08-29 09:10:13 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年1日历 -2025/1/18 16:57:00-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码