CREATE REPOSITORY

Description

  1. This statement is used to create the warehouse. The warehouse is used for backup or recovery. Only root or superuser users can create warehouses.
  2. Grammar:
  3. CREATE [READ ONLY] REPOSITORY `repo_name`
  4. WITH [BROKER `broker_name`|S3]
  5. ON LOCATION `repo_location`
  6. PROPERTIES ("key"="value", ...);
  7. Explain:
  8. 1. The creation of warehouses depends on existing brokers, or use aws s3 protocl to connet cloud storage directly.
  9. 2. If it is a read-only warehouse, it can only be restored on the warehouse. If not, you can backup and restore operations.
  10. 3. According to the different types of broker or S3, PROPERTIES is different, see the example.

example

  1. 1. Create a warehouse named bos_repo, which relies on BOS broker "bos_broker", and the data root directory is: bos://palo_backup.
  2. CREATE REPOSITORY `bos_repo`
  3. WITH BROKER `bos_broker`
  4. ON LOCATION "bos://palo_backup"
  5. PROPERTIES
  6. (
  7. "bos_endpoint" ="http://gz.bcebos.com",
  8. "bos_accesskey" = "bos_accesskey",
  9. "bos_secret_accesskey"="bos_accesskey"
  10. );
  11. 2. Create the same warehouse as in Example 1, but with read-only attributes:
  12. CREATE READ ONLY REPOSITORY `bos_repo`
  13. WITH BROKER `bos_broker`
  14. ON LOCATION "bos://palo_backup"
  15. PROPERTIES
  16. (
  17. "bos_endpoint" ="http://gz.bcebos.com",
  18. "bos_accesskey" = "bos_accesskey",
  19. "bos_secret_accesskey"="bos_secret_accesskey"
  20. );
  21. 3. Create a warehouse named hdfs_repo, which relies on Baidu HDFS broker "hdfs_broker", and the data root directory is: hdfs://hadoop-name-node:54310/path/to/repo./
  22. CREATE REPOSITORY `hdfs_repo`
  23. WITH BROKER `hdfs_broker`
  24. ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
  25. PROPERTIES
  26. (
  27. "Username" = "User"
  28. "password" = "password"
  29. );
  30. 4. 创建名为 s3_repo 的仓库, 直接链接云存储, 而不通过broker.
  31. CREATE REPOSITORY `s3_repo`
  32. WITH S3
  33. ON LOCATION "s3://s3-repo"
  34. PROPERTIES
  35. (
  36. "AWS_ENDPOINT" = "http://s3-REGION.amazonaws.com",
  37. "AWS_ACCESS_KEY" = "AWS_ACCESS_KEY",
  38. "AWS_SECRET_KEY"="AWS_SECRET_KEY",
  39. "AWS_REGION" = "REGION"
  40. );

keyword

CREATE, REPOSITORY