1、GlusterFS部署

安装GlusterFS集群的主要目的是为k8s集群提供分布式持久化存储。

GlusterFS部署使用2台服务器,服务名称与IP如下:

1 	db-storagea  	10.1.70.29
2 db-storageb 10.1.70.30

Ubuntu系统服务安装及启动

apt-get install  glusterfs-server
systemctl start glusterd
systemctl enable glusterd
systemctl status glusterd

集群认证

服务器10.1.70.29

gluster peer probe 10.1.70.30

查看集群集群状态

服务器10.1.70.29

命令:gluster peer status

反馈:Number of Peers: 1

服务器10.1.70.30

命令:gluster peer status

反馈:Number of Peers: 1

分别在服务器10.1.70.29,10.1.70.30创建目录

mkdir -p /data/gluster  /data/portal-files  /data/portal-private  /data/portal-config

创建gluster卷并启动卷

创建名称为 : mamm-volume 路径为 :/data/gluster
gluster volume create mamm-volume repl 2 10.1.70.29:/data/gluster 10.1.70.30:/data/gluster
启动mamm-volume卷
gluster volume start mamm-volume gluster volume create portal-files repl 2 10.1.70.29:/data/portal-files 10.1.70.30:/data/portal-files force gluster volume start portal-files gluster volume create portal-private repl 2 10.1.70.29:/data/portal-private 10.1.70.30:/data/portal-private force gluster volume start portal-private gluster volume create portal-config repl 2 10.1.70.29:/data/portal-config 10.1.70.30:/data/portal-config force gluster volume start portal-config

查看卷空间

命令: gluster volume info

Gluster 测试 找台服务器测试

客户端安装  glusterfs-client
mkdir /opt/clusterfstest
挂载
mount -t glusterfs 10.1.70.29:/mamm-volume /opt/clusterfstest

2、Kubernetes使用glusterfs持久化

先决条件

  • 设置 GlusterFS 服务器集群
  • 创建 GlusterFS 卷

创建 endpoints

apiVersion: v1
kind: Endpoints
metadata:
name: glusterfs-cluster
subsets:
- addresses:
- ip: 10.1.70.29
ports:
- port: 24007
- addresses:
- ip: 10.1.70.30
ports:
- port: 24007

subsets字段应填充 GlusterFS 集群中节点的地址。可以在字段中提供任何有效值(从 1 到 65535)端口。

kubectl get endpoints

还需要为这些端点创建一个服务,以便它们能够持久存在

apiVersion: v1
kind: Service
metadata:
name: glusterfs-cluster
spec:
ports:
- port: 20447

3、使用控制器进行挂载

    volumeMounts:
- mountPath: "/var/www/html/web/sites/default/files"
name: portal-files
- mountPath: "/var/www/html/private"
name: portal-private
- mountPath: "/var/www/html/config"
name: portal-config
volumes:
- name: portal-files
glusterfs:
endpoints: glusterfs-cluster
path: portal-files
readOnly: false
- name: portal-private
glusterfs:
endpoints: glusterfs-cluster
path: portal-private
readOnly: false
- name: portal-config
glusterfs:
endpoints: glusterfs-cluster
path: portal-config
readOnly: false

4、在pod内测试

在pod内相关目录创建文件,然后在gluster服务器卷目录查看该文件是否存在

kubernetes资源使用glusterfs卷进行数据持久化的更多相关文章

  1. 从0到1使用Kubernetes系列(六):数据持久化实战

    本文是从 0 到 1 使用 Kubernetes 系列第六篇,上一篇<从 0 到 1 使用 Kubernetes 系列(五):Kubernetes Scheduling>介绍了 Kuber ...

  2. Kubernetes使用GlusterFS实现数据持久化

    k8s中部署有状态应用等需要持久化数据的应用,必不可少得用存储,k8s支持很多中存储方案,我司目前使用的存储有glusterfs(分为容器化和裸机方式).nfs供应用选用,本次就简单实战下gluste ...

  3. kubernetes的应用数据持久化

    1.无状态应用与有状态应用 应用的有状态和无状态是根据应用是否有持久化保存数据的需求而言的,即持久化保存数据的应用为有状态的应用,反之则为无状态的应用.常见的系统往往是有状态的应用,比如对于微博和微信 ...

  4. $《第一行代码:Android》读书笔记——第6章 数据持久化

    主要讲述了Android数据持久化的三种方式:文件存储.SharedPreference存储.SQLite数据库存储. (一)文件存储 其实Android中文件存储方式和Java的文件操作类似,就是用 ...

  5. 附009.Kubernetes永久存储之GlusterFS独立部署

    一 前期准备 1.1 基础知识 Heketi提供了一个RESTful管理界面,可以用来管理GlusterFS卷的生命周期.Heketi会动态在集群内选择bricks构建所需的volumes,从而确保数 ...

  6. 附010.Kubernetes永久存储之GlusterFS超融合部署

    一 前期准备 1.1 基础知识 在Kubernetes中,使用GlusterFS文件系统,操作步骤通常是: 创建brick-->创建volume-->创建PV-->创建PVC--&g ...

  7. kubernetes存储之GlusterFS

    目录 1.glusterfs概述 1.1.glusterfs简介 1.2.glusterfs特点 1.3.glusterfs卷的模式 2.heketi概述 3.部署heketi+glusterfs 3 ...

  8. Kubernetes资源与对象简述

    资料 k8s基本对象概念 背景 资源和对象   Kubernetes 中的所有内容都被抽象为"资源",如 Pod.Service.Node 等都是资源."对象" ...

  9. iOS数据持久化-OC

    沙盒详解 1.IOS沙盒机制 IOS应用程序只能在为该改程序创建的文件系统中读取文件,不可以去其它地方访问,此区域被成为沙盒,所以所有的非代码文件都要保存在此,例如图像,图标,声音,映像,属性列表,文 ...

随机推荐

  1. 震惊!!!!!!!靠sort水过二叉堆的天秀操作

  2. 基于PXIe接口的CoaXpress高速相机图像采集、回放

    PXIe简介 PCI eXtensions for Instrumentation or PXI is a computer-based hardware and software platform ...

  3. c++编译加执行脚本

    python 脚本 1 #! /usr/bin/python 2 3 import os 4 5 msg = os.popen("g++ test.cpp").read(); 6 ...

  4. Dubbo扩展点应用之二负载均衡

    负载均衡其本质就是将请求分摊到多个操作单元上进行,从而共同完成工作任务.其策略主要用于客户端春常在多个提供者时根据算法选择某个提供者.在集群负载均衡时,Dubbo提供了多种均衡策略(包括随机.轮询.最 ...

  5. 搭建开源跳板机——jumpserver

    搭建开源跳板机mobaxterm 官方文档:https://jumpserver.readthedocs.io/zh/master/ $ yum update -y # 防火墙 与 selinux 设 ...

  6. k8s家族Pod辅助小能手Init容器认知答疑?

    k8s家族Pod辅助小能手Init容器认知答疑? k8s集群Init 容器是一种特殊容器,职责是在Pod的生命周期中作为应用容器的前置启动容器. 在很多应用场景中,在 Pod 内的应用容器正式启动之前 ...

  7. Flume学习记录

    Flume 是 Cloudera 提供的一个高可用的,高可靠的,分布式的海量日志采集.聚合和传 输的系统.Flume 基于流式架构,灵活简单. Flume基础架构 Agent Agent 是一个 JV ...

  8. Vulhub-漏洞环境的搭建(详细版)

    安装Vulhub需要的基础环境 更新现有的软件 复制代码 1 2 sudo apt-get update sudo apt-get upgrade 安装Docker 复制代码 1 2 3 4 5 6 ...

  9. 用Smartbi与Tableau制作仪表盘有什么不同?

    随着数据应用程度的加深,用户.尤其是业务部门用户越来越希望能够了解业务表现数据更深层次的原因.导致到越来越多的业务人员参于数据分析.这样传统的BI就面临新模式的挑战了.哪我们即然花大量时间授人以鱼,为 ...

  10. 从零搭建Pytorch模型教程(一)数据读取

    ​  前言  本文介绍了classdataset的几个要点,由哪些部分组成,每个部分需要完成哪些事情,如何进行数据增强,如何实现自己设计的数据增强.然后,介绍了分布式训练的数据加载方式,数据读取的整个 ...