Commands for managing buckets

The Ozone shell commands enable you to create, delete, view, and list buckets. Before running these commands, you must have configured the Ozone Service ID for your cluster from the Configuration tab of the Ozone service on Cloudera Manager.

Creating bucket and specifying quota

Command Syntax
ozone sh bucket create [--namespace-quota=<quotaInNamespace>] [--space-quota=<quotaInBytes>] <uri>
Command Usage
  • Create volume with only space quota:
    ozone sh bucket create --space–quota=<quotaInBytes> <uri>
  • Create volume with only namespace quota:
    ozone sh bucket create --namespace-quota=<quotaInNamespace> <uri>
  • Create volume with both space and namespace quota:
    ozone sh bucket create --namespace-quota=<quotaInNamespace> --space–quota=<quotaInBytes> <uri>
Purpose Creates a bucket with the quota.
Arguments
  • uri: The name of the bucket to create in the <prefix>://<Service ID>/<volumename>/<bucketname> format.
  • --namespace-quota: Specify the number of keys, files, and directories in a bucket. This is an optional parameter.
  • --space-quota: Specifies the maximum size the bucket can occupy in the cluster. This is an optional parameter.
Example
ozone sh bucket create --space-quota=2TB o3://ozone1/vol1/buck1
This command creates a 2 TB bucket named buck1. Here, ozone1 is the Ozone Service ID.
ozone sh bucket create --namespace-quota=100 o3://ozone1/vol1/buck1
This command sets the namespace quota of buck1 to 100.

Checking Namespace and space quota for bucket

Command Syntax
ozone sh bucket info <uri>
Purpose Get the quota value, usedNamespace, and usedBytes info of the bucket.
Arguments uri: The name of the bucket whose details you want to view, in the <prefix>://<Service ID>/<volumename>/<bucketname> format.
Example
ozone sh bucket info o3://ozone1/vol1/buck1
This command gets the quota value, usedNamespace, and usedBytes of buck1.
{
  "metadata" : { },
  "volumeName" : "vol1",
  "name" : "buck1",
  "storageType" : "DISK",
  "versioning" : false,
  "usedBytes" : 0,
  "usedNamespace" : 0,
  "creationTime" : "2023-07-10T06:12:47.270Z",
  "modificationTime" : "2023-07-10T06:12:47.270Z",
  "sourcePathExist" : true,
  "quotaInBytes" : 1099511627776,
  "quotaInNamespace" : 100,
  "bucketLayout" : "LEGACY",
  "owner" : "user1",
  "link" : false
}

Setting namespace and space level quota for bucket

Namespace quota is a number that represents how many unique names can be used. This number cannot be greater than LONG.MAX_VALUE in Java.

Command Syntax
ozone sh bucket setquota [-hV] [--namespace-quota=<quotaInNamespace>][--space-quota=<quotaInBytes>] <uri>
Command Usage
  • Update bucket with only space quota:
    ozone sh bucket setquota --space–quota=<quotaInBytes> <uri>
  • Update bucket with only namespace quota:
    ozone sh bucket setquota --namespace-quota=<quotaInNamespace> <uri>
  • Update bucket with both space and namespace quota:
    ozone sh bucket setquota --namespace-quota=<quotaInNamespace> --space–quota=<quotaInBytes> <uri>
Purpose
  • Manage the namespace and space quota of a bucket.
Arguments
    • uri: The name of the bucket to create in the <prefix>://<Service ID>/<volumename>/<bucketname> format.
    • --namespace-quota: Update the number of keys,files, and directories in a bucket. This is an optional parameter.
    • --space-quota: Update the maximum size the bucket can occupy in the cluster. This is an optional parameter.
Example
  • ozone sh bucket create --namespace-quota=100 o3://ozone1/vol1/buck1
    This command sets the namespace quota of buck1 to 100.
  • ozone sh bucket setquota --space-quota=10GB o3://ozone1/vol1/buck1
    This command sets vol1/buck1 space quota to 10 GB.

Clearing namespace and space quota for bucket

Command Syntax
ozone sh bucket clrquota [-hV] [--namespace-quota] [--space-quota] <uri>
Command Usage
  • Clear bucket with only space quota:
    ozone sh bucket clrquota --space-quota <uri> 
  • Clear bucket with only namespace quota:
    ozone sh bucket clrquota --namespace-quota <uri>
  • Clear bucket with both space and namespace quota:
    ozone sh bucket clrquota --space-quota --namespace-quota <uri> 
Purpose
  • Clear the namespace quota and space quota of the bucket.
Arguments
  • --namespace-quota: Clear the namespace quota of a bucket.
  • --space-quota: Clear the space quota of a bucket.
Example
  • ozone sh bucket clrquota --namespace-quota o3://ozone1/vol1/buck1
    This command clears the namespace quota of buck1.
  • ozone sh bucket clrquota --space-quota o3://ozone1/vol1/buck1
    This command clears the space quota of buck1.