Commands for managing keys

The Ozone shell commands enable you to upload, download, view, delete, and list keys.

Downloading a key from a bucket

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

Uploading a key to a bucket

Command Syntax
ozone sh key put /<volumename>/<bucketname>/<keyname> <filename>
Purpose Uploads a file from the local file system to the specified bucket in the Ozone cluster.
Arguments
  • keyname: The name of the key in /<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 /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.

Deleting a key

Command Syntax
ozone sh key delete /<volumename>/<bucketname>/<keyname>
Purpose Deletes the specified key from the Ozone cluster.
Arguments The name of the key in /<volumename>/<bucketname>/<keyname> format.
Example
ozone sh key delete /hive/jun/sales_duplicate.orc
This command deletes the sales_duplicate.orc key.

Viewing key information

Command Syntax
ozone sh bucket info /<volumename>/<bucketname>/<keyname>
Purpose Provides information about the specified key.
Arguments The name of the key whose details you want to view.
Example
ozone sh bucket info /hive/jun/sales_jun.orc
This command provides information about the sales_jun.orc key.

Listing keys

Command Syntax
ozone sh key list /<bucketname> --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.
  • The name of the bucket whose keys you want to list.
Example
ozone sh key list /hive/jun/
This command lists all the keys in the volume /hive/jun.