repository-azure.asciidoc 9.7 KB

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