All Products
Search
Document Center

Object Storage Service:Create a zone-redundant storage (ZRS) bucket

Last Updated:Mar 01, 2026

Object Storage Service (OSS) zone-redundant storage (ZRS) distributes redundant data copies across multiple zones within the same region, delivering 99.9999999999% (12 nines) data durability. If a zone becomes unavailable, your data remains accessible from the remaining zones, providing data center-level disaster recovery without manual intervention.

Usage notes

  • ZRS is available in select regions. For supported regions, data durability, and service availability, see Storage redundancy.

  • ZRS costs more than locally redundant storage (LRS). For pricing details, see OSS Pricing.

  • Once ZRS is enabled for a bucket, it cannot be disabled.

Procedure

Use the OSS console

  1. Log on to the OSS console.

  2. In the left-side navigation pane, click Buckets, then click Create Bucket.

  3. In the Create Bucket panel, set Redundancy Type to ZRS (Recommended), then configure the remaining parameters as needed. For more information about the parameters, see Create a bucket.

Use OSS SDKs

The following examples set the data redundancy type to ZRS when creating a bucket. For additional SDK examples, see SDK overview.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.*;

public class Demo {

    public static void main(String[] args) throws Exception {
        // Set yourEndpoint to the Endpoint of the region where the bucket is located.
        // For example, if the bucket is located in the China (Hangzhou) region,
        // set Endpoint to https://oss-cn-hangzhou.aliyuncs.com.
        String endpoint = "yourEndpoint";
        // Obtain access credentials from environment variables.
        // Make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
        // environment variables are configured.
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the bucket name.
        String bucketName = "examplebucket";
        // Specify the resource group ID. If you do not specify a resource group ID,
        // the bucket is added to the default resource group.
        //String rsId = "rg-aek27tc****";
        // Specify the region where the bucket is located. For example, if the bucket
        // is located in the China (Hangzhou) region, set Region to cn-hangzhou.
        String region = "cn-hangzhou";

        // Create an OSSClient instance.
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
        .endpoint(endpoint)
        .credentialsProvider(credentialsProvider)
        .clientConfiguration(clientBuilderConfiguration)
        .region(region)
        .build();

        try {
            // Create a bucket and enable the hierarchical namespace feature.
            CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName).withHnsStatus(HnsStatus.Enabled);
            // Set the storage class to Standard.
            createBucketRequest.setStorageClass(StorageClass.Standard);
            // Set the data redundancy type to ZRS. The default is LRS.
            createBucketRequest.setDataRedundancyType(DataRedundancyType.ZRS);
            // Set the ACL to public-read. The default ACL is private.
            createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
            // Assign the bucket to a resource group. Supported in regions
            // that support resource groups.
            //createBucketRequest.setResourceGroupId(rsId);


            // Create the bucket.
            ossClient.createBucket(createBucketRequest);
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}
const OSS = require('ali-oss');

const client = new OSS({
  // Specify the region in which the bucket is located. For example,
  // if the bucket is located in the China (Hangzhou) region, set the region
  // to oss-cn-hangzhou.
  region: 'yourregion',
  // Obtain access credentials from environment variables. Make sure that
  // you have configured environment variables OSS_ACCESS_KEY_ID and
  // OSS_ACCESS_KEY_SECRET.
  accessKeyId: process.env.OSS_ACCESS_KEY_ID,
  accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
  authorizationV4: true,
  // Specify the name of the bucket.
  bucket: 'yourBucketName',
});

// Create the bucket.
async function putBucket() {
  try {
    const options = {
      storageClass: 'Standard', // Default storage class is Standard.
      acl: 'private', // Default ACL is private.
      dataRedundancyType: 'ZRS' // Default redundancy type is LRS. Set to 'ZRS' for zone-redundant storage.
    }
    // Specify the name of the bucket.
    const result = await client.putBucket('examplebucket', options);
    console.log(result);
  } catch (err) {
    console.log(err);
  }
}

putBucket();
import argparse
import alibabacloud_oss_v2 as oss

# Create a command-line argument parser.
parser = argparse.ArgumentParser(description="put bucket sample")
# Specify the region where the bucket is located. Required.
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
# Specify the bucket name. Required.
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
# Specify the domain name that other services can use to access OSS. Optional.
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS')

def main():
    args = parser.parse_args()

    # Load credentials from environment variables.
    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    # Load the default SDK configuration and set the credentials provider.
    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    # Create an OSS client.
    client = oss.Client(cfg)

    # Create a bucket with the storage class set to Standard
    # and the data redundancy type set to ZRS.
    result = client.put_bucket(oss.PutBucketRequest(
        bucket=args.bucket,
        create_bucket_configuration=oss.CreateBucketConfiguration(
            storage_class='Standard',
           data_redundancy_type='ZRS'
        )
    ))
    # Print the status code and request ID.
    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}'
    )


if __name__ == "__main__":
    main()
using Aliyun.OSS;
using Aliyun.OSS.Common;

// Set yourEndpoint to the Endpoint of the region where the bucket is located.
// For example, if the bucket is in the China (Hangzhou) region,
// set the Endpoint to https://oss-cn-hangzhou.aliyuncs.com.
var endpoint = "yourEndpoint";
// Obtain access credentials from environment variables. Make sure that the
// OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
var accessKeyId = Environment.GetEnvironmentVariable("OSS_ACCESS_KEY_ID");
var accessKeySecret = Environment.GetEnvironmentVariable("OSS_ACCESS_KEY_SECRET");
// Specify the bucket name.
var bucketName = "examplebucket";
// Specify the region where the bucket is located. For example, if the bucket
// is in the China (Hangzhou) region, set the region to cn-hangzhou.
const string region = "cn-hangzhou";

// Create a ClientConfiguration instance and modify the default parameters as needed.
var conf = new ClientConfiguration();

// Use Signature V4.
conf.SignatureVersion = SignatureVersion.V4;

// Create an OssClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret, conf);
client.SetRegion(region);
// Create a bucket.
try
    {
        var request = new CreateBucketRequest(bucketName);
        // Set the ACL to public-read. The default ACL is private.
        request.ACL = CannedAccessControlList.PublicRead;
        // Set the data redundancy type to zone-redundant storage.
        request.DataRedundancyType = DataRedundancyType.ZRS;
        client.CreateBucket(request);
        Console.WriteLine("Create bucket succeeded");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Create bucket failed. {0}", ex.Message);
    }
#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;

int main(void)
{
    // Initialize the OSS account information.

    // Set yourEndpoint to the Endpoint of the region where the bucket is located.
    // For example, if the bucket is in the China (Hangzhou) region,
    // set the Endpoint to https://oss-cn-hangzhou.aliyuncs.com.
    std::string Endpoint = "yourEndpoint";

    // Set yourRegion to the region where the bucket is located. For example,
    // if the bucket is in the China (Hangzhou) region, set the Region to cn-hangzhou.
    std::string Region = "yourRegion";

    // Specify the bucket name, for example, examplebucket.
    std::string BucketName = "examplebucket";

    // Initialize network resources.
    InitializeSdk();

    ClientConfiguration conf;
    conf.signatureVersion = SignatureVersionType::V4;
    // Obtain access credentials from environment variables. Make sure that the
    // OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
    auto credentialsProvider = std::make_shared<EnvironmentVariableCredentialsProvider>();
    OssClient client(Endpoint, credentialsProvider, conf);
    client.SetRegion(Region);

    // Specify the name, storage class, and ACL for the new bucket.
    CreateBucketRequest request(BucketName, StorageClass::IA, CannedAccessControlList::PublicReadWrite);
    // Set the data redundancy type to zone-redundant storage.
    request.setDataRedundancyType(DataRedundancyType::ZRS);

    // Create the bucket.
    auto outcome = client.CreateBucket(request);

    if (!outcome.isSuccess()) {
        // Handle exceptions.
        std::cout << "CreateBucket fail" <<
        ",code:" << outcome.error().Code() <<
        ",message:" << outcome.error().Message() <<
        ",requestId:" << outcome.error().RequestId() << std::endl;
        return -1;
    }

    // Release network resources.
    ShutdownSdk();
    return 0;
}
package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
)

// Define command-line arguments.
var (
	region     string // The region where the bucket is located.
	bucketName string // The name of the bucket.
)

// Initialize command-line argument parsing.
func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&bucketName, "bucket", "", "The name of the bucket.")
}

func main() {
	flag.Parse()

	if len(bucketName) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, bucket name required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	// Configure the OSS client with environment variable credentials.
	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := oss.NewClient(cfg)

	// Create a bucket with the data redundancy type set to ZRS.
	request := &oss.PutBucketRequest{
		Bucket: oss.Ptr(bucketName),
		CreateBucketConfiguration: &oss.CreateBucketConfiguration{
			DataRedundancyType: oss.DataRedundancyZRS,
		},
	}

	result, err := client.PutBucket(context.TODO(), request)
	if err != nil {
		log.Fatalf("failed to create bucket: %v", err)
	}

	log.Printf("put bucket result: %#v\n", result)
}

Use ossutil

To create a zone-redundant storage bucket with ossutil, see put-bucket.

Use the RESTful API

For highly customized application requirements, send RESTful API requests directly. Direct RESTful API calls require manual signature calculation. For more information, see PutBucket.