RADOSGW Storage Pool Yapilandirma, Optimizasyon ve Testi

BulutWiki sitesinden
Şuraya atla: kullan, ara

Obje Depolama Pool Ayarlari - Depolama Politikasi

Örnek parola olarak "blabla" kullanılmıştır. Kendi kurulumunuzuzda belirleyeceğiniz parolayı kullanınız.

Herhangi bir yapilandirma yapilmadiginda radosgw uzerinden kullanici tarafinda atilan obje veya bucketlar default yer olan default.rgw.buckets.data adinda pool uzerinde tutulmaktadir. Bunun index bilgileri ise default.rgw.buckets.index pool uzerinde tutulmaktadir. Kullanici vb meta verileri, log'lar ise ayri yapilandirilmis default.rgw.meta ve default.rgw.log pool'lari uzerinde tutulmaktadir.

Asagidaki komutla default olusturulan pool ve detaylari bulunabilir.

# ceph osd pool ls detail
pool 1 '.rgw.root' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 195 owner 18446744073709551615 flags hashpspool stripe_width 0 application rgw
pool 2 'default.rgw.control' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 199 owner 18446744073709551615 flags hashpspool stripe_width 0 application rgw
pool 3 'default.rgw.meta' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 201 owner 18446744073709551615 flags hashpspool stripe_width 0 application rgw
pool 4 'default.rgw.log' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 203 owner 18446744073709551615 flags hashpspool stripe_width 0 application rgw 
pool 5 'default.rgw.buckets.index' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 206 owner 18446744073709551615 flags hashpspool stripe_width 0 application rgw
pool 6 'default.rgw.buckets.data' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 256 pgp_num 256 last_change 209 owner 18446744073709551615 flags hashpspool stripe_width 0 application rgw

Bune gore default olarak ayarlanan her bir pool 3 replikasi ve her birinin 256 pg sayisi bulunmaktadir. (CEPH kurulumu yapilirken ceph.conf icerisinde default pg sayisi 256 set edildiginde bu pool'lar bu sekilde yapilandirilmistir)

Bu nedenle farkli kullanicilar uzerinden gelecek veriler ayni ozellikte ki pool uzerinde kaydedilecektir, Ornegin B3LAB projesi icin olusturulan kullanicinin verileri de kendimiz icin olsuturulacak GLANCE ve NextCloud projeleri icin olusturulacak kullanicilar da ayni pool uzerinde verileri tutacaklardir. Bu pek istenen bir durum degildir, cunku degisen kapasiteye ve kullanima bagli ozel olusturulmus pool uzerinde verilerini tutmasi daha dogru bir yaklasim olacaktir. index, metadata ve log'lar default pool uzerinde tutulabilir, ancak veriler icin ayri bir data pool tutmak icin bu dokuman hazirlanmistir.

NOT: Her bir objeye ait veriler indexlenmektedir. Eger tum objeleri listeleme gibi bir gereksinim bulunmuyorsa bu durumda her bir objeye ait index bilgisini tutmak gereksizdir. Bunun icin asagidaki baslik izlenebilir. https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/3/html-single/object_gateway_guide_for_red_hat_enterprise_linux/#indexless_buckets

Ayrica; eger milyonlarca obje olacakse ve surekli listeleme gibi isler yapilacaksa bu durumda index'in yer aldigi pool aysi SSD'lerden olusan bir pool uzerine kurgulanabilir. Bucket index sharding islemi ile de oldukca performans kazanci elde edilebilir. https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/3/html-single/object_gateway_guide_for_red_hat_enterprise_linux/#bucket_sharding

AMAC:
1- Dosyalarin daha performansli listelenebilmesi icin SSD'ler uzerinde yer alan index pool ve objelerin tutulacagi yuksek pg sayili, 3 replikali data pool olusturmak.
    index pool: .rgw.buckets.ssd_index, 256 pg, 3 replika, 512GB kota
    data pool: .rgw.buckets.sharedfile_data, 1024 pg, 3 replika, 30TB kota
2- Ayni ozellikte isterleri olan farkli iki proje icin (SAFIR ve NextCloud) ayri kullanici olusturup bu pool'lar uzerinde islem yapabilmesini saglamak
3- Her bir kullaniciya ayri kotalar tanimlamak

POOL OLUSTURMA

Onceden hazirlanmis 2 farkli crush rule var, bunlardan biri sadece nVme ssd disklerin yer aldigi fast, digeri ise sadece SATA Hdd'lerin yer aldigi replicated_rule. Pool'lar bu chrush liste gore olusturuldu.

# ceph osd crush rule list
replicated_rule
fast
# ceph osd crush class ls-osd ssd
48
49
50
51
ceph osd pool create .rgw.buckets.ssd_index 256 256
ceph osd pool set .rgw.buckets.ssd_index crush_rule fast
ceph osd pool set-quota .rgw.buckets.ssd_index max_bytes 512GB
ceph osd pool application enable .rgw.buckets.ssd_index rgw
ceph osd pool create .rgw.buckets.sharedfile_data 1024 1024
ceph osd pool set .rgw.buckets.sharedfile_data crush_rule replicated_rule
ceph osd pool set-quota .rgw.buckets.sharedfile_data max_bytes 30TB
ceph osd pool application enable .rgw.buckets.sharedfile_data rgw
ceph osd pool ls detail
.... 
....
pool 8 '.rgw.buckets.ssd_index' replicated size 3 min_size 3 crush_rule 1 object_hash rjenkins pg_num 256 pgp_num 256 last_change 268 flags hashpspool stripe_width 0
pool 9 '.rgw.buckets.sharedfile_data' replicated size 3 min_size 3 crush_rule 0 object_hash rjenkins pg_num 1024 pgp_num 1024 last_change 271 flags hashpspool stripe_width 0


Placement Target

CEPH Object Gateway, kullanicinin verisini tutarken iliskilendirilmis placement target bilgisine bakar, herhangi bir ayar yapilmadiysa default olan zone altinda yer alan default-placement bilgisine gore de islem yapar. Az once olusturdugumuz sekilde pool'lar uzerinde spesifik islem yapabilmek icin ayni zone altinda yeni bir placement grup olusturup pool bilgilerini ayri ayri burada set etmemiz gerekecektir.

# radosgw-admin zonegroup --rgw-zonegroup=default get
{
   "id": "f252a88f-d3b2-4566-815a-",
   "name": "default",
   "api_name": "",
   "is_master": "true",
   "endpoints": [],
   "hostnames": [],
   "hostnames_s3website": [],
   "master_zone": "813cf61b-a412-4130-8eb4-",
   "zones": [
       {
           "id": "813cf61b-a412-4130-8eb4-",
           "name": "default",
           "endpoints": [],
           "log_meta": "false",
           "log_data": "false",
           "bucket_index_max_shards": 0,
           "read_only": "false",
           "tier_type": "",
           "sync_from_all": "true",
           "sync_from": [],
           "redirect_zone": ""
       }
   ],
   "placement_targets": [
       {
           "name": "default-placement",
           "tags": []
       }
   ],
   "default_placement": "default-placement",
   "realm_id": ""

}

sharedfile-placement adinda yeni bir placement target olusturmak icin zonegroup.json dosyasi asagidaki sekilde guncellenip calistirilir.

{
   "id": "f252a88f-d3b2-4566-815a-",
   "name": "default",
   "api_name": "",
   "is_master": "true",
   "endpoints": [],
   "hostnames": [],
   "hostnames_s3website": [],
   "master_zone": "813cf61b-a412-4130-8eb4-",
   "zones": [
       {
           "id": "813cf61b-a412-4130-8eb4-",
           "name": "default",
           "endpoints": [],
           "log_meta": "false",
           "log_data": "false",
           "bucket_index_max_shards": 0,
           "read_only": "false",
           "tier_type": "",
           "sync_from_all": "true",
           "sync_from": [],
           "redirect_zone": ""
       }
   ],
   "placement_targets": [
       {
           "name": "default-placement",
           "tags": []
       },
       {
           "name": "sharedfile-placement",
           "tags": []
       }
   ],
   "default_placement": "default-placement",
   "realm_id": ""
}
# radosgw-admin zonegroup set < zonegroup.json

Daha sonra zone yapilandirma dosyasini alip data ve index icin olusturulan bu pool'lar set edilecek sekilde placement target guncellenir.

# sudo radosgw-admin zone get
{
   "id": "813cf61b-a412-4130-8eb4-",
   "name": "default",
   "domain_root": "default.rgw.meta:root",
   "control_pool": "default.rgw.control",
   "gc_pool": "default.rgw.log:gc",
   "lc_pool": "default.rgw.log:lc",
   "log_pool": "default.rgw.log",
   "intent_log_pool": "default.rgw.log:intent",
   "usage_log_pool": "default.rgw.log:usage",
   "reshard_pool": "default.rgw.log:reshard",
   "user_keys_pool": "default.rgw.meta:users.keys",
   "user_email_pool": "default.rgw.meta:users.email",
   "user_swift_pool": "default.rgw.meta:users.swift",
   "user_uid_pool": "default.rgw.meta:users.uid",
   "otp_pool": "default.rgw.otp",
   "system_key": {
       "access_key": "",
       "secret_key": ""
   },
   "placement_pools": [
       {
           "key": "default-placement",
           "val": {
               "index_pool": "default.rgw.buckets.index",
               "data_pool": "default.rgw.buckets.data",
               "data_extra_pool": "default.rgw.buckets.non-ec",
               "index_type": 0,
               "compression": ""
           }
       }
   ],
   "metadata_heap": "",
   "realm_id": ""
}
sudo radosgw-admin zone get > zone.json
sudo vi zone.json
{
   "id": "813cf61b-a412-4130-8eb4-",
   "name": "default",
   "domain_root": "default.rgw.meta:root",
   "control_pool": "default.rgw.control",
   "gc_pool": "default.rgw.log:gc",
   "lc_pool": "default.rgw.log:lc",
   "log_pool": "default.rgw.log",
   "intent_log_pool": "default.rgw.log:intent",
   "usage_log_pool": "default.rgw.log:usage",
   "reshard_pool": "default.rgw.log:reshard",
   "user_keys_pool": "default.rgw.meta:users.keys",
   "user_email_pool": "default.rgw.meta:users.email",
   "user_swift_pool": "default.rgw.meta:users.swift",
   "user_uid_pool": "default.rgw.meta:users.uid",
   "otp_pool": "default.rgw.otp",
   "system_key": {
       "access_key": "",
       "secret_key": ""
   },
   "placement_pools": [
       {
           "key": "default-placement",
           "val": {
               "index_pool": "default.rgw.buckets.index",
               "data_pool": "default.rgw.buckets.data",
               "data_extra_pool": "default.rgw.buckets.non-ec",
               "index_type": 0,
               "compression": ""
           }
       },
       {
           "key": "sharedfile-placement",
           "val": {
               "index_pool": ".rgw.buckets.ssd_index",
               "data_pool": ".rgw.buckets.sharedfile_data",
               "data_extra_pool": ".rgw.buckets.sharedfile_data.non-ec",
               "index_type": 0,
               "compression": ""
           }
       }
   ],
   "metadata_heap": "",
   "realm_id": ""
}
radosgw-admin zone set < zone.json
radosgw-admin period update --commit

Bucket Optimizasyon

Pool uzerinde kayitli bucket uzerinde tutulan tum objelerin index bilgisi SSD disk uzerinde tutacak sekilde yapilandirilan .rgw.buckets.ssd_index poolu uzerinde durmaktadir. Buna ek olarak performansi artirmak icin bucket sharding denilen her bir bucket icin tutulacak maksimim obje sayisini belirleyen bir ayar girilmesi gerekmektedir. Tek bir bucket uzerinde milyonlarca kayit tutmak performansi cok dusurecektir.

rgw_override_bucket_index_max_shards parametresi bucket basina tutulacak en fazla shard bilgisini gostermektedir. Default ayari 0'dir, yani bucket uzerinde sinirsiz sayida obje tutacak sekildedir. Bu sayinin belirlenmesi icin asagidaki formul onerilmektedir.

number of objects expected in a bucket / 100,000

Biz olusturdugumuz pool icin 10.000 kullanici ve her birinin 100 dosyasi olacak sekilde on gordugumuzde toplam obje sayisi 1 milyon olmakta, bu durumda bu sayi ise 10 olacaktir. ceph.conf dosyasina asagidaki satir eklenir, ve radosgw servisi restart edilir.

rgw_override_bucket_index_max_shards = 10
systemctl restart ceph-radosgw.service

Kullanici Olusturma ve Yetkilendirme

Son olarak RADOSGW uzerinde ayarlari yapilmis bu pool'lar uzerinde veri tutacak kullanicilarin olusturulmasinda. RadosGW, hem S3 uyumlu (user) hem de swift api uyumlu (subuser) kullanici olusturmaya izin veriyor. Dolayisiyla S3 arayuzu icin access ve secret key gerekirken swift arayuzu icin secret key yeterli olabilmektedir. Burada swift api uyumlu subuser olusturulup yetkilendirilecektir. Kullanicilar full yetkiye sahip olacak sekilde olusturulacaktir. (Alternatifer; read, write, readwrite)

SAFIR kullanicisi icin:
radosgw-admin user create --uid="safir" --display-name="B3LAB SAFIR Grubu"
radosgw-admin subuser create --uid=safir --subuser=safir:swift --access=full
NextCloud kullanicisi icin:
radosgw-admin user create --uid="nextcloud" --display-name="ULAKBIM NextCloud Servisi"
radosgw-admin subuser create --uid=nextcloud --subuser=nextcloud:swift --access=full
# radosgw-admin user info --uid=nextcloud
{
   "user_id": "nextcloud",
   "display_name": "ULAKBIM NextCloud Servisi",
   "email": "",
   "suspended": 0,
   "max_buckets": 1000,
   "auid": 0,
   "subusers": [
       {
           "id": "nextcloud:swift",
           "permissions": "full-control"
       }
   ],
   "keys": [
       {
           "user": "nextcloud",
           "access_key": "blabla",
           "secret_key": "blabla"
       }
   ],
   "swift_keys": [
       {
           "user": "nextcloud:swift",
           "secret_key": "blabla"
       }
   ],
   "caps": [],
   "op_mask": "read, write, delete",
   "default_placement": "",
   "placement_tags": [],
   "bucket_quota": {
       "enabled": false,
       "check_on_raw": false,
       "max_size": -1,
       "max_size_kb": 0,
       "max_objects": -1
   },
   "user_quota": {
       "enabled": false,
       "check_on_raw": false,
       "max_size": -1,
       "max_size_kb": 0,
       "max_objects": -1
   },
   "temp_url_keys": [],
   "type": "rgw",
   "mfa_ids": []

}


komutu ile kullaniciya ait bilgiler gelmektedir. Bu kullanicilar, hem S3 ile hem de Swift arayuzu ile konusabilecek key'lere sahiptirler.

Dilenirse bu kullanicilar bir sure kullanima kapatilip tekrar asagidaki komutla acilabilir.

# radosgw-admin user suspend --uid=nextcloud
# radosgw-admin user enable --uid=nextcloud

Kullanici bilgilerine bakildiginda herhangi bir kota bulunmamaktadir. Her ne kadar pool bazinda bir kota tanimlamasi yapildiysa da kullanici bazinda da bir kota tanimlamasi yapilmasi gerekmektedir. CEPH uzerinde kota tanimlamasi kullanici veya kullanicinin sahip oldugu bucket bazinda yapilabilmektedir. Default'ta her ikisi disable durumundadir. Burada kullanici bazli bir kota tanimlanacaktir.

# radosgw-admin quota set --quota-scope=user --uid=safir --max-objects=1000000 --max-size=30TB
# radosgw-admin quota set --quota-scope=user --uid=nextcloud --max-objects=100000 --max-size=3TB

son olarak kullanici bazli kota tanimlamayi etkinlestirmek gerekmektedir.

# radosgw-admin quota enable --quota-scope=user --uid=nextcloud
# radosgw-admin quota enable --quota-scope=user --uid=safir
"bucket_quota": {
       "enabled": false,
       "check_on_raw": false,
       "max_size": -1,
       "max_size_kb": 0,
       "max_objects": -1
   },
   "user_quota": {
       "enabled": true,
       "check_on_raw": false,
       "max_size": 32985348833280,
       "max_size_kb": 32212254720,
       "max_objects": 1000000
   },


Kullanici ile Iliskilendirme

Olusturulan bu kullanicilarin sadece yeni olusturdugumuz placement_target dolayisiyla pool uzerinde default islem yapabilmeleri icin metadata verilerinde guncelleme yapmak gerekir. Kullanici bilgisine baktigimizda default_placement bos gelmektedir. Bunu sharedfile_placement ile guncellemek icin:

# radosgw-admin metadata get user:nextcloud > user.json

user.json dosyasinda default_placement karsisina sharedfile-placement eklenir.

   "default_placement": "sharedfile-placement",
# radosgw-admin metadata put user:nextcloud < user.json ile metadata guncellenir.

Benzer islem diger kullanici icinde yapilir.

# radosgw-admin metadata get user:safir > user.json
# radosgw-admin metadata put user:safir < user.json


TEST islemleri

Pek cok farkli yontemle bucket olusturulup icerisine dosya atilabilir. Bunlardan birkaci ile asagida ornek olmasi acisindan komutlar verilmistir.

S3 arayuzu uzerinden python boto kutuphanesi kullanilarak o kullanicinin access ve secret keyleri ile bucket olusturulabilir. Ornegin;

# cat cephtestv2.py
import boto
import boto.s3.connection
access_key = 'blabla'
secret_key = 'blabla'
conn = boto.connect_s3(
          aws_access_key_id = access_key,
             aws_secret_access_key = secret_key,
                host = 'gwmon', port =7480,is_secure=False, calling_format = boto.s3.connection.OrdinaryCallingFormat(),)
bucket = conn.create_bucket('test-bucket')
for bucket in conn.get_all_buckets():
      print "{name} {created}".format(name = bucket.name,created = bucket.creation_date,)

Boylece test-bucket adinda bir bucket olusturulmus olunur. Bu bucket altina dosya atmak icinse SWIFT arayuzu uzerinden secret_key ile dosya gonderilebilir.

# swift -A http://gwmon:7480/auth/1.0 -U nextcloud:swift -K blabla upload test-bucket cephtest.py

Bu bucket altindaki dosyalari listelemek icinse

# swift -A http://gwmon:7480/auth/1.0 -U nextcloud:swift -K blabla list test-bucket komutu kullanilir.

Bucket ve dosyanin nereye yazildigi onemlidir. Bucket adi verilerek kullanimina ve hangi placement target kullandigina bakilabilir. Ornegin;

# radosgw-admin bucket stats --bucket test-bucket
{
   "bucket": "test-bucket",
   "zonegroup": "f252a88f-d3b2-4566-815a-c975ab4e2d65",
   "placement_rule": "sharedfile-placement",
   "explicit_placement": {
       "data_pool": "",
       "data_extra_pool": "",
       "index_pool": ""
   },
   "id": "813cf61b-a412-4130-8eb4-bc8bacb0f752.494548.2",
   "marker": "813cf61b-a412-4130-8eb4-bc8bacb0f752.494548.2",
   "index_type": "Normal",
   "owner": "nextcloud",
   "ver": "0#2,1#1,2#1,3#2,4#1,5#1,6#1,7#1,8#1,9#1",
   "master_ver": "0#0,1#0,2#0,3#0,4#0,5#0,6#0,7#0,8#0,9#0",
   "mtime": "2018-09-17 15:51:55.909340",
   "max_marker": "0#,1#,2#,3#,4#,5#,6#,7#,8#,9#",
   "usage": {
       "rgw.main": {
           "size": 1102,
           "size_actual": 8192,
           "size_utilized": 1102,
           "size_kb": 2,
           "size_kb_actual": 8,
           "size_kb_utilized": 2,
           "num_objects": 2
       }
   },
   "bucket_quota": {
       "enabled": false,
       "check_on_raw": true,
       "max_size": -1,
       "max_size_kb": 0,
       "max_objects": -1
   }
}

placement_rule bizim set etmis oldugumuz yerde olusturulmustur. Icerisinde ise 2 obje bulunmaktadir. Diger taraftan garanti olmasi acisindan her bir pool kullanimina bakilirsa 2 objenin yeni olusturmus oldugumuz pool uzerinde oldugu gozlemlenir.

#sudo ceph df detail
GLOBAL:
   SIZE        AVAIL       RAW USED     %RAW USED     OBJECTS
   351 TiB     351 TiB       54 GiB          0.01        257 
POOLS:
   NAME                             ID     QUOTA OBJECTS     QUOTA BYTES     USED        %USED     MAX AVAIL     OBJECTS     DIRTY     READ        WRITE       RAW USED
   .rgw.root                        1      N/A               N/A             1.3 KiB         0       111 TiB           4        4      1.8 KiB        10 B      4.0 KiB
   default.rgw.control              2      N/A               N/A                 0 B         0       111 TiB           8        8          0 B         0 B          0 B
   default.rgw.meta                 3      N/A               N/A             3.9 KiB         0       111 TiB          21       21        522 B       153 B       12 KiB
   default.rgw.log                  4      N/A               N/A                 0 B         0       111 TiB         207      207      2.1 MiB     1.4 MiB          0 B
   default.rgw.buckets.index        5      N/A               N/A                 0 B         0       111 TiB           4        4         79 B        33 B          0 B
   default.rgw.buckets.data         6      N/A               N/A               516 B         0       111 TiB           1        1          0 B        10 B      1.5 KiB
   .rgw.buckets.ssd_index           8      N/A               512 GiB             0 B         0       471 GiB          10       10        214 B        56 B          0 B
   .rgw.buckets.sharedfile_data     9      N/A               30 TiB          1.1 KiB         0       111 TiB           2        2          0 B        20 B      3.2 KiB