CREATE REPOSITORY
Descriptionβ
This statement is used to create a repository. Repositories are used for backup or restore.
Syntaxβ
CREATE [READ ONLY] REPOSITORY <repo_name>
WITH [ S3 | HDFS ]
ON LOCATION <repo_location>
PROPERTIES (
-- S3 or HDFS storage property
<storage_property>
[ , ... ]
)
Required Parametersβ
<repo_name>
The unique name of the repository.
<repo_location>
The storage path of the repository.
<storage_property>
The properties of the repository. The corresponding parameters should be selected based on whether S3 or HDFS is chosen as the storage medium.
<storage_property> Optional parameters are as follows, and additional parameters can be added based on the actual environment.
εζ° | θ―΄ζ |
---|---|
s3.endpoint | S3 service endpoint |
s3.access_key | S3 access key |
s3.secret_key | S3 secret key |
s3.region | S3 region |
use_path_style | Whether to use path-style access for S3 (applies to MinIO) |
fs.defaultFS | Hadoop default file system URI |
hadoop.username | Hadoop username |
Access Control Requirementsβ
Privilege | Object | Notes |
---|---|---|
ADMIN_PRIV | Entire cluster management permissions | Only the root or superuser can create repositories |
Usage notesβ
- If it is a read-only repository, restoration can only be performed on the repository. If not, both backup and restoration operations can be performed.
- The properties (PROPERTIES) vary depending on whether it is S3 or HDFS, as shown in the example.
- For ON LOCATION, if it is S3, the following should be the S3 Bucket Name.
- When performing data migration, the same repository must be created in both the source and destination clusters so that the destination cluster can view the data snapshot from the source cluster's backup.
- Any user can view the repositories that have been created by using the SHOW REPOSITORIES command.
Examplesβ
Create a repository named s3_repo.
CREATE REPOSITORY `s3_repo`
WITH S3
ON LOCATION "s3://s3-repo"
PROPERTIES
(
"s3.endpoint" = "http://s3-REGION.amazonaws.com",
"s3.region" = "s3-REGION",
"s3.access_key" = "AWS_ACCESS_KEY",
"s3.secret_key"="AWS_SECRET_KEY",
"s3.region" = "REGION"
);
Create a repository named hdfs_repo.
CREATE REPOSITORY `hdfs_repo`
WITH hdfs
ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
PROPERTIES
(
"fs.defaultFS"="hdfs://hadoop-name-node:54310",
"hadoop.username"="user"
);
Create a repository named minio_repo to link minio storage directly through the S3 protocol.
CREATE REPOSITORY `minio_repo`
WITH S3
ON LOCATION "s3://minio_repo"
PROPERTIES
(
"s3.endpoint" = "http://minio.com",
"s3.access_key" = "MINIO_USER",
"s3.secret_key"="MINIO_PASSWORD",
"s3.region" = "REGION",
"use_path_style" = "true"
);
Create a repository named minio_repo via temporary security credentials.
CREATE REPOSITORY `minio_repo`
WITH S3
ON LOCATION "s3://minio_repo"
PROPERTIES
(
"s3.endpoint" = "AWS_ENDPOINT",
"s3.access_key" = "AWS_TEMP_ACCESS_KEY",
"s3.secret_key" = "AWS_TEMP_SECRET_KEY",
"s3.session_token" = "AWS_TEMP_TOKEN",
"s3.region" = "AWS_REGION"
)
Create repository using Tencent COS
CREATE REPOSITORY `cos_repo`
WITH S3
ON LOCATION "s3://backet1/"
PROPERTIES
(
"s3.access_key" = "ak",
"s3.secret_key" = "sk",
"s3.endpoint" = "http://cos.ap-beijing.myqcloud.com",
"s3.region" = "ap-beijing"
);