0031-00000023

更新时间:
复制 MD 格式

问题描述

数据复制规则中Action参数取值不合法。

问题原因

您发起了PutBucketReplication请求,但是数据复制规则中Action参数取值不合法。

问题示例

以下请求示例中Action参数取值为SET,取值不合法。

POST /?replication&comp=add HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com 
Content-Type: application/xml
Content-Length: 186
Date: Thu, 24 Sep 2015 15:39:12 GMT
Authorization: OSS qn6q**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<ReplicationConfiguration>
  <Rule>  
     <RTC>
        <Status>enabled</Status>
     </RTC>
     <PrefixSet>
        <Prefix>source1</Prefix>
        <Prefix>video</Prefix>
     </PrefixSet>
     <Action>SET</Action>
     <Destination>
        <Bucket>destbucket</Bucket>
        <Location>oss-cn-beijing</Location>
        <TransferType>oss_acc</TransferType>
     </Destination>
     <HistoricalObjectReplication>enabled</HistoricalObjectReplication>
      <SyncRole>aliyunramrole</SyncRole>
      <SourceSelectionCriteria>
         <SseKmsEncryptedObjects>
           <Status>Enabled</Status>
         </SseKmsEncryptedObjects>
      </SourceSelectionCriteria>
      <EncryptionConfiguration>
           <ReplicaKmsKeyID>c4d49f85-ee30-426b-a5ed-95e9139d****</ReplicaKmsKeyID>
      </EncryptionConfiguration>     
  </Rule>
</ReplicationConfiguration>

解决方案

Action参数用于指定可以复制到目标Bucket的操作。如果配置了Action,则新写入的数据和历史数据的同步都会遵循Action指定的复制操作。

Action允许以下操作类型,您可以指定一项或多项。

  • ALL(默认值):表示PUT、DELETE、ABORT操作均会被同步到目标Bucket。

    重要

    该策略下新增、更新和删除Object都会被复制到目标Bucket。通过这种方式,确保了数据的一致性,适用于需要共享和访问同一数据集的多用户或应用程序环境。但是配置该策略后,当手动删除或者通过生命周期自动删除源Bucket内的Object时,目标Bucket也会删除对应的Object,且Object删除后无法恢复。

  • PUT:表示被同步到目标Bucket的写入操作,包括PutObject、PostObject、AppendObject、CopyObject、PutObjectACL、InitiateMultipartUpload、UploadPart、UploadPartCopy、CompleteMultipartUpload。

    重要

    该策略下仅新增和更新的Object会被复制,而删除操作不会影响目标Bucket。通过这种方式,可以有效防止因源Bucket手动删除、通过生命周期自动删除的行为导致目标Bucket数据丢失的问题。

正确请求示例如下:

POST /?replication&comp=add HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com 
Content-Type: application/xml
Content-Length: 186
Date: Thu, 17 Apr 2025 15:39:12 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=content-length,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
<?xml version="1.0" encoding="UTF-8"?>
<ReplicationConfiguration>
  <Rule>  
     <RTC>
        <Status>enabled</Status>
     </RTC>
     <PrefixSet>
        <Prefix>source1</Prefix>
        <Prefix>video</Prefix>
     </PrefixSet>
     <Action>PUT</Action>
     <Destination>
        <Bucket>destbucket</Bucket>
        <Location>oss-cn-beijing</Location>
        <TransferType>oss_acc</TransferType>
     </Destination>
     <HistoricalObjectReplication>enabled</HistoricalObjectReplication>
      <SyncRole>aliyunramrole</SyncRole>
      <SourceSelectionCriteria>
         <SseKmsEncryptedObjects>
           <Status>Enabled</Status>
         </SseKmsEncryptedObjects>
      </SourceSelectionCriteria>
      <EncryptionConfiguration>
           <ReplicaKmsKeyID>c4d49f85-ee30-426b-a5ed-95e9139d****</ReplicaKmsKeyID>
      </EncryptionConfiguration>
      <UserTaggings>
           <FilterType>OR</FilterType>
           <UserTagging>
               <Key>env</Key>
               <Value>test</Value>
           </UserTagging>
           <UserTagging>
               <Key>dept</Key>
               <Value>dev</Value>
           </UserTagging>
      </UserTaggings>
  </Rule>
</ReplicationConfiguration>

相关文档

PutBucketReplication