HarperDB CLI
HarperDB CLI
The HarperDB command line interface (CLI) is used to administer self-installed HarperDB instances.
Installing HarperDB
To install HarperDB with CLI prompts, run the following command:
Alternatively, HarperDB installations can be automated with environment variables or command line arguments; see a full list of configuration parameters here. Note, when used in conjunction, command line arguments will override environment variables.
Environment Variables
Command Line Arguments
Starting HarperDB
To start HarperDB after it is installed, run the following command:
Stopping HarperDB
To stop HarperDB once it is running, run the following command:
Restarting HarperDB
To restart HarperDB once it is running, run the following command:
Getting the HarperDB Version
To check the version of HarperDB that is installed run the following command:
Renew self-signed certificates
To renew the HarperDB generated self-signed certificates, run:
Copy a database with compaction
To copy a HarperDB database with compaction (to eliminate free-space and fragmentation), use
For example, to copy the default database:
Get all available CLI commands
To display all available HarperDB CLI commands along with a brief description run:
Get the status of HarperDB and clustering
To display the status of the HarperDB process, the clustering hub and leaf processes, the clustering network and replication statuses, run:
Backups
HarperDB uses a transactional commit process that ensures that data on disk is always transactionally consistent with storage. This means that HarperDB maintains database integrity in the event of a crash. It also means that you can use any standard volume snapshot tool to make a backup of a HarperDB database. Database files are stored in the hdb/database directory. As long as the snapshot is an atomic snapshot of these database files, the data can be copied/moved back into the database directory to restore a previous backup (with HarperDB shut down) , and database integrity will be preserved. Note that simply copying an in-use database file (using cp
, for example) is not a snapshot, and this would progressively read data from the database at different points in time, which yields unreliable copy that likely will not be usable. Standard copying is only reliable for a database file that is not in use.
Operations API through the CLI
Some of the API operations are available through the CLI, this includes most operations that do not require nested parameters. To call the operation use the following convention: <api-operation> <parameter>=<value>
. By default, the result will be formatted as YAML, if you would like the result in JSON pass: json=true
.
Some examples are:
harperdb set_configuration logging_level=error
harperdb deploy_component project=my-cool-app package=https://github.com/HarperDB/application-template
harperdb get_components
harperdb search_by_id database=dev table=dog ids='["1"]' get_attributes='["*"]' json=true
harperdb search_by_value table=dog search_attribute=name search_value=harper get_attributes='["id", "name"]'
harperdb sql sql='select * from dev.dog where id="1"'
Remote Operations
The CLI can also be used to run operations on remote HarperDB instances. To do this, pass the target
parameter with the HTTP address of the remote instance. You generally will also need to provide credentials and specify the username
and password
parameters, or you can set environment variables CLI_TARGET_USERNAME
and CLI_TARGET_PASSWORD
, for example:
The same set of operations API are available for remote operations as well.
Remote Component Deployment
When using remote operations, you can deploy a local component to the remote instance. If you omit the package
parameter, you can deploy the current directory. This will package the current directory and send it to the target server (also deploy
is allowed as an alias to deploy_component
):
If you are interacting with a cluster, you may wish to include the replicated=true
parameter to ensure that the deployment operation is replicated to all nodes in the cluster. You will also need to restart afterwards to apply the changes (here seen with the replicated parameter):
Last updated