repository-azure.asciidoc 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. [[repository-azure]]
  2. === Azure repository
  3. You can use https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction[Azure Blob storage] as a repository for
  4. {ref}/modules-snapshots.html[Snapshot/Restore].
  5. [[repository-azure-usage]]
  6. ==== Setup
  7. To enable Azure repositories, you have first to define your azure storage settings as
  8. {ref}/secure-settings.html[secure settings], before starting up the node:
  9. [source,sh]
  10. ----------------------------------------------------------------
  11. bin/elasticsearch-keystore add azure.client.default.account
  12. bin/elasticsearch-keystore add azure.client.default.key
  13. ----------------------------------------------------------------
  14. Note that you can also define more than one account:
  15. [source,sh]
  16. ----------------------------------------------------------------
  17. bin/elasticsearch-keystore add azure.client.default.account
  18. bin/elasticsearch-keystore add azure.client.default.key
  19. bin/elasticsearch-keystore add azure.client.secondary.account
  20. bin/elasticsearch-keystore add azure.client.secondary.sas_token
  21. ----------------------------------------------------------------
  22. For more information about these settings, see
  23. <<repository-azure-client-settings>>.
  24. [IMPORTANT]
  25. .Supported Azure Storage Account types
  26. ===============================================
  27. The Azure repository type works with all Standard storage accounts
  28. * Standard Locally Redundant Storage - `Standard_LRS`
  29. * Standard Zone-Redundant Storage - `Standard_ZRS`
  30. * Standard Geo-Redundant Storage - `Standard_GRS`
  31. * Standard Read Access Geo-Redundant Storage - `Standard_RAGRS`
  32. https://azure.microsoft.com/en-gb/documentation/articles/storage-premium-storage[Premium Locally Redundant Storage] (`Premium_LRS`) is **not supported** as it is only usable as VM disk storage, not as general storage.
  33. ===============================================
  34. [[repository-azure-client-settings]]
  35. ==== Client settings
  36. The client that you use to connect to Azure has a number of settings available.
  37. The settings have the form `azure.client.CLIENT_NAME.SETTING_NAME`. By default,
  38. `azure` repositories use a client named `default`, but this can be modified using
  39. the <<repository-azure-repository-settings,repository setting>> `client`.
  40. For example:
  41. [source,console]
  42. ----
  43. PUT _snapshot/my_backup
  44. {
  45. "type": "azure",
  46. "settings": {
  47. "client": "secondary"
  48. }
  49. }
  50. ----
  51. // TEST[skip:we don't have azure setup while testing this]
  52. Most client settings can be added to the `elasticsearch.yml` configuration file.
  53. For example:
  54. [source,yaml]
  55. ----
  56. azure.client.default.timeout: 10s
  57. azure.client.default.max_retries: 7
  58. azure.client.default.endpoint_suffix: core.chinacloudapi.cn
  59. azure.client.secondary.timeout: 30s
  60. ----
  61. In this example, the client side timeout is `10s` per try for the `default`
  62. account with `7` retries before failing. The endpoint suffix is
  63. `core.chinacloudapi.cn` and `30s` per try for the `secondary` account with `3`
  64. retries.
  65. The `account`, `key`, and `sas_token` storage settings are reloadable secure
  66. settings, which you add to the {es} keystore. For more information about
  67. creating and updating the {es} keystore, see
  68. {ref}/secure-settings.html[Secure settings]. After you reload the settings, the
  69. internal Azure clients, which are used to transfer the snapshot, utilize the
  70. latest settings from the keystore.
  71. NOTE: In progress snapshot or restore jobs will not be preempted by a *reload*
  72. of the storage secure settings. They will complete using the client as it was
  73. built when the operation started.
  74. The following list contains the available client settings. Those that must be
  75. stored in the keystore are marked as "secure"; the other settings belong in the
  76. `elasticsearch.yml` file.
  77. `account` ({ref}/secure-settings.html[Secure], {ref}/secure-settings.html#reloadable-secure-settings[reloadable])::
  78. The Azure account name, which is used by the repository's internal Azure client.
  79. `endpoint_suffix`::
  80. The Azure endpoint suffix to connect to. The default value is
  81. `core.windows.net`.
  82. `key` ({ref}/secure-settings.html[Secure], {ref}/secure-settings.html#reloadable-secure-settings[reloadable])::
  83. The Azure secret key, which is used by the repository's internal Azure client. Alternatively, use `sas_token`.
  84. `max_retries`::
  85. The number of retries to use when an Azure request fails. This setting helps
  86. control the exponential backoff policy. It specifies the number of retries
  87. that must occur before the snapshot fails. The default value is `3`. The
  88. initial backoff period is defined by Azure SDK as `30s`. Thus there is `30s`
  89. of wait time before retrying after a first timeout or failure. The maximum
  90. backoff period is defined by Azure SDK as `90s`.
  91. `proxy.host`::
  92. The host name of a proxy to connect to Azure through. For example: `azure.client.default.proxy.host: proxy.host`.
  93. `proxy.port`::
  94. The port of a proxy to connect to Azure through. For example, `azure.client.default.proxy.port: 8888`.
  95. `proxy.type`::
  96. Register a proxy type for the client. Supported values are `direct`, `http`,
  97. and `socks`. For example: `azure.client.default.proxy.type: http`. When
  98. `proxy.type` is set to `http` or `socks`, `proxy.host` and `proxy.port` must
  99. also be provided. The default value is `direct`.
  100. `sas_token` ({ref}/secure-settings.html[Secure], {ref}/secure-settings.html#reloadable-secure-settings[reloadable])::
  101. A shared access signatures (SAS) token, which the repository's internal Azure
  102. client uses for authentication. The SAS token must have read (r), write (w),
  103. list (l), and delete (d) permissions for the repository base path and all its
  104. contents. These permissions must be granted for the blob service (b) and apply
  105. to resource types service (s), container (c), and object (o). Alternatively,
  106. use `key`.
  107. `timeout`::
  108. The client side timeout for any single request to Azure. The value should
  109. specify the time unit. For example, a value of `5s` specifies a 5 second
  110. timeout. There is no default value, which means that {es} uses the
  111. https://azure.github.io/azure-storage-java/com/microsoft/azure/storage/RequestOptions.html#setTimeoutIntervalInMs(java.lang.Integer)[default value]
  112. set by the Azure client (known as 5 minutes). This setting can be defined
  113. globally, per account, or both.
  114. `endpoint`::
  115. The Azure endpoint to connect to. It must include the protocol used to connect to Azure.
  116. `secondary_endpoint`::
  117. The Azure secondary endpoint to connect to. It must include the protocol used to connect to Azure.
  118. [[repository-azure-repository-settings]]
  119. ==== Repository settings
  120. The Azure repository supports following settings:
  121. `client`::
  122. Azure named client to use. Defaults to `default`.
  123. `container`::
  124. Container name. You must create the azure container before creating the repository.
  125. Defaults to `elasticsearch-snapshots`.
  126. `base_path`::
  127. Specifies the path within container to repository data. Defaults to empty
  128. (root directory).
  129. +
  130. NOTE: Don't set `base_path` when configuring a snapshot repository for {ECE}.
  131. {ECE} automatically generates the `base_path` for each deployment so that
  132. multiple deployments may share the same bucket.
  133. `chunk_size`::
  134. Big files can be broken down into multiple smaller blobs in the blob store during snapshotting.
  135. It is not recommended to change this value from its default unless there is an explicit reason for limiting the
  136. size of blobs in the repository. Setting a value lower than the default can result in an increased number of API
  137. calls to the Azure blob store during snapshot create as well as restore operations compared to using the default
  138. value and thus make both operations slower as well as more costly.
  139. Specify the chunk size as a value and unit, for example:
  140. `10MB`, `5KB`, `500B`. Defaults to the maximum size of a blob in the Azure blob store which is `5TB`.
  141. `compress`::
  142. When set to `true` metadata files are stored in compressed format. This
  143. setting doesn't affect index files that are already compressed by default.
  144. Defaults to `true`.
  145. include::repository-shared-settings.asciidoc[]
  146. `location_mode`::
  147. `primary_only` or `secondary_only`. Defaults to `primary_only`. Note that if you set it
  148. to `secondary_only`, it will force `readonly` to true.
  149. Some examples, using scripts:
  150. [source,console]
  151. ----
  152. # The simplest one
  153. PUT _snapshot/my_backup1
  154. {
  155. "type": "azure"
  156. }
  157. # With some settings
  158. PUT _snapshot/my_backup2
  159. {
  160. "type": "azure",
  161. "settings": {
  162. "container": "backup-container",
  163. "base_path": "backups",
  164. "chunk_size": "32MB",
  165. "compress": true
  166. }
  167. }
  168. # With two accounts defined in elasticsearch.yml (my_account1 and my_account2)
  169. PUT _snapshot/my_backup3
  170. {
  171. "type": "azure",
  172. "settings": {
  173. "client": "secondary"
  174. }
  175. }
  176. PUT _snapshot/my_backup4
  177. {
  178. "type": "azure",
  179. "settings": {
  180. "client": "secondary",
  181. "location_mode": "primary_only"
  182. }
  183. }
  184. ----
  185. // TEST[skip:we don't have azure setup while testing this]
  186. Example using Java:
  187. [source,java]
  188. ----
  189. client.admin().cluster().preparePutRepository("my_backup_java1")
  190. .setType("azure").setSettings(Settings.builder()
  191. .put(Storage.CONTAINER, "backup-container")
  192. .put(Storage.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
  193. ).get();
  194. ----
  195. [[repository-azure-validation]]
  196. ==== Repository validation rules
  197. According to the
  198. https://docs.microsoft.com/en-us/rest/api/storageservices/Naming-and-Referencing-Containers--Blobs--and-Metadata[containers
  199. naming guide], a container name must be a valid DNS name, conforming to the
  200. following naming rules:
  201. * Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
  202. * Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not
  203. permitted in container names.
  204. * All letters in a container name must be lowercase.
  205. * Container names must be from 3 through 63 characters long.