zoukankan      html  css  js  c++  java
  • ceph学习之pool

    pool是ceph存储数据时的逻辑分区,它起到namespace的作用。其他分布式存储系统,比如Mogilefs、Couchbase、Swift都有pool的概念,只是叫法不同。每个pool包含一定数量的PG,PG里的对象被映射到不同的OSD上,因此pool是分布到整个集群的。

    除了隔离数据,我们也可以分别对不同的POOL设置不同的优化策略,比如副本数、数据清洗次数、数据块及对象大小等。

    查看POOL

    查看pool有多种方式:

    [root@mon1 ~]# rados lspools
    rbd
    testpool
    testpool2
    [root@mon1 ~]# ceph osd lspools
    0 rbd,1 testpool,2 testpool2,
    [root@mon1 ~]# ceph osd dump |grep pool
    pool 0 'rbd' replicated size 3 min_size 2 crush_ruleset 0 object_hash rjenkins pg_num 64 pgp_num 64 last_change 1 flags hashpspool stripe_width 0
    pool 1 'testpool' replicated size 2 min_size 2 crush_ruleset 0 object_hash rjenkins pg_num 128 pgp_num 128 last_change 20 flags hashpspool stripe_width 0
    pool 2 'testpool2' replicated size 2 min_size 2 crush_ruleset 0 object_hash rjenkins pg_num 128 pgp_num 128 last_change 22 flags hashpspool crash_replay_interval 45 stripe_width 0
    [root@mon1 ~]#

    毫无疑问ceph osd dump输出的信息最详尽,包括pool ID、副本数量、CRUSH规则集、PG和PGP数量等

     创建POOL

    通常在创建pool之前,需要覆盖默认的pg_num,官方推荐:

    • 若少于5个OSD, 设置pg_num为128。
    • 5~10个OSD,设置pg_num为512。
    • 10~50个OSD,设置pg_num为4096。
    • 超过50个OSD,可以参考pgcalc计算。
    [root@mon1 ~]# ceph osd pool create pool1 64
    pool 'pool1' created
    [root@mon1 ~]#

    创建pool时要设置pg_num

    调整POOL副本

    [root@mon1 ~]# ceph osd pool set pool1 size 2
    set pool 3 size to 2
    [root@mon1 ~]#

    删除POOL

    [root@mon1 ~]# ceph osd pool delete pool1
    Error EPERM: WARNING: this will *PERMANENTLY DESTROY* all data stored in pool pool1.  If you are *ABSOLUTELY CERTAIN* that is what you want, pass the pool name *twice*, followed by --yes-i-really-really-mean-it.
    [root@mon1 ~]# ceph osd pool delete pool1 pool1  --yes-i-really-really-mean-it
    pool 'pool1' removed

    note:删除pool时,pool名字要输入两次同时要加入--yes-i-really-really-mean-it参数

    设置POOL配额

    [root@mon1 ~]# ceph osd pool set-quota pool1 max_objects 100           #最大100个对象
    set-quota max_objects = 100 for pool pool1
    [root@mon1 ~]# ceph osd pool set-quota pool1 max_bytes $((10 * 1024 * 1024 * 1024))    #容量大小最大为10G
    set-quota max_bytes = 10737418240 for pool pool1 

    重命名POOL

    [root@mon1 ~]# ceph osd pool rename pool1 pool2
    pool 'pool1' renamed to 'pool2'
    [root@mon1 ~]#

    查看POOL状态信息

    [root@mon1 ~]# rados df
    pool name                 KB      objects       clones     degraded      unfound           rd        rd KB           wr        wr KB
    pool2                      0            0            0            0            0            0            0            0            0
    rbd                        0            0            0            0            0            0            0            0            0
    testpool                   0            0            0            0            0            0            0            0            0
    testpool2                  0            0            0            0            0            0            0            0            0
      total used          118152            0
      total avail       47033916
      total space       47152068
    [root@mon1 ~]#

    创建快照

    ceph支持对整个pool创建快照(和Openstack Cinder一致性组区别?),作用于这个pool的所有对象。但注意ceph有两种pool模式:

    • Pool Snapshot,我们即将使用的模式。创建一个新的pool时,默认也是这种模式。
    • Self Managed Snapsoht,用户管理的snapshot,这个用户指的是librbd,也就是说,如果在pool创建了rbd实例就自动转化为这种模式。

    这两种模式是相互排斥,只能使用其中一个。因此,如果pool中曾经创建了rbd对象(即使当前删除了所有的image实例)就不能再对这个pool做快照了。反之,如果对一个pool做了快照,就不能创建rbd image了。

    [root@mon1 ~]# ceph osd pool mksnap pool2 pool2_snap
    created pool pool2 snap pool2_snap
    [root@mon1 ~]#

    删除快照

    [root@mon1 ~]# ceph osd pool rmsnap
                                         #remove snapshot <snap> from <pool>
    [root@mon1 ~]# ceph osd pool rmsnap pool2 pool2_snap
    removed pool pool2 snap pool2_snap
    [root@mon1 ~]#
  • 相关阅读:
    http和https
    openstack
    openstack安全问题
    openstack优势
    java多线程实现方式
    python多进程实现的几种方式
    Java 在提取url 生成图片以及正则表达式
    idea 生成 可执行文件
    dw cs6 支持高分辨率
    svchost.exe 大量占用的问题
  • 原文地址:https://www.cnblogs.com/netmouser/p/6878885.html
Copyright © 2011-2022 走看看