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 |
|
Example | ozone sh key get o3://ozone1/hive/jun/sales.orc sales_jun.orcThis 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 |
|
Example | ozone sh key put o3://ozone1/hive/year/sales.orc sales_corrected.orcThis 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.orcThis 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.orcThis 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 |
|
Example | ozone sh key list o3://ozone1/hive/year/ --length=100 --prefix=<key_prefix> --start=day1This 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. |