Command Line Interface

Ozone shell is the primary interface to interact with Ozone from the command line. Behind the scenes it uses the Java API.

There are some functionality which couldn’t be accessed without using ozone sh commands. For example:

  1. Creating volumes with quota
  2. Managing internal ACLs
  3. Creating buckets with encryption key

All of these are one-time, administration tasks. Applications can use Ozone without this CLI using other interface like Hadoop Compatible File System (o3fs or ofs) or S3 interface.

Ozone shell help can be invoked at object level or at action level.

For example:

  1. ozone sh volume --help

will show all possible actions for volumes.

Or it can be invoked to explain a specific action like:

  1. ozone sh volume create --help

which will print the command line options of the create command for volumes.

General Command Format

Ozone shell commands take the following form:

ozone sh object action url

ozone script is used to invoke all Ozone sub-commands. The ozone shell is invoked via sh command.

Object can be volume, bucket or key. Actions are various verbs like create, list, delete etc.

Depending on the action, Ozone URL can point to a volume, bucket or key in the following format:

[schema][server:port]/volume/bucket/key

Where,

  1. Schema - This should be o3 which is the native RPC protocol to access Ozone API. The usage of the schema is optional.

  2. Server:Port - This is the address of the Ozone Manager. If the port is omitted the default port from ozone-site.xml will be used.

Please see volume commands, bucket commands, and key commands section for more detail.

Volume operations

Volume is the top level element of the hierarchy, managed only by administrators. Optionally, quota and the owner user can be specified.

Example commands:

  1. $ ozone sh volume create /vol1
  1. $ ozone sh volume info /vol1
  2. {
  3. "metadata" : { },
  4. "name" : "vol1",
  5. "admin" : "hadoop",
  6. "owner" : "hadoop",
  7. "creationTime" : "2020-07-28T12:31:50.112Z",
  8. "modificationTime" : "2020-07-28T12:31:50.112Z",
  9. "acls" : [ {
  10. "type" : "USER",
  11. "name" : "hadoop",
  12. "aclScope" : "ACCESS",
  13. "aclList" : [ "ALL" ]
  14. }, {
  15. "type" : "GROUP",
  16. "name" : "users",
  17. "aclScope" : "ACCESS",
  18. "aclList" : [ "ALL" ]
  19. } ],
  20. "quota" : 1152921504606846976
  21. }
  1. $ ozone sh volume list /
  2. [ {
  3. "metadata" : { },
  4. "name" : "s3v",
  5. "admin" : "hadoop",
  6. "owner" : "hadoop",
  7. "creationTime" : "2020-07-27T11:32:22.314Z",
  8. "modificationTime" : "2020-07-27T11:32:22.314Z",
  9. "acls" : [ {
  10. "type" : "USER",
  11. "name" : "hadoop",
  12. "aclScope" : "ACCESS",
  13. "aclList" : [ "ALL" ]
  14. }, {
  15. "type" : "GROUP",
  16. "name" : "users",
  17. "aclScope" : "ACCESS",
  18. "aclList" : [ "ALL" ]
  19. } ],
  20. "quota" : 1152921504606846976
  21. }, {
  22. ....
  23. } ]

Bucket operations

Bucket is the second level of the object hierarchy, and is similar to AWS S3 buckets. Users can create buckets in volumes, if they have the necessary permissions.

Command examples:

  1. $ ozone sh bucket create /vol1/bucket1
  1. $ ozone sh bucket info /vol1/bucket1
  2. {
  3. "metadata" : { },
  4. "volumeName" : "vol1",
  5. "name" : "bucket1",
  6. "storageType" : "DISK",
  7. "versioning" : false,
  8. "creationTime" : "2020-07-28T13:14:45.091Z",
  9. "modificationTime" : "2020-07-28T13:14:45.091Z",
  10. "encryptionKeyName" : null,
  11. "sourceVolume" : null,
  12. "sourceBucket" : null
  13. }

Transparent Data Encryption can be enabled at the bucket level.

Key operations

Key is the object which can store the data.

  1. $ ozone sh key put /vol1/bucket1/README.md README.md

In this case the standard ozone sh <object_type> <action> <url> scheme may be a bit confusing at first, as it results in the syntax ozone sh key put <destination> <source> instead of the arguably more natural order of <source> <destination>.

  1. $ ozone sh key info /vol1/bucket1/README.md
  2. {
  3. "volumeName" : "vol1",
  4. "bucketName" : "bucket1",
  5. "name" : "README.md",
  6. "dataSize" : 3841,
  7. "creationTime" : "2020-07-28T13:17:20.749Z",
  8. "modificationTime" : "2020-07-28T13:17:21.979Z",
  9. "replicationType" : "RATIS",
  10. "replicationFactor" : 1,
  11. "ozoneKeyLocations" : [ {
  12. "containerID" : 1,
  13. "localID" : 104591670688743424,
  14. "length" : 3841,
  15. "offset" : 0
  16. } ],
  17. "metadata" : { },
  18. "fileEncryptionInfo" : null
  19. }
  1. $ ozone sh key get /vol1/bucket1/README.md /tmp/