repository-s3.asciidoc 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. [[repository-s3]]
  2. === S3 Repository Plugin
  3. The S3 repository plugin adds support for using S3 as a repository for
  4. {ref}/modules-snapshots.html[Snapshot/Restore].
  5. *If you are looking for a hosted solution of Elasticsearch on AWS, please visit http://www.elastic.co/cloud.*
  6. :plugin_name: repository-s3
  7. include::install_remove.asciidoc[]
  8. [[repository-s3-usage]]
  9. ==== Getting started with AWS
  10. The plugin provides a repository type named `s3` which may be used when creating a repository.
  11. The repository defaults to using
  12. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html[IAM Role]
  13. credentials for authentication. The only mandatory setting is the bucket name:
  14. [source,js]
  15. ----
  16. PUT _snapshot/my_s3_repository
  17. {
  18. "type": "s3",
  19. "settings": {
  20. "bucket": "my_bucket"
  21. }
  22. }
  23. ----
  24. // CONSOLE
  25. // TEST[skip:we don't have s3 setup while testing this]
  26. [[repository-s3-client]]
  27. ==== Client Settings
  28. The client used to connect to S3 has a number of settings available. Client setting names are of
  29. the form `s3.client.CLIENT_NAME.SETTING_NAME` and specified inside `elasticsearch.yml`. The
  30. default client name looked up by an s3 repository is called `default`, but can be customized
  31. with the repository setting `client`. For example:
  32. [source,js]
  33. ----
  34. PUT _snapshot/my_s3_repository
  35. {
  36. "type": "s3",
  37. "settings": {
  38. "bucket": "my_bucket",
  39. "client": "my_alternate_client"
  40. }
  41. }
  42. ----
  43. // CONSOLE
  44. // TEST[skip:we don't have s3 setup while testing this]
  45. Some settings are sensitive and must be stored in the {ref}/secure-settings.html[elasticsearch keystore].
  46. For example, to use explicit AWS access keys:
  47. [source,sh]
  48. ----
  49. bin/elasticsearch-keystore add s3.client.default.access_key
  50. bin/elasticsearch-keystore add s3.client.default.secret_key
  51. ----
  52. The following are the available client settings. Those that must be stored in the keystore
  53. are marked as `Secure`.
  54. `access_key`::
  55. An s3 access key. The `secret_key` setting must also be specified. (Secure)
  56. `secret_key`::
  57. An s3 secret key. The `access_key` setting must also be specified. (Secure)
  58. `endpoint`::
  59. The s3 service endpoint to connect to. This will be automatically
  60. figured out by the s3 client based on the bucket location, but
  61. can be specified explicitly. See http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region.
  62. `protocol`::
  63. The protocol to use to connect to s3. Valid values are either `http`
  64. or `https`. Defaults to `https`.
  65. `proxy.host`::
  66. The host name of a proxy to connect to s3 through.
  67. `proxy.port`::
  68. The port of a proxy to connect to s3 through.
  69. `proxy.username`::
  70. The username to connect to the `proxy.host` with. (Secure)
  71. `proxy.password`::
  72. The password to connect to the `proxy.host` with. (Secure)
  73. `read_timeout`::
  74. The socket timeout for connecting to s3. The value should specify the unit. For example,
  75. a value of `5s` specifies a 5 second timeout. The default value is 50 seconds.
  76. `max_retries`::
  77. The number of retries to use when an s3 request fails. The default value is 3.
  78. `use_throttle_retries`::
  79. Whether retries should be throttled (ie use backoff). Must be `true` or `false`. Defaults to `false`.
  80. [[repository-s3-repository]]
  81. ==== Repository Settings
  82. The `s3` repository type supports a number of settings to customize how data is stored in S3.
  83. These can be specified when creating the repository. For example:
  84. [source,js]
  85. ----
  86. PUT _snapshot/my_s3_repository
  87. {
  88. "type": "s3",
  89. "settings": {
  90. "bucket": "my_bucket_name",
  91. "another_setting": "setting_value"
  92. }
  93. }
  94. ----
  95. // CONSOLE
  96. // TEST[skip:we don't have s3 set up while testing this]
  97. The following settings are supported:
  98. `bucket`::
  99. The name of the bucket to be used for snapshots. (Mandatory)
  100. `client`::
  101. The name of the s3 client to use to connect to S3. Defaults to `default`.
  102. `base_path`::
  103. Specifies the path within bucket to repository data. Defaults to
  104. value of `repositories.s3.base_path` or to root directory if not set.
  105. Previously, the base_path could take a leading `/` (forward slash).
  106. However, this has been deprecated and setting the base_path now should
  107. omit the leading `/`.
  108. `chunk_size`::
  109. Big files can be broken down into chunks during snapshotting if needed.
  110. The chunk size can be specified in bytes or by using size value notation,
  111. i.e. `1gb`, `10mb`, `5kb`. Defaults to `1gb`.
  112. `compress`::
  113. When set to `true` metadata files are stored in compressed format. This
  114. setting doesn't affect index files that are already compressed by default.
  115. Defaults to `false`.
  116. `server_side_encryption`::
  117. When set to `true` files are encrypted on server side using AES256
  118. algorithm. Defaults to `false`.
  119. `buffer_size`::
  120. Minimum threshold below which the chunk is uploaded using a single
  121. request. Beyond this threshold, the S3 repository will use the
  122. http://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html[AWS Multipart Upload API]
  123. to split the chunk into several parts, each of `buffer_size` length, and
  124. to upload each part in its own request. Note that setting a buffer
  125. size lower than `5mb` is not allowed since it will prevents the use of the
  126. Multipart API and may result in upload errors. Defaults to the minimum
  127. between `100mb` and `5%` of the heap size.
  128. `canned_acl`::
  129. The S3 repository supports all http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl[S3 canned ACLs]
  130. : `private`, `public-read`, `public-read-write`, `authenticated-read`, `log-delivery-write`,
  131. `bucket-owner-read`, `bucket-owner-full-control`. Defaults to `private`.
  132. You could specify a canned ACL using the `canned_acl` setting. When the S3 repository
  133. creates buckets and objects, it adds the canned ACL into the buckets and objects.
  134. `storage_class`::
  135. Sets the S3 storage class type for the backup files. Values may be
  136. `standard`, `reduced_redundancy`, `standard_ia`. Defaults to `standard`.
  137. Due to the extra complexity with the Glacier class lifecycle, it is not
  138. currently supported by the plugin. For more information about the
  139. different classes, see http://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html[AWS Storage Classes Guide]
  140. [[repository-s3-permissions]]
  141. ===== Recommended S3 Permissions
  142. In order to restrict the Elasticsearch snapshot process to the minimum required resources, we recommend using Amazon
  143. IAM in conjunction with pre-existing S3 buckets. Here is an example policy which will allow the snapshot access to an
  144. S3 bucket named "snaps.example.com". This may be configured through the AWS IAM console, by creating a Custom Policy,
  145. and using a Policy Document similar to this (changing snaps.example.com to your bucket name).
  146. [source,js]
  147. ----
  148. {
  149. "Statement": [
  150. {
  151. "Action": [
  152. "s3:ListBucket",
  153. "s3:GetBucketLocation",
  154. "s3:ListBucketMultipartUploads",
  155. "s3:ListBucketVersions"
  156. ],
  157. "Effect": "Allow",
  158. "Resource": [
  159. "arn:aws:s3:::snaps.example.com"
  160. ]
  161. },
  162. {
  163. "Action": [
  164. "s3:GetObject",
  165. "s3:PutObject",
  166. "s3:DeleteObject",
  167. "s3:AbortMultipartUpload",
  168. "s3:ListMultipartUploadParts"
  169. ],
  170. "Effect": "Allow",
  171. "Resource": [
  172. "arn:aws:s3:::snaps.example.com/*"
  173. ]
  174. }
  175. ],
  176. "Version": "2012-10-17"
  177. }
  178. ----
  179. // NOTCONSOLE
  180. You may further restrict the permissions by specifying a prefix within the bucket, in this example, named "foo".
  181. [source,js]
  182. ----
  183. {
  184. "Statement": [
  185. {
  186. "Action": [
  187. "s3:ListBucket",
  188. "s3:GetBucketLocation",
  189. "s3:ListBucketMultipartUploads",
  190. "s3:ListBucketVersions"
  191. ],
  192. "Condition": {
  193. "StringLike": {
  194. "s3:prefix": [
  195. "foo/*"
  196. ]
  197. }
  198. },
  199. "Effect": "Allow",
  200. "Resource": [
  201. "arn:aws:s3:::snaps.example.com"
  202. ]
  203. },
  204. {
  205. "Action": [
  206. "s3:GetObject",
  207. "s3:PutObject",
  208. "s3:DeleteObject",
  209. "s3:AbortMultipartUpload",
  210. "s3:ListMultipartUploadParts"
  211. ],
  212. "Effect": "Allow",
  213. "Resource": [
  214. "arn:aws:s3:::snaps.example.com/foo/*"
  215. ]
  216. }
  217. ],
  218. "Version": "2012-10-17"
  219. }
  220. ----
  221. // NOTCONSOLE
  222. The bucket needs to exist to register a repository for snapshots. If you did not create the bucket then the repository
  223. registration will fail. If you want elasticsearch to create the bucket instead, you can add the permission to create a
  224. specific bucket like this:
  225. [source,js]
  226. ----
  227. {
  228. "Action": [
  229. "s3:CreateBucket"
  230. ],
  231. "Effect": "Allow",
  232. "Resource": [
  233. "arn:aws:s3:::snaps.example.com"
  234. ]
  235. }
  236. ----
  237. // NOTCONSOLE
  238. [[repository-s3-aws-vpc]]
  239. [float]
  240. ==== AWS VPC Bandwidth Settings
  241. AWS instances resolve S3 endpoints to a public IP. If the elasticsearch instances reside in a private subnet in an AWS VPC then all traffic to S3 will go through that VPC's NAT instance. If your VPC's NAT instance is a smaller instance size (e.g. a t1.micro) or is handling a high volume of network traffic your bandwidth to S3 may be limited by that NAT instance's networking bandwidth limitations.
  242. Instances residing in a public subnet in an AWS VPC will connect to S3 via the VPC's internet gateway and not be bandwidth limited by the VPC's NAT instance.