CREATE-REPOSITORY

Name

CREATE REPOSITORY

Description

This statement is used to create a repository. Repositories are used for backup or restore. Only root or superuser users can create repositories.

grammar:

  1. CREATE [READ ONLY] REPOSITORY `repo_name`
  2. WITH [BROKER `broker_name`|S3|hdfs]
  3. ON LOCATION `repo_location`
  4. PROPERTIES ("key"="value", ...);

illustrate:

  • Creation of repositories, relying on existing brokers or accessing cloud storage directly through AWS s3 protocol, or accessing HDFS directly.
  • If it is a read-only repository, restores can only be done on the repository. If not, backup and restore operations are available.
  • PROPERTIES are different according to different types of broker or S3 or hdfs, see the example for details.
  • ON LOCATION : if it is S3 , here followed by the Bucket Name.

Example

  1. Create a warehouse named bos_repo, rely on BOS broker “bos_broker”, and the data root directory is: bos://palo_backup
  1. CREATE REPOSITORY `bos_repo`
  2. WITH BROKER `bos_broker`
  3. ON LOCATION "bos://palo_backup"
  4. PROPERTIES
  5. (
  6. "bos_endpoint" = "http://gz.bcebos.com",
  7. "bos_accesskey" = "bos_accesskey",
  8. "bos_secret_accesskey"="bos_secret_accesskey"
  9. );
  1. Create the same repository as Example 1, but with read-only properties:
  1. CREATE READ ONLY REPOSITORY `bos_repo`
  2. WITH BROKER `bos_broker`
  3. ON LOCATION "bos://palo_backup"
  4. PROPERTIES
  5. (
  6. "bos_endpoint" = "http://gz.bcebos.com",
  7. "bos_accesskey" = "bos_accesskey",
  8. "bos_secret_accesskey"="bos_accesskey"
  9. );
  1. Create a warehouse named hdfs_repo, rely on Baidu hdfs broker “hdfs_broker”, the data root directory is: hdfs://hadoop-name-node:54310/path/to/repo/
  1. CREATE REPOSITORY `hdfs_repo`
  2. WITH BROKER `hdfs_broker`
  3. ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
  4. PROPERTIES
  5. (
  6. "username" = "user",
  7. "password" = "password"
  8. );
  1. Create a repository named s3_repo to link cloud storage directly without going through the broker.
  1. CREATE REPOSITORY `s3_repo`
  2. WITH S3
  3. ON LOCATION "s3://s3-repo"
  4. PROPERTIES
  5. (
  6. "AWS_ENDPOINT" = "http://s3-REGION.amazonaws.com",
  7. "AWS_ACCESS_KEY" = "AWS_ACCESS_KEY",
  8. "AWS_SECRET_KEY"="AWS_SECRET_KEY",
  9. "AWS_REGION" = "REGION"
  10. );
  1. Create a repository named hdfs_repo to link HDFS directly without going through the broker.
  1. CREATE REPOSITORY `hdfs_repo`
  2. WITH hdfs
  3. ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
  4. PROPERTIES
  5. (
  6. "fs.defaultFS"="hdfs://hadoop-name-node:54310",
  7. "hadoop.username"="user"
  8. );
  9. ### Keywords
  1. Create a repository named minio_repo to link minio storage directly through the s3 protocol.
  1. CREATE REPOSITORY `minio_repo`
  2. WITH S3
  3. ON LOCATION "s3://minio_repo"
  4. PROPERTIES
  5. (
  6. "AWS_ENDPOINT" = "http://minio.com",
  7. "AWS_ACCESS_KEY" = "MINIO_USER",
  8. "AWS_SECRET_KEY"="MINIO_PASSWORD",
  9. "AWS_REGION" = "REGION",
  10. "use_path_style" = "true"
  11. );

SinceVersion 1.2

  1. Create a repository named minio_repo via temporary security credentials.
  1. CREATE REPOSITORY `minio_repo`
  2. WITH S3
  3. ON LOCATION "s3://minio_repo"
  4. PROPERTIES
  5. (
  6. "AWS_ENDPOINT" = "AWS_ENDPOINT",
  7. "AWS_ACCESS_KEY" = "AWS_TEMP_ACCESS_KEY",
  8. "AWS_SECRET_KEY" = "AWS_TEMP_SECRET_KEY",
  9. "AWS_TOKEN" = "AWS_TEMP_TOKEN",
  10. "AWS_REGION" = "AWS_REGION"
  11. )

Keywords

  1. CREATE, REPOSITORY

Best Practice

  1. A cluster can create multiple warehouses. Only users with ADMIN privileges can create repositories.
  2. Any user can view the created repositories through the SHOW REPOSITORIES command.
  3. When performing data migration operations, it is necessary to create the exact same warehouse in the source cluster and the destination cluster, so that the destination cluster can view the data snapshots backed up by the source cluster through this warehouse.