首页 > 其他分享 >Curve 分布式存储在 KubeSphere 中的实践

Curve 分布式存储在 KubeSphere 中的实践

时间:2023-01-03 18:32:34浏览次数:63  
标签:service Curve KubeSphere curve Up host curve1 root 分布式

作者:尹珉, KubeSphere 社区用户委员会杭州站站长

Curve 介绍

Curve 是网易开发的现代存储系统,目前支持文件存储 (CurveFS) 和块存储 (CurveBS)。现在它作为一个沙盒项目托管在 CNCF。
Curve 是一个高性能、轻量级操作、本地云的开源分布式存储系统。Curve 可以应用于 :

  1. 主流云本地基础设施平台 OpenStack 和 Kubernetes;
  2. 云本地数据库的高性能存储 ;
  3. 使用与 s3 兼容的对象存储作为数据存储的云存储中间件。

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere

实现效果

通过部署 CurveFS 集群、Helm 部署 Curve-csi 插件创建 SC 来达到声明 PVC 时自动创建 PV 的效果

开始部署

K8s 环境可以通过安装 KubeSphere 进行部署 , 我使用的是高可用方案。
在公有云上安装 KubeSphere 参考文档:​​多节点安装​

[root@k8s-master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 79d v1.23.8
k8s-node1 Ready worker 79d v1.23.8
k8s-node2 Ready worker 79d v1.23.8
k8s-node3 Ready worker 79d v1.23.8

Curve 分布式存储在 KubeSphere 中的实践_K8s_02

使用 Curveadm 工具部署 CurveFS

CurveAdm 是 Curve 团队为提高系统易用性而设计的工具,其主要用于快速部署和运维 CurveBS/CurveFS 集群。

硬件环境需求:

宿主机

系统

IP 地址

Curve(控制节点)

Centos7.9

192.168.149.169

Curve1(服务节点)

Centos7.9

192.168.149.177

每台服务器都需要安装 docker:

[root@curve ~]# yum install -y yum-utils
[root@curve ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@curve ~]# yum install docker-ce docker-ce-cli containerd.io
[root@curve ~]# systemctl start docker

控制节点安装 Curveadm:

[root@curve ~]# bash -c "$(curl -fsSL https://curveadm.nos-eastchina1.126.net/script/install.sh)"

主机管理

主机模块用来统一管理用户主机,以减少用户在各配置文件中重复填写主机 SSH 连接相关配置。(此操作在控制节点进行)

准备主机列表:

global:
user: root
ssh_port: 22
private_key_file: /root/.ssh/id_rsa

hosts:
- host: curve1
hostname: 192.168.149.169
- host: curve
hostname: 192.168.149.177
forward_agent: true
become_user: root
labels:
- client

说明:

Curve 分布式存储在 KubeSphere 中的实践_K8s_03

创建 SSH 秘钥:

[root@curve ~]# ssh-keygen #一路回车即可
[root@curve ~]# ssh-copy-id -i [email protected]
#发送私钥到服务节点

导入主机列表:

[root@curve ~]#curveadm hosts commit hosts.yaml

查看主机列表:

[root@curve ~]# curveadm hosts ls

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_04

CuveFS 集群拓扑

集群拓扑文件用来描述哪些服务部署在哪些机器上,以及每一个服务实例的配置。
(目前集群拓扑分为单机部署、多机部署本教程只演示单机部署)

准备单机部署文件:

说明:此文件只需要修改一处,target 的值改成服务节点的 hostname,其他全默认不需要修改。

kind: curvefs
global:
report_usage: true
data_dir: ${home}/curvefs/data/${service_role}${service_host_sequence}
log_dir: ${home}/curvefs/logs/${service_role}${service_host_sequence}
container_image: opencurvedocker/curvefs:latest
variable:
home: /tmp
target: curve1 #这里需要改成服务节点的hostname

etcd_services:
config:
listen.ip: ${service_host}
listen.port: 2380${service_host_sequence} # 23800,23801,23802
listen.client_port: 2379${service_host_sequence} # 23790,23791,23792
deploy:
- host: ${target}
- host: ${target}
- host: ${target}

mds_services:
config:
listen.ip: ${service_host}
listen.port: 670${service_host_sequence} # 6700,6701,6702
listen.dummy_port: 770${service_host_sequence} # 7700,7701,7702
deploy:
- host: ${target}
- host: ${target}
- host: ${target}

metaserver_services:
config:
listen.ip: ${service_host}
listen.port: 680${service_host_sequence} # 6800,6801,6802
listen.external_port: 780${service_host_sequence} # 7800,7801,7802
global.enable_external_server: true
metaserver.loglevel: 0
# whether commit filesystem caches of raft wal to disk.
# it should be true iff you wants data NEVER lost,
# of course, it will leads some performance skew.
braft.raft_sync: false
deploy:
- host: ${target}
- host: ${target}
- host: ${target}
config:
metaserver.loglevel: 0

部署预检

预检模块用来提前检测那些可能导致用户部署失败的因素,以提高用户部署的成功率。

添加自定义命名集群,并指定拓扑文件:

[root@curve ~]# curveadm cluster add curve -f topology.yaml

切换 curve 集群为当前管理集群:

[root@curve ~]# curveadm cluster checkout curve

执行预检:

[root@curve ~]# curveadm precheck

查看执行结果:

Curve 分布式存储在 KubeSphere 中的实践_Curve_05

使用 CurveAdm 部署 CurveFS 集群

[root@curve ~]# curveadm deploy
如果部署成功,将会输出类似 Cluster 'curve' successfully deployed ^_^. 的字样

查看集群运行情况:

[root@curve ~]#curveadm status
[root@localhost curve]# curveadm status
Get Service Status: [OK]

cluster name : curve
cluster kind : curvefs
cluster mds addr : 192.168.149.177:6700,192.168.149.177:6701,192.168.149.177:6702
cluster mds leader: 192.168.149.177:6701 / f339fd5e7f3e

Id Role Host Replicas Container Id Status
-- ---- ---- -------- ------------ ------
724fe98710d0 etcd curve1 1/1 e3d86591f2dc Up 50 seconds
d5b08fe05a81 etcd curve1 1/1 da7932929055 Up 50 seconds
963664e175dd etcd curve1 1/1 134d4445542a Up 50 seconds
83fa9fc656af mds curve1 1/1 1f7429cd9822 Up 48 seconds
f339fd5e7f3e mds curve1 1/1 2983a89adecf Up 49 seconds
3d7201165a57 mds curve1 1/1 b6135408346b Up 49 seconds
875d7fd126f2 metaserver curve1 1/1 1983afeed590 Up 44 seconds
9d5fb31b2bd9 metaserver curve1 1/1 fe920d6b7343 Up 44 seconds
1344d99579c4 metaserver curve1 1/1 875cb4e5c14d Up 44 seconds
[root@localhost curve]# curveadm status
Get Service Status: [OK]

cluster name : curve
cluster kind : curvefs
cluster mds addr : 192.168.149.177:6700,192.168.149.177:6701,192.168.149.177:6702
cluster mds leader: 192.168.149.177:6701 / f339fd5e7f3e

Id Role Host Replicas Container Id Status
-- ---- ---- -------- ------------ ------
724fe98710d0 etcd curve1 1/1 e3d86591f2dc Up 2 hours
d5b08fe05a81 etcd curve1 1/1 da7932929055 Up 2 hours
963664e175dd etcd curve1 1/1 134d4445542a Up 2 hours
83fa9fc656af mds curve1 1/1 1f7429cd9822 Up 2 hours
f339fd5e7f3e mds curve1 1/1 2983a89adecf Up 2 hours
3d7201165a57 mds curve1 1/1 b6135408346b Up 2 hours
875d7fd126f2 metaserver curve1 1/1 1983afeed590 Up 2 hours
9d5fb31b2bd9 metaserver curve1 1/1 fe920d6b7343 Up 2 hours
1344d99579c4 metaserver curve1 1/1 875cb4e5c14d Up 2 hours

KubeSphere 平台部署 minio

添加 minio 应用仓库

Curve 分布式存储在 KubeSphere 中的实践_docker_06

添加仓库地址:​​charts.min.io/​​。

Curve 分布式存储在 KubeSphere 中的实践_docker_07

从应用模板创建 minio 服务

<

Curve 分布式存储在 KubeSphere 中的实践_K8s_08

,

Curve 分布式存储在 KubeSphere 中的实践_docker_09

,

Curve 分布式存储在 KubeSphere 中的实践_docker_10

,

Curve 分布式存储在 KubeSphere 中的实践_Curve_11

,

Curve 分布式存储在 KubeSphere 中的实践_Curve_12

>

自定义 root 账号和密码:

Curve 分布式存储在 KubeSphere 中的实践_Curve_13

Curve 分布式存储在 KubeSphere 中的实践_Curve_14

访问 minio 界面并设置:

说明:登录的 URL 是集群宿主机的 IP+NodePort 端口,可以在 service 中查看对应端口号

Curve 分布式存储在 KubeSphere 中的实践_docker_15

Curve 分布式存储在 KubeSphere 中的实践_docker_16

点击新建 Bucket:

Curve 分布式存储在 KubeSphere 中的实践_Curve_17

自定义 Bucket 名称:

Curve 分布式存储在 KubeSphere 中的实践_Curve_18

创建 Policies:

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_19

自定义 Policy Name:

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_20

创建规则:

说明 : 此规则是全局 Bucket 都可以访问,生产环境不建议这么配置

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:DeleteObject",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListAllMyBuckets",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}

创建 Users:

Curve 分布式存储在 KubeSphere 中的实践_docker_21

创建 AKSK:

Curve 分布式存储在 KubeSphere 中的实践_K8s_22

Curve 分布式存储在 KubeSphere 中的实践_Curve_23

自定义账号名称并勾选刚才设置好的规则(也可以全选):

Curve 分布式存储在 KubeSphere 中的实践_docker_24

创建 Group:

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_25

Curve 分布式存储在 KubeSphere 中的实践_K8s_26

KubeSphere 平台部署 Cruvefs-csi 插件

创建应用:

Curve 分布式存储在 KubeSphere 中的实践_docker_27

选择应用商店:

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_28

选择 Curvefs-csi 应用进行安装:

Curve 分布式存储在 KubeSphere 中的实践_Curve_29

Curve 分布式存储在 KubeSphere 中的实践_docker_30

Curve 分布式存储在 KubeSphere 中的实践_Curve_31

填写 parameters 信息。字段说明 :

  1. mdsAddr 地址可以通过 Curveadm status 输出后查看
  2. s3Endpoint 可以通过 K8s 集群的 service 里查看到(要填写 minio 服务对应的 NodePort,不要填写 console 的 Nodeport)
  3. AKSK 可以通过刚才 minio 上创建时保存的查看
  4. s3Bucket 可以通过刚才创建的 Bucket 查看

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_32

通过 Curve-sc 创建 PV 和 PVC 进行挂载

创建持久卷声明:

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_33

Curve 分布式存储在 KubeSphere 中的实践_Curve_34

Curve 分布式存储在 KubeSphere 中的实践_Curve_35

Curve 分布式存储在 KubeSphere 中的实践_docker_36

创建工作负载使用存储卷:

Curve 分布式存储在 KubeSphere 中的实践_Curve_37

Curve 分布式存储在 KubeSphere 中的实践_K8s_38

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_39

Curve 分布式存储在 KubeSphere 中的实践_K8s_40

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_41

Curve 分布式存储在 KubeSphere 中的实践_K8s_42

进入容器终端:

Curve 分布式存储在 KubeSphere 中的实践_K8s_43

切换目录到 /data 并写入测试数据:

cd /data
mkdir curve
echo 1111 > curve.txt

验证查看 minio 数据:

Curve 分布式存储在 KubeSphere 中的实践_KubeSphere_44

标签:service,Curve,KubeSphere,curve,Up,host,curve1,root,分布式
From: https://blog.51cto.com/u_15533008/5986276

相关文章

  • m基于matlab的协作mimo分布式空时编码技术的仿真
    1.算法描述基于matlab的协作mimo分布式空时编码技术的仿真,包括规则LDPC级联D-STBC,ML,ZF,DFE均衡,Fincke-Pohst-MAP算法检测。将规则LDPC加入这个协作MIMO的D-STBC里,......
  • Curve 分布式存储在 KubeSphere 中的实践
    Curve介绍Curve是网易开发的现代存储系统,目前支持文件存储(CurveFS)和块存储(CurveBS)。现在它作为一个沙盒项目托管在CNCF。Curve是一个高性能、轻量级操作、本......
  • 分布式事务——两阶段提交和三阶段提交
    1.两阶段提交协议(2PC)1.1两阶段提交协议事务发起阶段:事务的发起者提出一个request(比如用户下单购买某个商品),要求其依赖的服务(事务的执行者)本地执行业务逻辑。执行成功本......
  • 分布式存储(ceph)技能图谱(持续更新)
    一下为个人结合其他人对分布式存储所需的技能进行总结,绘制成如下图谱,方便针对性学习。这里对分布式存储系统接触较多的是ceph,所以在分布式存储系统分支上偏向ceph的学习......
  • 如何解决分布式场景下的数据一致性问题?今天冰河的分布式锁服务插件mykit-lock开源啦
    大家好,我是冰河~~重磅消息:分布式锁插件mykit-lock正式开源开源地址:https://github.com/sunshinelyz/mykit-lock欢迎大家Star和Fork源码,并pr你牛逼哄哄的代码!框架简述mykit架......
  • 分布式存储系统 Ceph 实战操作
    目录一、概述二、cephadm工具的使用1)cephadm工具的介绍2)cephadm安装3)cephadm常用命令使用4)启用cephshell三、ceph命令使用1)添加新节点2)使用ceph安装软件3)主机操作......
  • MassTransit | 基于StateMachine实现Saga编排式分布式事务
    什么是状态机状态机作为一种程序开发范例,在实际的应用开发中有很多的应用场景,其中.NET中的async/await的核心底层实现就是基于状态机机制。状态机分为两种:有限状态机和......
  • SpringCloud分布式配置中心的搭建
    1.配置中心服务端的搭建创建模块cloud-config-center3344添加坐标<!--这是分布式的配置中心--><dependencies><!--需要引入配置中心的坐标--><dependency><......
  • 分布式 id 生成器(雪花算法)
    分布式id生成器(雪花算法)有时我们需要能够生成类似MySQL自增ID这样不断增大,同时又不会重复的id。以支持业务中的高并发场景。比较典型的,电商促销时,短时间内会有大量的订......
  • 分布式测试工具的调研对比
    1.背景当自动化用例累积的越来越多,回归自动化用例的时间越来越长。我们往往会选择使用多线程的方式来跑用例集,但是用例数量达到一定数量级(千级以上)后,在单台机器上使用多线程......