OpenStack swift到期对象支持

到期对象支持

swift-object-expirer 提供了定时删除对象的功能。Swift客户端将在对象的PUT或POST期间使用X-Delete-AtX-Delete-After头,集群将在指定的时间自动退出对该对象的服务,并在此后不久将该对象从系统中删除。

X-Delete-At 头采用整数形式的Unix Epoch时间戳;例如:1317070737 表示Mon Sep 26 20:58:57 2011 UTC

X-Delete-After 报头需要一个正整数秒数。接收请求的代理服务器将使用请求时间戳加上给定的值将此标头转换为X-Delete-At

如果X-Delete-AtX-Delete-After头都与请求一起发送,那么X-Delete-After头将优先。

当将过期对象添加到系统中时,对象服务器将在隐藏的.expiring_objects帐户中记录过期情况,以便 swift-object-expirer稍后处理。

通常,一个集群只需要运行 swift-object-expirer守护进程的一个实例。这并不完全是自动故障切换高可用性,但如果这个守护进程在几个小时内没有运行,就不会有任何实际问题。如果有人试图对过期但尚未删除的对象进行 GETHEAD操作,则这些对象仍将404 Not Found,稍后当守护进程重启时,这些对象将被删除。

默认情况下,swift-object-expirer守护进程将以1的并发性运行。增加此值可获得更多的并发性。对于特定的Swift集群,1的并发性可能不足以及时删除过期对象。

如果并发数超过1的单个进程不够用时,可以运行多个守护进程来完成工作的不同部分(详细信息请参阅示例配置文件)。

要将 swift-object-expirer作为多个进程运行,请将processes 设置为进程数(在配置文件中或在命令行中)。然后为每个部件运行一个流程。使用process 通过命令行或配置指定进程要完成的工作部分。因此,例如,如果想运行三个进程,则将processes 设置为3,并将process 设置为0、1和2来运行三个进程。如果使用多个进程,则有必要为工作的每个部分运行一个进程,否则该部分工作将无法完成。

默认情况下,守护进程查找两个不同的配置文件。当启动时,进程会在/etc/swift/object-server.conf 配置中搜索[object-expirer]部分。如果缺少该节或配置,它将查找并使用/etc/swift/object-expirer.conf 配置。后一种配置文件被认为已弃用,并被搜索以帮助集群升级。

升级影响:通用任务队列与传统队列

expirer守护进程将转向一种新的基于通用任务队列的设计,该设计将在所有对象服务器之间分配工作,因此只有在对象服务器配置中定义的expirer才能使用新系统。两个文件中的参数是相同的,除了对象服务器 [object-expirer]部分中的一个新选项dequeue_from_legacy ,当设置为True时,它将告诉expirer,除了使用新的任务排队系统来检查旧的(即将弃用的)队列之外。

扫描二维码关注公众号,回复: 16988504 查看本文章

说明

新的任务队列系统尚未完成。因此,dequeue_from_legacy设置为False的expirer当前将不起任何作用。

默认情况下dequeue_from_legacy将为False,从旧的过期队列迁移时需要显式设置为True

任何使用旧配置/etc/swift/object-expirer.conf 的expirer都不会使用新的通用任务队列。它将忽略dequeue_from_legacy,只检查旧队列。这意味着它将作为一个遗留的expirer运行。

为什么这很重要?如果当前在不是对象存储节点的节点上运行对象expirer,那么它们暂时仍能工作,但只能从旧队列中退出。当引入新的通用任务队列时,需要在对象服务器上运行expirer,以便可以删除添加的任何新对象。如果处于这种情况,可以安全地在object-server.conf中设置新的expirer部分,以处理新队列,并让旧的expirers在其他地方运行。

但是,如果旧的expirer在对象服务器(最常见的拓扑)上运行,那么将向所有对象服务器添加新的部分,以处理新的队列。为了保持检查旧队列的expirer数量相同,请选择与以前相同数量的节点,并仅在这些节点上启用 dequeue_from_legacy。还要注意,在这些节点上,需要保留传统的 processprocesses选项,以维护传统队列的并发级别。

说明

注意不要在太多的expirer上启用 dequeue_from_legacy ,因为所有传统任务都存储在一个隐藏帐户和相同的隐藏容器中。在大型集群上,可能会无意中使处理旧式expirer队列的账户/容器服务器过载。

Here is a quick sample of the object-expirer section required in the object-server.conf:

以下是object-server.conf中所需的 object-expirer 部分的快速示例:

[object-expirer]
# log_name = object-expirer
# log_facility = LOG_LOCAL0
# log_level = INFO
# log_address = /dev/log
#
interval = 300

# If this true, expirer execute tasks in legacy expirer task queue
dequeue_from_legacy = false

# processes can only be used in conjunction with `dequeue_from_legacy`.
# So this option is ignored if dequeue_from_legacy=false.
# processes is how many parts to divide the legacy work into, one part per
# process that will be doing the work
# processes set 0 means that a single legacy process will be doing all the work
# processes can also be specified on the command line and will override the
# config value
# processes = 0

# process can only be used in conjunction with `dequeue_from_legacy`.
# So this option is ignored if dequeue_from_legacy=false.
# process is which of the parts a particular legacy process will work on
# process can also be specified on the command line and will override the config
# value
# process is "zero based", if you want to use 3 processes, you should run
# processes with process set to 0, 1, and 2
# process = 0

report_interval = 300

# request_tries is the number of times the expirer's internal client will
# attempt any given request in the event of failure. The default is 3.
# request_tries = 3

# concurrency is the level of concurrency to use to do the work, this value
# must be set to at least 1
# concurrency = 1

# The expirer will re-attempt expiring if the source object is not available
# up to reclaim_age seconds before it gives up and deletes the entry in the
# queue.
# reclaim_age = 604800

为了完整起见,这里有一个传统的object-expirer.conf 文件的快速示例:

[DEFAULT]
# swift_dir = /etc/swift
# user = swift
# You can specify default log routing here if you want:
# log_name = swift
# log_facility = LOG_LOCAL0
# log_level = INFO

[object-expirer]
interval = 300

[pipeline:main]
pipeline = catch_errors cache proxy-server

[app:proxy-server]
use = egg:swift#proxy
# See proxy-server.conf-sample for options

[filter:cache]
use = egg:swift#memcache
# See proxy-server.conf-sample for options

[filter:catch_errors]
use = egg:swift#catch_errors
# See proxy-server.conf-sample for options

说明

运行旧版expirer时,守护进程需要在可以访问群集中所有后端服务器的计算机上运行,但不需要代理服务器或公共访问。守护进程将使用自己的内部代理代码实例来访问后端服务器。

猜你喜欢

转载自blog.csdn.net/QTM_Gitee/article/details/131181316