repository-azure.asciidoc 9.4 KB

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