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. 【POJ2942】Knights of the Round Table(二分图 点双联通分量)

    题目链接 大意 给定\(N\)个点与\(M\)个关系,每个关系表示某两个点间没有直接的边相连,求不在所有奇环上的点的个数. (\(1\le N\le 1e3,1\le M\le 1e6\)) 思路 考 ...

  2. pycharm关闭pytest

    在pycharm中,如果py文件以 test 开头,则运行时会使用pytest执行,pycharm关闭pytest方式如下 File -> Settings -> Tools -> ...

  3. Python语言编程基础

    Python 技能目标 理解编程基本原理和思想 掌握python语言的基础语法 能够使用python进行基本的开发工作 熟练使用项目开发IDE:eclipse,PyDev 能够使用Python开发简单 ...

  4. C#Winform 注册使用全局快捷键详解

    C#.NET Winform 注册使用全局快捷键详解 借助于全局快捷键,用户可以在任何地方操控程序,触发对应的功能.但 WinForms 框架并没有提供全局快捷键的功能.想要实现全局快捷键需要跟 Wi ...

  5. SpringBoot 自定义MessageConvert

    创建一个MessageConvert类,实现HttpMessageConvert接口 简单实现,只完成写功能.其他默认false package com.boot.converter; import ...

  6. 使用IDEA新建一个Spring Boot项目

    本文使用Spring Initializer来创建 开发环境 操作系统:Windows 10 IDEA:2020.3.2 JDK:1.8 1. 启动IDEA,选择New Project(新建工程): ...

  7. axios请求方式

    `// 使用默认进行请求(默认是get) axios({ url: "http://localhost:9999/student/student/getAllStudent" }) ...

  8. 使用SpringBoot整合MybatisPlus出现 : java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

    解决方案一: 将测试类的包路径改为和主启动类的一致 解决方法二: 不想改测试类的路径 就在测试类上添加要测试的类的classes

  9. mysql is not null 执行效率低

    a表字段类型为int b表字段类型为varchar a left join b时如果查询条件是is not null,效率很快,is  null 效率很低 后来两者改为同类型 int,效率很高

  10. IDEA如何快速生成get和set方法

    方法一:1.鼠标右击"Generate"2.点击"Getter and Setter",3.将定义的字段全部选中,点击OK.方法二:使用alt+insert 快 ...