Commands for managing keys

The Ozone shell commands enable you to upload, download, view, delete, and list keys. 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.

Downloading a key from a bucket

Command Syntax
ozone sh key get URI <local_filename>
Purpose Downloads the specified key from a bucket in the Ozone cluster to the local file system.
Arguments
  • URI: The name of the key to download in the <prefix>://<Service ID>/<volumename>/<bucketname>/<keyname> format.
  • filename: The name of the file to which you want to write the key.
Example
ozone sh key get o3://ozone1/hive/jun/sales.orc sales_jun.orc
This command downloads the sales.orc file from the /hive/jun bucket and writes to the sales_jun.orc file present in the local file system. Here, ozone1 is the Ozone Service ID.

Uploading a key to a bucket

Command Syntax
ozone sh key put URI <filename>
Purpose Uploads a file from the local file system to the specified bucket in the Ozone cluster.
Arguments
  • URI: The name of the key to upload in the <prefix>://<Service ID>/<volumename>/<bucketname>/<keyname> format.
  • filename: The name of the local file that you want to upload.
  • -r, --replication: The number of copies of the file that you want to upload.
Example
ozone sh key put o3://ozone1/hive/year/sales.orc sales_corrected.orc
This command adds the sales_corrected.orc file from the local file system as key to /hive/year/sales.orc on the Ozone cluster. Here, ozone1 is the Ozone Service ID.

Deleting a key

Command Syntax
ozone sh key delete URI
Purpose Deletes the specified key from the Ozone cluster.
Arguments URI: The name of the key to delete in the <prefix>://<Service ID>/<volumename>/<bucketname>/<keyname> format.
Example
ozone sh key delete o3://ozone1/hive/jun/sales_duplicate.orc
This command deletes the sales_duplicate.orc key. Here, ozone1 is the Ozone Service ID.

Viewing key information

Command Syntax
ozone sh key info URI
Purpose Provides information about the specified key.
Arguments URI: The name of the key whose details you want to view, in the <prefix>://<Service ID>/<volumename>/<bucketname>/<keyname> format.
Example
ozone sh key info o3://ozone1/hive/jun/sales_jun.orc
This command provides information about the sales_jun.orc key. Here, ozone1 is the Ozone Service ID.

Listing keys

Command Syntax
ozone sh key list URI --length=<number_of_keys> --prefix=<key_prefix> --start=<starting_key>
Purpose Lists the keys in a specified bucket.
Arguments
  • -l, length: Specifies the maximum number of results to return. The default is 100.
  • -p, prefix: Returns keys that match the specified prefix.
  • -s, start: Returns results starting with the key after the specified value.
  • URI: The name of the bucket whose keys you want to list, in the <prefix>://<Service ID>/<volumename>/<bucketname>/ format.
Example
ozone sh key list o3://ozone1/hive/year/ --length=100 --prefix=<key_prefix> --start=day1
This command lists 100 keys belonging to the volume /hive/year/ and names starting with the prefix day, but listed after the value day1. Here, ozone1 is the Ozone Service ID.