Chinaunix首页 | 论坛 | 博客
  • 博客访问: 143008
  • 博文数量: 31
  • 博客积分: 2075
  • 博客等级: 大尉
  • 技术积分: 340
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-29 10:06
文章分类

全部博文(31)

文章存档

2017年(3)

2014年(1)

2013年(1)

2011年(9)

2010年(14)

2009年(3)

我的朋友

分类: 云计算

2017-07-05 11:26:05

目  录
第1章 引言    
1.1 文档说明    
1.2 其他说明    
第2章 分层存储概述    
第3章 创建池    
3.1 设置存储池    
3.2 设置缓存池    
第4章 创建缓存层    
第5章 配置缓存层    
5.1 目标的大小和类型    
5.2 缓存大小    
5.2.1 相对大小    
5.2.2 绝对大小    
5.3 缓存周期    
第6章 清除缓存层    
6.1 删除只读模式的缓冲层    
6.2 删除回写模式的缓冲层    
 
第1章 引言
1.1 文档说明
本文对Ceph的存储分层进行介绍;存储分层也叫cache分层、缓存分层;主要作用是提高Ceph存储性能。这也是redhat最近重点宣传的概念之一。

1.2 其他说明
参考文档
 
第2章 分层存储概述
缓存层(A cache tier)为Ceph客户端提供更好的I/O性能,而数据存储在存储层(a backing storage tier)。用相对快速/昂贵的设备(比如SSD)创建pool作为缓存层(A cache tier),用纠删码池或者相对慢速/便宜的设备创建pool作为经济的存储池。Ceph(The Ceph objecter)负责对象存放的位置,分层代理(the tiering agent)确定什么时候把数据对象从缓存层(the cache)存储到存储层(the backing storage tier)。因此对Ceph客户端而言缓存层(the cache tier)和存储层(the backing storage tier)是完全透明的。
 
缓存分层代理(the cache tiering agent)负责在缓存层(the cache tier)与存储层(the backing storage tier)间数据的自动迁移。然而,管理员(admin)有权利配置数据如何迁移。如下有两种典型的方案:
回写模式(Writeback Mode): 当管理员配置分层存储为回写模式(writeback mode)时,Ceph客户端写数据到缓存层(the cache tier)并收到缓存层(the cache tier)的相应。此时,写入缓存层(the cache tier)的数据被迁移到存储层(the storage tier)并刷新缓存层(the cache tier)。从感念上讲,缓存层(the cache tier)在存储层(the backing storage tier)的“上边”覆盖了一层。当客户端需要读写存储层(the storage tier)中的数据时,缓存分层代理(the cache tiering agent)把数据迁移到缓存层(the cache tier),然后发送到Ceph客户端。然后,Ceph客户端可以使用缓存层(the cache tier)执行I/O,直到使用完毕。这种方式针对经常变动的数据(比如 照片/视频编辑、事务数据等)。
只读模式(Read-only Mode): 当管理员(admin)配置分层存储为只读模式(readonly mode)时,客户端写数据到存储层(the backing tier,回写模式的读写都在缓存层)。读数据的时候,Ceph从存储层(the backing tier)拷贝需要的数据到缓存层 (the cache tier)。根据定义好的规则,旧数据从缓存层(the cache tier)删除掉。这种方式针对不经常变动的数据。(比如 提交到社交网站上的照片和视频、DNA数据、X射线映像等), 因为数据是从缓存池中读取的,因此数据是弱一致性的,可能包含过时的数据。不要为经常变动的数据配置只读模式(readonly mode).
既然所有的客户端都能使用缓存分层(cache tiering),那么对于Ceph块存储、对象存储、文件存储、本地绑定,提高I/O性能都是可行的。

第3章 创建池
配置存储分层(cache tiering),需要有2个池(pool)。一个用作存储池(the backing storage pool),另一个用作缓存池(the cache pool).
3.1 设置存储池
设置一个存储池(backing storage pool)通常涉及两种典型情况之一
标准存储(Standard Storage): 在这种情况下,pool把数据的多个副本存储在Ceph集群(the Ceph Storage Cluster)中。
纠删码存储(Erasure Coding): 在这种情况下,pool用纠删码方式存储数据,数据存储节约空间,只是有一点性能损耗。
在标准存储(the standard storage)情况下,你可以创建CRUSH规则来设置参数failure domain (比如 osd, host, chassis, rack, row 等)。在CRUSH规则中,所有的存储设备大小、速度(包括RPM和吞吐量)、类型一样时,Ceph OSD进程运行最佳。创建了CRUSH规则后,就可以创建存储池(backing storage pool)了。
在纠删码存储(the erasure coding)情况下,创建池的参数会自动生成合适的规则。 
在后续的例子中,我们假设已经创建了一个存储池(the backing storage pool),名字是cold-storage。
3.2 设置缓存池
设置一个缓存池(a cache pool)的步骤和标准存储池(the standard storage pool)的过程一样,但有如下不同: 缓存层(the cache tier)的驱动器是专有的高性能驱动器,运行在自己的服务器上,并有自己的Crush规则。当我们创建Crush规则时,要考虑有高性能驱动器的主机,而删除低性能驱动器的主机。
在后续的例子中,我们假设已经创建了一个缓存池(the cache pool),名字是hot-storage,一个存储池(the backing pool),名字是cold-storage。

第4章 创建缓存层
创建缓存层(a cache tier)就是把存储池(a backing storage pool)和缓冲池(a cache pool)关联起来。
ceph osd tier add {storagepool} {cachepool}
例子
ceph osd tier add cold-storage hot-storage
设置缓存模式(the cache mode),执行如下命令:
ceph osd tier cache-mode {cachepool} {cache-mode}
例子:
ceph osd tier cache-mode hot-storage writeback
回写模式缓存层是在存储层(the backing storage tier)上添加了一层,所以要求添加一步:你必须直接打通客户端从存储池(the storage pool)到缓冲池(the cache pool)的交互。设置客户端直接和缓冲池(the cache pool)交互,执行如下命令:
ceph osd tier set-overlay {storagepool} {cachepool}
例子:
ceph osd tier set-overlay cold-storage hot-storage

第5章 配置缓存层
存储分层(Cache tiers)有几个配置选项。配置这些参数,你可以用如下方法:
ceph osd pool set {cachepool} {key} {value}
5.1 目标的大小和类型
Ceph产品的存储分层用Bloom Filter作为hit_set_type类型;Bloom filter 是由 Howard Bloom 在 1970 年提出的二进制向量数据结构,它具有很好的空间和时间效率,被用来检测一个元素是不是集合中的一个成员。
ceph osd pool set {cachepool} hit_set_type bloom
例子:
ceph osd pool set hot-storage hit_set_type bloom
The hit_set_count and hit_set_period define how much time each HitSet should cover, and how many such HitSets to store. Currently there is minimal benefit for hit_set_count > 1 since the agent does not yet act intelligently on that information.
ceph osd pool set {cachepool} hit_set_count 1
ceph osd pool set {cachepool} hit_set_period 3600
ceph osd pool set {cachepool} target_max_bytes 1000000000000
Binning accesses over time allows Ceph to determine whether a Ceph client accessed an object at least once, or more than once over a time period (“age” vs “temperature”).
注:周期越长,计数越高,ceph-osd 用的内存越多。特别是,当代理主动刷新或清除缓存对象,所有hitsets被加载到RAM。
5.2 缓存大小
分层存储代理(The cache tiering agent)执行2个主要的函数:
刷新(Flushing): 代理识别变动的对象,并把这些变动的对象转存到存储池(the storage pool)中长期保存;
清除(Evicting): 代理识别未变动的对象,并从缓存中删除最近没有使用的对象。
5.2.1 相对大小
缓存代理(The cache tiering agent)刷新/清除对象和缓冲池大小有关。当缓冲池(the cache pool)达到一定比例的变动对象时,缓存代理(the cache tiering agent)会刷新数据,把它们存储到存储池(the storage pool)中。设置cache_target_dirty_ratio执行如下命令:
ceph osd pool set {cachepool} cache_target_dirty_ratio {0.0..1.0}
例如,设置值为0.4,当变动的对象达到缓冲池(the cache pool)容量的40%时,就刷新缓存:
ceph osd pool set hot-storage cache_target_dirty_ratio 0.4
当缓冲池(the cache pool)达到一定百分百的容量时,缓存代理(the cache tiering agent)会清除一些对象来维持一定空闲的存储空间。设置cache_target_full_ratio执行如下命令:
ceph osd pool set {cachepool} cache_target_full_ratio {0.0..1.0}
例如,设置值为0.8,当达到缓冲池(the cache pool)容量的80%时,就会清除缓存中一些未变动的数据:
ceph osd pool set hot-storage cache_target_full_ratio 0.8
5.2.2 绝对大小
缓存代理(The cache tiering agent)能根据总字节数和总对象数刷新/清除对象。设置字节数的最大值,可以执行如下命令:
ceph osd pool set {cachepool} target_max_bytes {#bytes}
例如, 1TB时刷新/清楚,执行如下语句:
ceph osd pool set hot-storage target_max_bytes 1000000000000
设置最大对象数,执行如下语句:
ceph osd pool set {cachepool} target_max_objects {#objects}
例如,1M时刷新/清楚,执行如下语句:
ceph osd pool set hot-storage target_max_objects 1000000
注:如果限制条件你都配置了,当任何一个阈值被触发时,缓存代理(the cache tiering agent)就刷新/清除数据。
5.3 缓存周期
你可以配置对象的最小周期,达到这个周期后,缓存代理(the cache tiering agent)刷新最近变动的对象到存储池(the backing storage pool)中:
ceph osd pool set {cachepool} cache_min_flush_age {#seconds}
例如,刷新变动10分钟的数据,执行如下语句:
ceph osd pool set hot-storage cache_min_flush_age 600
你可以配置对象的最小周期,达到这个周期后,缓存代理(the cache tiering agent)从缓存中清除未变动的对象:
ceph osd pool {cache-tier} cache_min_evict_age {#seconds}
例如,清除30分钟未使用的对象,执行如下语句:
ceph osd pool set hot-storage cache_min_evict_age 1800

第6章 清除缓存层
缓存模式(回写模式writeback cache,只读模式read-only cache)不同,删除缓存层的方法也不同。
6.1 删除只读模式的缓冲层
因为只读模式的缓冲池中没有变动的数据,所以你可以删除缓存池中的数据,不用担心数据丢失。
1.    修改缓存模式为none废除缓存
ceph osd tier cache-mode {cachepool} none
例子:
ceph osd tier cache-mode hot-storage none
2.    从存储池(the backing pool)上移除缓冲池(the cache pool)
ceph osd tier remove {storagepool} {cachepool}
例子:
ceph osd tier remove cold-storage hot-storage
6.2 删除回写模式的缓冲层
因为回写模式(writeback cache)有变动的数据,所以在废除和删除前,首先确保最近修改的数据不丢失。
1.    修改缓存模式为forward,使新增和修改的对象刷新到存储池(the backing storage pool)中。
ceph osd tier cache-mode {cachepool} forward
例子:
ceph osd tier cache-mode hot-storage forward
2.    确认缓冲池(the cache pool)已经刷新,这将花费几分钟时间:
rados -p {cachepool} ls
如果缓冲池(the cache pool)中还有对象,你可以手动刷新他们:
rados -p {cachepool} cache-flush-evict-all
3.    删除覆盖层,使客户端不再直接和缓存交互。
ceph osd tier remove-overlay {storagetier}
例子:
ceph osd tier remove-overlay cold-storage
4.    最后,从存储池(the backing storage pool)上移除缓冲池(the cache tier pool):
ceph osd tier remove {storagepool} {cachepool}
例子:
ceph osd tier remove cold-storage hot-storage
第7章 附录
阅读(3187) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~