repository-hdfs.asciidoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. [[repository-hdfs]]
  2. === Hadoop HDFS Repository Plugin
  3. The HDFS repository plugin adds support for using HDFS File System as a repository for
  4. {ref}/modules-snapshots.html[Snapshot/Restore].
  5. :plugin_name: repository-hdfs
  6. include::install_remove.asciidoc[]
  7. [[repository-hdfs-usage]]
  8. ==== Getting started with HDFS
  9. The HDFS snapshot/restore plugin is built against the latest Apache Hadoop 2.x (currently 2.7.1). If the distro you are using is not protocol
  10. compatible with Apache Hadoop, consider replacing the Hadoop libraries inside the plugin folder with your own (you might have to adjust the security permissions required).
  11. Even if Hadoop is already installed on the Elasticsearch nodes, for security reasons, the required libraries need to be placed under the plugin folder. Note that in most cases, if the distro is compatible, one simply needs to configure the repository with the appropriate Hadoop configuration files (see below).
  12. Windows Users::
  13. Using Apache Hadoop on Windows is problematic and thus it is not recommended. For those _really_ wanting to use it, make sure you place the elusive `winutils.exe` under the
  14. plugin folder and point `HADOOP_HOME` variable to it; this should minimize the amount of permissions Hadoop requires (though one would still have to add some more).
  15. [[repository-hdfs-config]]
  16. ==== Configuration Properties
  17. Once installed, define the configuration for the `hdfs` repository through the
  18. {ref}/modules-snapshots.html[REST API]:
  19. [source,console]
  20. ----
  21. PUT _snapshot/my_hdfs_repository
  22. {
  23. "type": "hdfs",
  24. "settings": {
  25. "uri": "hdfs://namenode:8020/",
  26. "path": "elasticsearch/repositories/my_hdfs_repository",
  27. "conf.dfs.client.read.shortcircuit": "true"
  28. }
  29. }
  30. ----
  31. // TEST[skip:we don't have hdfs set up while testing this]
  32. The following settings are supported:
  33. [horizontal]
  34. `uri`::
  35. The uri address for hdfs. ex: "hdfs://<host>:<port>/". (Required)
  36. `path`::
  37. The file path within the filesystem where data is stored/loaded. ex: "path/to/file". (Required)
  38. `load_defaults`::
  39. Whether to load the default Hadoop configuration or not. (Enabled by default)
  40. `conf.<key>`::
  41. Inlined configuration parameter to be added to Hadoop configuration. (Optional)
  42. Only client oriented properties from the hadoop https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/core-default.xml[core] and https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/hdfs-default.xml[hdfs] configuration files will be recognized by the plugin.
  43. `compress`::
  44. Whether to compress the metadata or not. (Enabled by default)
  45. include::repository-shared-settings.asciidoc[]
  46. `chunk_size`::
  47. Override the chunk size. (Disabled by default)
  48. `security.principal`::
  49. Kerberos principal to use when connecting to a secured HDFS cluster.
  50. If you are using a service principal for your elasticsearch node, you may
  51. use the `_HOST` pattern in the principal name and the plugin will replace
  52. the pattern with the hostname of the node at runtime (see
  53. link:repository-hdfs-security-runtime[Creating the Secure Repository]).
  54. [[repository-hdfs-availability]]
  55. [discrete]
  56. ===== A Note on HDFS Availability
  57. When you initialize a repository, its settings are persisted in the cluster state. When a node comes online, it will
  58. attempt to initialize all repositories for which it has settings. If your cluster has an HDFS repository configured, then
  59. all nodes in the cluster must be able to reach HDFS when starting. If not, then the node will fail to initialize the
  60. repository at start up and the repository will be unusable. If this happens, you will need to remove and re-add the
  61. repository or restart the offending node.
  62. [[repository-hdfs-security]]
  63. ==== Hadoop Security
  64. The HDFS Repository Plugin integrates seamlessly with Hadoop's authentication model. The following authentication
  65. methods are supported by the plugin:
  66. [horizontal]
  67. `simple`::
  68. Also means "no security" and is enabled by default. Uses information from underlying operating system account
  69. running Elasticsearch to inform Hadoop of the name of the current user. Hadoop makes no attempts to verify this
  70. information.
  71. `kerberos`::
  72. Authenticates to Hadoop through the usage of a Kerberos principal and keytab. Interfacing with HDFS clusters
  73. secured with Kerberos requires a few additional steps to enable (See <<repository-hdfs-security-keytabs>> and
  74. <<repository-hdfs-security-runtime>> for more info)
  75. [[repository-hdfs-security-keytabs]]
  76. [discrete]
  77. ===== Principals and Keytabs
  78. Before attempting to connect to a secured HDFS cluster, provision the Kerberos principals and keytabs that the
  79. Elasticsearch nodes will use for authenticating to Kerberos. For maximum security and to avoid tripping up the Kerberos
  80. replay protection, you should create a service principal per node, following the pattern of
  81. `elasticsearch/hostname@REALM`.
  82. WARNING: In some cases, if the same principal is authenticating from multiple clients at once, services may reject
  83. authentication for those principals under the assumption that they could be replay attacks. If you are running the
  84. plugin in production with multiple nodes you should be using a unique service principal for each node.
  85. On each Elasticsearch node, place the appropriate keytab file in the node's configuration location under the
  86. `repository-hdfs` directory using the name `krb5.keytab`:
  87. [source, bash]
  88. ----
  89. $> cd elasticsearch/config
  90. $> ls
  91. elasticsearch.yml jvm.options log4j2.properties repository-hdfs/ scripts/
  92. $> cd repository-hdfs
  93. $> ls
  94. krb5.keytab
  95. ----
  96. // TEST[skip:this is for demonstration purposes only
  97. NOTE: Make sure you have the correct keytabs! If you are using a service principal per node (like
  98. `elasticsearch/hostname@REALM`) then each node will need its own unique keytab file for the principal assigned to that
  99. host!
  100. // Setup at runtime (principal name)
  101. [[repository-hdfs-security-runtime]]
  102. [discrete]
  103. ===== Creating the Secure Repository
  104. Once your keytab files are in place and your cluster is started, creating a secured HDFS repository is simple. Just
  105. add the name of the principal that you will be authenticating as in the repository settings under the
  106. `security.principal` option:
  107. [source,console]
  108. ----
  109. PUT _snapshot/my_hdfs_repository
  110. {
  111. "type": "hdfs",
  112. "settings": {
  113. "uri": "hdfs://namenode:8020/",
  114. "path": "/user/elasticsearch/repositories/my_hdfs_repository",
  115. "security.principal": "elasticsearch@REALM"
  116. }
  117. }
  118. ----
  119. // TEST[skip:we don't have hdfs set up while testing this]
  120. If you are using different service principals for each node, you can use the `_HOST` pattern in your principal
  121. name. Elasticsearch will automatically replace the pattern with the hostname of the node at runtime:
  122. [source,console]
  123. ----
  124. PUT _snapshot/my_hdfs_repository
  125. {
  126. "type": "hdfs",
  127. "settings": {
  128. "uri": "hdfs://namenode:8020/",
  129. "path": "/user/elasticsearch/repositories/my_hdfs_repository",
  130. "security.principal": "elasticsearch/_HOST@REALM"
  131. }
  132. }
  133. ----
  134. // TEST[skip:we don't have hdfs set up while testing this]
  135. [[repository-hdfs-security-authorization]]
  136. [discrete]
  137. ===== Authorization
  138. Once Elasticsearch is connected and authenticated to HDFS, HDFS will infer a username to use for
  139. authorizing file access for the client. By default, it picks this username from the primary part of
  140. the kerberos principal used to authenticate to the service. For example, in the case of a principal
  141. like `elasticsearch@REALM` or `elasticsearch/hostname@REALM` then the username that HDFS
  142. extracts for file access checks will be `elasticsearch`.
  143. NOTE: The repository plugin makes no assumptions of what Elasticsearch's principal name is. The main fragment of the
  144. Kerberos principal is not required to be `elasticsearch`. If you have a principal or service name that works better
  145. for you or your organization then feel free to use it instead!