ceph 对象存储配置zone 同步

环境:ceph v10.2.3(jewel)、ubuntu16.04

                                     -----------us-east------rgw.node2

                                    |        (master zone)      (ceph-1 radosgw 实例)

                                    |

Movies----us----------

(realm)   (zonegroup)   |

                                     |

                                     -----------us-west------------rgw.node3

                                             ( secondary zone)     (ceph-2 radosgw 实例)

一、概念:      

    1、zone:可用区,有一个或多个对象网关实例组成。zone不可以跨集群,配置zone不同于其他典型配置,因为不需要在ceph.conf中配置。

    2、zonegroup:以前叫做“region”,有多个zone组成,一个zonegroup里面有一个master zone,在同一个zonegroup中的多个zone可以同步元数据和数据,提供灾难恢复能力。

    3、realm:代表一个唯一的命名空间,有一个或多个zonegroup组成。在同一个realm中的不同zonegroup只能同步元数据。在realm中有period的概念,表示zonegroup的配置状态,修改zonegroup,必须更新period。

二、在ceph-1集群上配置master zone

      1、创建realm

      radosgw-admin realm create --rgw-realm=movies --default

     如果没有指定default 后面在配置zone 和zonegroup的时候要指定realm

      2、创建master zonegroup

      radosgw-admin zonegroup create --rgw-zonegroup=us --endpoints=http://10.33.0.13:80  --master --default

      3、创建master zone

      radosgw-admin zone create  --rgw-zone=us-east --master --default --endpoints=10.33.0.13:80

      4、创建一个system账户用于和us-west zone同步

       radosgw-admin user create --uid="synchronization-user" --display-name="Synchronization User" --system

     5、用创建system账户产生的access 和secret更新zone配置

     radosgw-admin zone modify --rgw-zone=us-east --access-key={access-key} --secret={secret}

    6、更新period

    radosgw-admin period update --commit

     7、配置ceph.conf

     [client.rgw.node2]

          host = node2

          rgw frontends = "civetweb port=80"

          rgw_zone=us-east

    8、搭建radosgw

       见https://my.oschina.net/u/2326998/blog/838611

三、在ceph-2集群上配置secondary zone

       1、从master zone拉取realm

       radosgw-admin realm pull --url=http://10.33.0.13:80 --access-key={access-key} --secret={secret}

       note:这里的access key 和secret是master zone上system 账户的access key和secret

      2、拉取period

      radosgw-admin period pull --url=http://10.33.0.13:80 --access-key={access-key} --secret={secret}

     note:这里的access key和secret 同上

     3、创建secondary zone

       radosgw-admin zone create --rgw-zonegroup=us --rgw-zone=us-west \

                            --access-key={system-key} --secret={secret} \

                            --endpoints=http://10.33.0.40:80

       note:这里的access key和secret是在master zone中system账户的创建的。

    4、更新period

       radosgw-admin period update --commit

       note:如果出现认证错误,重启master zone的实例服务

    5、配置ceph.conf

       [client.rgw.rgw2]

        host = node3

        rgw frontends = "civetweb port=80"

        rgw_zone=us-west

    6、搭建radosgw

     见https://my.oschina.net/u/2326998/blog/838611

四、验证zone之间数据同步

     1、在secondary zone节点执行

        radosgw-admin sync status

              realm 89daf245-1a59-44d4-b3f9-d8b141dfb226 (movies)

      zonegroup 398ed754-1d07-497d-ad35-84ec99c36f21 (us)

           zone b5752408-e416-4b9c-919e-924d624ea290 (us-west)

  metadata sync syncing

                full sync: 0/4 shards

                metadata is caught up with master

                incremental sync: 4/4 shards

      data sync source: 73dbf160-d57d-41b5-9870-97fe7e7e7c1a (us-east)

                        syncing

                        full sync: 0/8 shards

                        incremental sync: 8/8 shards

                        data is caught up with source

  

  可以看到数据和元数据都已同步

   2、在master zone节点上创建用户

      radosgw-admin user create --uid="testuser" --display-name="First User"

   3、  用s3客户端 创建桶,并put 对象

**注意 在secondary zone节点上也要创建相同的用户才会看到创建的桶,和上传的对象**。

猜你喜欢

转载自my.oschina.net/u/2326998/blog/1036740