分布式块存储介绍_第1页
分布式块存储介绍_第2页
分布式块存储介绍_第3页
分布式块存储介绍_第4页
分布式块存储介绍_第5页
已阅读5页,还剩39页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、分布式块存储介绍2022/8/21分布式块存储概念:采用分布式技术:多存储节点;操作: 块;2022/8/22概念1 分布式分布式系统:硬件或软件组件分布在网络计算机上且通过消息传递进行通信和动作协调的协调。特征:并发性异构性可伸缩性透明性2022/8/23概念2 块存储块设备:各类磁盘;块层:linux存储虚拟化RAIDQemu 虚拟盘2022/8/24概念3 网络存储NAS(Network Attached Storage-网络附加存储)即将存储设备通过标准的网络拓扑结构(例如以太网),连接到一群计算机上。NAS 是部件级的存储方法,它的重点在于帮助工作组和部门级机构解决迅速增加存储容量的

2、需求。DAS(Direct Attached Storage-直接附加存储)是指将存储设备通过SCSI 接口或光纤通道直接连接到一台计算机上。DAS 产品包括存储器件和集成在一起的简易服务器,可用于实现涉及文件存取及管理的所有功能。SAN(Storage Area Network-存储局域网络)通过光纤通道连接到一群计算机上。在该网络中提供了多主机连接,但并非通过标准的网络拓扑。SAN 专注于企业级存储的特有问题,主要用于存储量大的工作环境。2022/8/252022/8/262022/8/27实例分析开源分布式块存储sheepdog开源的分布式块存储:2009年由日本NTT实验室MORITA

3、 KAZUTAKA 创建的专为虚拟机(QEMU/KVM虚拟机)提供块存储,但并不完全拘泥于虚拟机,可提供一个虚拟的块设备无单节点失效:如果一个节点失败,其数据可由其他节点得到。低运维开销:零配置;对内核文件系统无特性假设;节点变化无须人工参与即可恢复;数据动态均衡负载;支持虚拟机的热迁移、镜像快照、模版&克隆、集群快照;计算节点和数据节点混合模式线性扩展,支持上千级别节点2022/8/28Sheepdog cluster2022/8/29整体架构2022/8/2102022/8/211整体架构Sheepdog是一个分布式存储系统,它为sheepdog客户端(QEMU块设备驱动)提供一个obje

4、ct storage(对象存储),(类似于简单的key-value接口)。object storage :sheepdog并不是一般通用的文件系统。Sheepdog守护线程(sheep)为QEMU创建一个分布式的对象存储系统。对象可以存放在存储系统中。对象是大小可伸缩的,并且有一个全局唯一标识。我们通过指定对象标识来进行读写删除等操作。对象存储包括gateway和对象管理。Gateway:gateway接受QEMU发送来的I/O请求(object id, offset, length, operation type),并根据一致性哈希算法来计算目标节点,然后将请求发送至目标节点。Object

5、manager:object manager 接受到gateway发送来的I/O请求,并对它的磁盘上进行读写操作。Cluster manager:它管理node membership(节点之间的关系)例如,检测失败或添加的节点和通知节点的变化,并且管理一些保持节点一致性的操作,例如vdi创建以及快照等。目前我们采用corosync cluster engine作为cluster manager。QEMU block driver:它将一个VM镜像分成固定大小的object(4MB)并通过gateway将它们存放在object storage。2022/8/212节点内部2022/8/213Ob

6、ject Storage每个对象都有一个全局唯一的64位标识,对象可以存在多个节点上。QEMU block driver并不关心对象的存储位置。对象存储系统负责管理对象的存储位置。Object 类型:data object、vdi object(虚拟盘镜像)、vmstate object(运行的虚拟机的虚拟机状态镜像,用来做快照)、vdi attr object(每个虚拟盘的属性,属性为key-value风格,类似于常用文件系统的扩展属性)Object ID 规范:0 - 31 (32 bits): object type specific space32 - 55 (24 bits): vd

7、i id 对VDI名计算hash值得到56 - 59 ( 4 bits): reserved60 - 63 ( 4 bits): object type identifierobject typethe usage of lower 32 bitsdata objectthe index number in the virtual disk imagevdi objectnot used (filled with zero)vmstate objectthe index number in the vm state imagevdi attr objectsthe hash value of

8、the key name2022/8/214Object 格式:Data object:虚拟盘镜像的chunkVdi object:struct sheepdog_inode char nameSD_MAX_VDI_LEN; /* the name of this VDI*/ char tagSD_MAX_VDI_TAG_LEN; /* the snapshot tag name */ uint64_t ctime; /* creation time of this VDI */ uint64_t snap_ctime; /* the time snapshot is taken */ uin

9、t64_t vm_clock_nsec; /* vm clock (used for live snapshot) */ uint64_t vdi_size; /* the size of VDI */ uint64_t vm_state_size; /* the size of vm state (used for live snapshot) */ uint16_t copy_policy; /* reserved */ uint8_t nr_copies; /* the number of object redundancy */ uint8_t block_size_shift; /*

10、 info about the size of the data object */ uint32_t snap_id; /* the snapshot id */ uint32_t vdi_id; /* the vdi id */ uint32_t parent_vdi_id; /* the parent snapshot vdi id of this VDI */ uint32_t child_vdi_idMAX_CHILDREN; /* the children VDIs of this VDI */ uint32_t data_vdi_idMAX_DATA_OBJS; /* the d

11、ata object IDs this VDI contains*/ ;Vmstate object:chunkVdi attr object: The first SD_MAX_VDI_ATTR_KEY_LEN bytes (256 bytes) is the key name of this attribute. The rest of the object is the value of this attribute.2022/8/215Read-only/writable objectsWritable:只允许一个VM读写此对象而其他VMs不能访问;Read-only objects:

12、可读但不能写这是指虚拟机不能同一时间共享同一卷(volume)。这避免了写写冲突,简化了sheepdog系统的实现。2022/8/216Gateway Where to store objects consistent hashing:增删节点不会对对象映射产生改变;I/O 负载平衡Replication 写冲突Write I/O flow 所有副本必须成功更新Read I/O flow 对象一致性:节点失效造成副本不一致。Retrying I/O requests epoch:历史版本号2022/8/217Object managerPath name rule:存放路径/store_dir

13、/obj/epoch number/object IDWrite journaling 写日志 如果sheep 守护线程在写操作的时候失败,则只有部分对象会更新。1. create a journal file /store_dir/journal/epoch/vdi object id2. write a data to the journal file first3. write a data to the vdi object4. remove the journal file2022/8/218Cluster manager一般sheepdog客户端独立访问他们的镜像。而且一些VDI操

14、作(克隆、创建VDI)必须唯一的执行,因为这些操作更新全局信息。Corosync cluster engine2022/8/219QEMU Block DriverSheepdog卷被分成4MB的data objects。只有被写过的才分配。Open:QEMU块设备驱动通过gateway读一个vdi对象bdrv_open()Read/wrte:根据请求扇区的偏移和大小计算data object id,然后将请求发送到gateway。如果块设备驱动发送写请求至某个不属于当前VDI的数据对象,则块设备驱动发送Cow请求来分配一个新的数据对象写快照vdi:对QEMU附加一个快照VDI,当块设备驱动第

15、一次将写请求发送到块设备vdi时,则块设备驱动创建一个写的writeable VDI作为快照的孩子,然后发送请求到这个新的VDI。2022/8/220VDI 操作Lookupcalculate a vdi id from the hash value of the vdi namecalculate a vdi object id from the vdi idsend a read request to the vdi objectif the vdi is not the requested one, increment the vdi id and retry to send a rea

16、d request快照和克隆1. read a target VDI2. create a new VDI which has the same content as the target object VDI 3. set the parent_vdi_id of the new VDI to the target VDI id 4. set the child_vdi_id of the target VDI to the new VDI id 5. set the snap_ctime of the target VDI to the current time then, the new

17、 vdi becomes the current vdi object.Deletereclaiming of unused data objects is not invoked until all relevant VDI objects (all relative snapshot VDIs and cloned VDIs) are deleted。After all relevant VDIs are deleted, Sheepdog deletes all data objects of the VDIs, and set the null string to the name o

18、f the vdi objects.2022/8/221Object recoveryEpoch:node membership的历史信息,路径为/store_dir/epoch/epoch number每个文件包含此epoch的节点信息表(IP address, port number, the number of virtual nodes)Recovery process1. Receive all stored object IDs from all nodes2. Calculate which objects to have3. Create the object IDs list

19、 file /store_dir/obj/the current epoch/list4. Send a read requests to get objects whose ID is in the list file. The requests are sent to the node which had the object at the previous epoch.5. Store the object to the current epoch directory2022/8/222Protocol Sheepdog请求头包含固定大小的header(48位)和可变的数据段。Heade

20、r包括协议版本,操作代码,epoch号,数据长度等。2022/8/223Between sheep 和 qemu2022/8/224between sheep and collieoperation codedescriptionSD_OP_DEL_VDIDelete the requested VDI.SD_OP_GET_NODE_LISTGet the list of sheepdog nodes.SD_OP_GET_VM_LISTNot used now.SD_OP_MAKE_FSCreate a sheepdog cluster.SD_OP_SHUTDOWNStop a sheepdo

21、g cluster.SD_OP_STAT_SHEEPGet information about local disk usage.SD_OP_STAT_CLUSTERGet information about the sheepdog clusterSD_OP_KILL_NODEAbort the sheep daemon.SD_OP_GET_VDI_ATTRGet a vdi attr object id.2022/8/225between sheepsoperation codedescriptionSD_OP_REMOVE_OBJRemoves the object.SD_OP_GET_

22、OBJ_LISTGet the list of object IDs which are stored on the target node.2022/8/226Sheepdog线程模型两种上下文 主线程上下文 接收请求,唤醒处理函数 group_handler(),处理节点变化和广播消息 client_handler(),处理IO和数据恢复、迁移等请求 工作线程上下文 12个,其中4个专门处理IO请求,4个专门处理 gateway请求2022/8/227逻辑处理模型两种上下文,主线程同工作线程无竞争的全局变量将请求处理逻辑中需要串行化的逻辑放到主线程中,可以并行的逻辑放到工作线程中 多线程、

23、无锁的节点变化处理逻辑、数据恢复、迁移逻辑 复杂的分布式算法简单化,根除死锁的可能性 容易检验算法的正确性2022/8/228节点管理Sheepdog只提供节点变化后的处理机制 节点变化的检测依赖外部实现 消息机制依赖外部实现 节点变化消息 节点广播消息支持两种模型 全对称(依赖corosync,运行于sheepdog的地址空间) 缺点:规模小10002022/8/229节点变化的处理节点加入时,内部逻辑需要一个特殊的master节点来处理新节点是否可以加入 集群主动或被动关闭后,重新启动集群,也是节点变化的处理过程每个节点都有一致的成员视图目前可以处理多个节点同时离开或者加入的事件(比如同时

24、有A,B加入,C离开)2022/8/230节点加入节点加入 分成两个阶段 1.新加入的节点发送加入请求 2. master节点检查系统状态,核查能否加入,如果能,则广播一个新的视图,各个节点更新视图和状态3. 新节点加入时,在节点1和2之间master节点离开,mastership自动转移,不会影响系统运行 新的master节点继续检查状态以及广播视图2022/8/231节点离开节点离开 外部的节点检测机制发送成员变化视图 各个节点更新视图和状态当多个节点变化事件发生时,外部检测机制确保离开和加入的消息的顺序一致 剩下的节点和新加入的节点看见一致的视图 比如集群有(A, B, C, D)四个节

25、点,E在加入的同时D因事故离开,则(A, B, C, E)四个节点都将看到最终如下的视图 -member(A, B, C, E), join(E), left(D) 产生一个还是多个视图变化消息跟外部检测机制相关2022/8/232虚拟节点与一致性哈希Sheepdog采用虚拟节点和一致性哈希存储块对象 节点和数据都放到哈希环上 一个物理节点分散成多个节点均匀到环上2022/8/233节点变化的影响节点加入,数据需要重新均衡 -虚拟节点和一致性哈希算法保证 数据均匀分布在各个物理节点 很大程度上减少数据迁移节点离开,数据拷贝需要恢复,保证数据冗余度 -通过节点变化的历史信息恢复数据2022/8/

26、234数据管理虚拟机镜像被切分为4M大小的对象对象稀疏存储每个对象由唯一的64位数字索引每个对象有多个拷贝负值到节点上2022/8/235数据的读写由于一个镜像只有一个虚拟机操作,所以更新拷贝时可以并行执行写操作读一个对象,可以从任何一个拷贝中返回2022/8/236拷贝修复分布式系统中,拷贝的修复通常有两种 急修复:收到节点离开消息,立即进行修复 优点:简单 缺点:当离开的节点回来之后,造成带宽的浪费 懒修复: 优点:能区分节点的临时错误和永久错误,减少带宽的浪费 缺点:增加算法逻辑复杂度 -如何处理关于临时离开节点的数据请求2022/8/237拷贝修复逻辑对象的时间轨迹 -用epoch来记

27、录每个发生节点变化的新视图 -通过epoch来区分不同时间的数据对象 -每个对象都有一个以epoch为点的时间轨迹 init: (A, B, C), 3个拷贝 2022/8/238Sheepdog面临的主要问题多个节点变化: 节点加入时,有其他节点当掉 扩容,缩容等数据平衡,节点存储权重: 虚拟节点和一致性哈希减少恢复时间和数据迁移节点变化时对虚拟机IO的影响 本地缓存模式,几乎无影响 无本地缓存,需要等待对象恢复大规模节点的扩展性 目标是上几千节点的规模 内部算法的扩展性 专门的节点控制集群2022/8/239安装sheepdog /collie/sheepdog/wiki/Getting-

28、StartedRequirementsOne or more x86-64 machines.Linux kernel 2.6.27 or laterglibc 2.9 or laterThe corosync and corosync lib package.QEMU 0.13 or laterCompile-time dependenciesGNU Autotoolspkg-configcorosync devel packagegit (when compiling from source repo)liburcuoptional:fuse-devel (for sheepfs)2022

29、/8/240InstallCompile or install the Corosync packagesFor debian package based systems:$ sudo aptitude install corosync libcorosync-dev For RPM package based systems:$ sudo yum install corosynclib-develDownload, build and install QEMU with Sheepdog support$ git clone git:/qemu.git $ cd qemu $ ./confi

30、gure $ sudo make install $ cd .2022/8/241Download, build and install the Sheepdog server and command line tools$ git clone git:/collie/sheepdog.git $ cd sheepdog $ ./autogen.sh $ ./configure $ sudo make install $ cd .2022/8/242Usage Setup Sheepdog$ sudo /etc/init.d/sheepdog start Or;$ sudo sheep /var/lib/sheepdog1. F

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论