溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Redhat對象網(wǎng)關(guān)的示例分析

發(fā)布時間:2021-12-16 10:08:12 來源:億速云 閱讀:178 作者:小新 欄目:云計算

這篇文章主要介紹了Redhat對象網(wǎng)關(guān)的示例分析,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

##1.配置 ###更換默認的端口

###從apache遷移到civetweb

一個基于apache的配置類似以下形式:

[client.radosgw.gateway-node1]
host = {hostname}
keyring = /etc/ceph/ceph.client.radosgw.keyring
rgw socket path = ""
log file = /var/log/radosgw/client.radosgw.gateway-node1.log
rgw frontends = fastcgi socket_port=9000 socket_host=0.0.0.0
rgw print continue = false

修改成Civetweb,只需要移除:rgw_socket_path rgw_print_continue 得到:

[client.radosgw.gateway-node1]
host = {hostname}
keyring = /etc/ceph/ceph.client.radosgw.keyring
log file = /var/log/radosgw/client.radosgw.gateway-node1.log
rgw_frontends = civetweb port=80

重啟rgw:

systemctl restart ceph-radosgw.service

###Civetweb使用SSL 在v2.0前,基于HAProxy和keepalived上支持Civetweb SSL。在v2.0及以上版本,Civetweb支持OpenSSL庫來提供TLS(Transport Layer Security)

#1. 創(chuàng)建一個自簽名的認證

#生成rsa密鑰
openssl genrsa -des3 -out server.key 1024
	
#生成對應的csr文件
openssl req -new -key server.key -out server.csr	

cp server.key server.key.orig

#去除密鑰文件的保護密碼
openssl rsa -in server.key.orig -out server.key	

#自簽名
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt	

cp server.crt server.pem

cat server.key >> server.pem

注:在做第二步后common name(CN)的設置,可以設置成*.instance01.com

#2. 需要使用如下軟連接,否則會出錯,可在log_file文件中查看出錯信息

ln -s /lib64/libssl.so.1.0.1e /usr/lib64/libssl.so
ln -s /lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so

#3. 配置端口信息

[client.rgw.instance01]
host = ceph02
keyring = /var/lib/ceph/radosgw/ceph-rgw.instance01/keyring
log_file = /var/log/radosgw/ceph-client.rgw.instance01.log
rgw_dns_name = instance01.com
rgw thread pool size=1000
rgw_enable_static_website=true

rgw_frontends = "civetweb port=443s ssl_certificate=/etc/ceph/private/server.pem"
error_log_file=/var/log/radosgw/civetweb.error.log
access_log_file=/var/log/radosgw/civetweb.access.log

#5. 域名加入etc/hosts:

192.168.141.129 website02.instance01.com
192.168.141.129 website01.instance01.com

#6. 直接訪問https://website01.instance01.com:(有證書錯誤提示)

Redhat對象網(wǎng)關(guān)的示例分析

#7. 瀏覽器添加自定義的證書,如這里的server.crt,進行訪問

IE為例:

  • 設置->Internet選項->內(nèi)容->證書

  • 選擇“受信任的根證書頒發(fā)機構(gòu)”->導入

Redhat對象網(wǎng)關(guān)的示例分析

###導出命名空間到NFS-GANESHA NFS-GANESHA 是一個用戶空間服務器,支持NFSv2、NFSv3和NFSv4。它支持的運行平臺包括Linux,BSD variants和POSIX-compliant Unixes。

在v2.0發(fā)行版中,提供了通過NFS v4.1導出S3對象命名空間。

注:這個功能不常用,只支持S3

桶是NFS中的一個目錄,繼承S3慣例,支持創(chuàng)建文件或者文件夾。

##2. 管理(CLI)

每個osd上設置最大的pg數(shù),超出會有警告(默認300)

mon_pg_warn_max_per_osd = n

###存儲策略 ceph對象網(wǎng)關(guān)通過placement targets進行存儲桶對象的數(shù)據(jù),通過placement target來指定桶和對象的存儲池。如果不配置placement targets,桶和對象將會存到網(wǎng)關(guān)實例所在zone配置的存儲池中(使用默認的target和pools)。

存儲策略給對象網(wǎng)關(guān)提供了一個獲得存儲策略的權(quán)限,比如,指定特殊的存儲類型(SSDs,SAS drivers, SATA drivers)

  1. 創(chuàng)建一個新的pool.rgw.buckets.special,這個pool是一個特定的存儲策略。比如說,自定義的糾刪碼、具有一個特殊的crush ruleset、副本數(shù)或者pg數(shù)。

  2. 獲得region配置,導入到文件中

radosgw-admin region get > region.json
  1. 加入special-placement到placement_target下

{
	"name": "default",
	"api_name": "",
	"is_master": "true",
	"endpoints": [],
	"hostnames": [],
	"master_zone": "",
	"zones": [{
		"name": "default",
		"endpoints": [],
		"log_meta": "false",
		"log_data": "false",
		"bucket_index_max_shards": 5
	}],
	"placement_targets": [{
		"name": "default-placement",
		"tags": []
	}, {
		"name": "special-placement",
		"tags": []
	}],
	"default_placement": "default-placement"
}
  1. 獲得zone配置

radosgw-admin zone get > zone.json
  1. 編輯zone文件,加入placement policy key。

{
	"domain_root": ".rgw",
	"control_pool": ".rgw.control",
	"gc_pool": ".rgw.gc",
	"log_pool": ".log",
	"intent_log_pool": ".intent-log",
	"usage_log_pool": ".usage",
	"user_keys_pool": ".users",
	"user_email_pool": ".users.email",
	"user_swift_pool": ".users.swift",
	"user_uid_pool": ".users.uid",
	"system_key": {
		"access_key": "",
		"secret_key": ""
	},
	"placement_pools": [{
		"key": "default-placement",
		"val": {
			"index_pool": ".rgw.buckets.index",
			"data_pool": ".rgw.buckets",
			"data_extra_pool": ".rgw.buckets.extra"
		}
	}, {
		"key": "special-placement",
		"val": {
			"index_pool": ".rgw.buckets.index",
			"data_pool": ".rgw.buckets.special",
			"data_extra_pool": ".rgw.buckets.extra"
		}
	}]
}
  1. 寫入

radosgw-admin zone set < zone.json
  1. 更新region map

radosgw-admin regionmap update
  1. 重啟rgw

  2. 使用

curl -i http://10.0.0.1/swift/v1/TestContainer/file.txt -X PUT -H "X-Storage-Policy: special-placement" -H "X-Auth-Token: AUTH_rgwtxxxxxx"

###桶的分片

index_pool中存放了桶的索引數(shù)據(jù),默認是.rgw.bucket.index。用戶可能會存放很多對象(幾千萬甚至幾億對象)到單個bucket中,如果不用網(wǎng)關(guān)管理員接口去設置每個桶的最大配額,那桶的索引會遭受性能降級,當用戶存放大量的對象時。

當允許每個桶存儲大量的對象時,v1.3可以切片桶目錄,來解決性能瓶頸。 rgw_override_bucket_index_max_shards 以上參數(shù)是設置每個桶的最大切片數(shù)。默認是0(0代表關(guān)閉桶的索引切片)。

設置方式 可以在[global]標題下增加,然后重啟。

對于聯(lián)合配置,每個zone都有index_pool配置,可以針對不同區(qū)域的網(wǎng)關(guān)配置這個參數(shù)

radosgw-admin region get > region.json 打開json文件,對不同的zone編輯bucket_index_max_shards 保存重置:

radosgw-admin region set < region.json

更新region map:

radosgw-admin regionmap update --name client.rgw.ceph-client

###Realms 一個realm代表了一個全局的唯一的命名空間,這個命名空間由一個或者多個zonegroup,包含了一個或多個zone,zone里包含了桶,桶里包依次存放了對象。realm使得Ceph對象網(wǎng)關(guān)支持多命名空間和配置。

一個realm包含了period的概念(表示一個realm的有效期)。每個period及時地代表了zonegroup的狀態(tài)和zone的配置。每次需要對zonegroup或者zone做些改變的時候,需要更新周期,然后提交,

為了向后兼容v1.3或者更早期的版本,默認下,Ceph不會創(chuàng)建realm。然而,為了更好的體驗,redhat會在新集群上創(chuàng)建realm

###查找孤立對象 在一個健康的集群中,不應該存在任何孤立的對象,但是在一些情況下孤立對象可能發(fā)生:

  1. 在某個操作中rgw掛了,這可能使得對象變成孤立的。

  2. 未知的bug

步驟:

  • 創(chuàng)建一個新的log池

rados mkpool .log
  • 搜索孤立對象

radosgw-admin orphans find --pool=.rgw.buckets --job-id=abc123
  • 清理搜索出的孤立對象數(shù)據(jù)

radosgw-admin orphans finish --job-id=abc123

##3. 多數(shù)據(jù)中心

一個單zone的配置一般由一個zonegroup組成,這個zonegroup包含一個zone和一個或者多個rgw實例。在這些rgw中可以平衡網(wǎng)關(guān)請求。在單zone配置中,一般多網(wǎng)關(guān)實例指向了單個ceph集群。然而,redhat對于rgw支持幾個多站點配置項

  • 多zone 一個好的配置是由一個zonegroup和多zone組成,每個zone是由一個或者多個rgw組成。每個zone由自身的ceph集群支撐。在一個zone group中,多zone可以提供容災能力。2.0中每個zone是激活的,可以接受寫操作。為了能夠容災,多活zone可以為cdn起到一個基礎(chǔ)作用。

  • 多zone group 之前稱為region,ceph仍然支持多zone group,每個zone group由一個或多個zone組成。在相同的realm中,在同一個zone group中的對象共享一個全局命名空間,在跨zonegroup和zone中具有唯一的對象ID

  • 多realms 從2.0開始,支持realm的概念??梢允且粋€zonegroup或者多zonegroup和一個全局唯一的命名空間。多realm提供了支持許多配置和命名空間的能力。

Redhat對象網(wǎng)關(guān)的示例分析

從redhat v2.0和以上,可以配置雙活zone,意思是能夠?qū)懭氲椒侵鱶one。

多站點配置保存在一個容器中,叫realm,realm包含zone group, zone和period,period是由多個epoch組成,epoch是用來追蹤配置的變化。

這個指南上,假設分別有rgw1,rgw2,rgw3,rgw4。多站點配置要求一個主的zone group和一個主zone。另外,每個zone group要求一個主zone。zone groups可能有一個或多個非主zones

  • rgw1是主zone groups中的主zone,

  • rgw2是主zone groups中的非主zone

  • rgw3是非主zone groups的主zone

  • rgw4是非主zone groups的非主zone

###pools 對于zone的pool的名字{zone-name}.pool-name,比如,一個zone叫us-east??梢赃@樣命名pool:

  • .rgw.root

  • us-east.rgw.control

  • us-east.rgw.data.root

  • us-east.rgw.gc

  • us-east.rgw.log

  • us-east.rgw.intent-log

  • us-east.rgw.usage

  • us-east.rgw.users.keys

  • us-east.rgw.users.email

  • us-east.rgw.users.swift

  • us-east.rgw.users.uid

  • us-east.rgw.buckets.index

  • us-east.rgw.buckets.data

  • us-east.rgw.meta

###更新對象網(wǎng)關(guān) redhat推薦首先重啟主zonegroup和主zone。接著是非主

###配置一個主zone

  1. 創(chuàng)建一個realm 一個realm包含了zone groups和zones的多站點配置,也用來在所在的領(lǐng)域中實行一個全局唯一的命名空間。

radosgw-admin realm create --rgw-realm={realm-name} [--default]
  1. 創(chuàng)建一個主zone group

radosgw-admin zonegroup create --rgw-zonegroup={name} --endpoints={url} [--rgw-realm={realm-name}|--realm-id={realm-id}] --master --default
  1. 創(chuàng)建一個主zone

radosgw-admin zone create --rgw-zonegroup={zone-group-name} \
                            --rgw-zone={zone-name} \
                            --master --default \
                            --endpoints={http://fqdn}[,{http://fqdn}
  1. 創(chuàng)建一個系統(tǒng)用戶

  2. 更新period

  3. 更新ceph配置文件 在主zone上,增加rgw_zone配置項,以及zone的實例入口。

[client.rgw.{instance-name}]
...
rgw_zone={zone-name}
  1. 重啟rgw

###配置非主zone

  1. pull realm

radosgw-admin realm pull --url={url-to-master-zone-gateway} --access-key={access-key} --secret={secret}
  1. pull period

radosgw-admin period pull --url={url-to-master-zone-gateway} --access-key={access-key} --secret={secret}
  1. 創(chuàng)建一個非主zone 在v2.0或以上版本,所有的zone默認都是使用雙活配置:對象客戶端可以向任何一個zone寫數(shù)據(jù)。這個被寫入數(shù)據(jù)的zone將會復制所有的數(shù)據(jù)到同一個zone group的其他的zone。如果非主zone不接受寫操作,需要在創(chuàng)建zone時,使用參數(shù)--read-only標簽來創(chuàng)建主備配置,這個是在主zone和非主zone之間的,另外需要使用系統(tǒng)用戶的access key和secret key。

# radosgw-admin zone create --rgw-zonegroup={zone-group-name}\
                           --rgw-zone={zone-name} --endpoints={url} \
                           --access-key={system-key} --secret={secret}\
                           --endpoints=http://{fqdn}:80 \
                           [--read-only]
  1. 更新ceph配置文件 在非主zone的主機上更新ceph配置文件

[client.rgw.rgw2]
host = rgw2
rgw frontends = "civetweb port=80"
rgw_zone=us-west
  1. 更新period

  2. 啟動網(wǎng)關(guān)

###故障恢復

  1. 使得非主zone成為主zone,并且為的默認zone

# radosgw-admin zone modify --rgw-zone={zone-name} --master --default

默認情況下,ceph是雙活配置,如果集群是主備,非主zone是只讀的。移除--read-only狀態(tài)來獲得寫操作。

  1. 更新period生效

  2. 重啟rgw

如果原主zone已恢復

  1. 從恢復的zone中拉取當前的主zone的period。

  2. 使得恢復的zone成為主,并且是默認的zone

  3. 更新period

  4. 主zone上重啟rgw

  5. 如果非主zone需要成為只讀,則進行配置

  6. 更新period

  7. 在非主zone上重啟rgw

###從單數(shù)據(jù)中心遷移到多數(shù)據(jù)中心

  1. 創(chuàng)建realm,

  2. 重命名默認的zone和zonegroup

  3. 配置主zonegroup,加入到realm

radosgw-admin zonegroup modify --rgw-realm=<name> --rgw-zonegroup=<name> --endpoints http://<fqdn>:80 --master --default
  1. 配置主zone

# radosgw-admin zone modify --rgw-realm=<name> --rgw-zonegroup=<name> \
                            --rgw-zone=<name> --endpoints http://<fqdn>:80 \
                            --access-key=<access-key> --secret=<secret-key> \
                            --master --default
  1. 創(chuàng)建系統(tǒng)用戶

# radosgw-admin user create --uid=<user-id> --display-name="<display-name>"\
                            --access-key=<access-key> --secret=<secret-key> --system
  1. 提交更新配置

  2. 重啟rgw

感謝你能夠認真閱讀完這篇文章,希望小編分享的“Redhat對象網(wǎng)關(guān)的示例分析”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI