repository-hdfs.asciidoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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,js]
  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. // CONSOLE
  32. // TEST[skip:we don't have hdfs set up while testing this]
  33. The following settings are supported:
  34. [horizontal]
  35. `uri`::
  36. The uri address for hdfs. ex: "hdfs://<host>:<port>/". (Required)
  37. `path`::
  38. The file path within the filesystem where data is stored/loaded. ex: "path/to/file". (Required)
  39. `load_defaults`::
  40. Whether to load the default Hadoop configuration or not. (Enabled by default)
  41. `conf.<key>`::
  42. Inlined configuration parameter to be added to Hadoop configuration. (Optional)
  43. Only client oriented properties from the hadoop http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/core-default.xml[core] and http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/hdfs-default.xml[hdfs] configuration files will be recognized by the plugin.
  44. `compress`::
  45. Whether to compress the metadata or not. (Enabled by default)
  46. include::repository-shared-settings.asciidoc[]
  47. `chunk_size`::
  48. Override the chunk size. (Disabled by default)
  49. `security.principal`::
  50. Kerberos principal to use when connecting to a secured HDFS cluster.
  51. If you are using a service principal for your elasticsearch node, you may
  52. use the `_HOST` pattern in the principal name and the plugin will replace
  53. the pattern with the hostname of the node at runtime (see
  54. link:repository-hdfs-security-runtime[Creating the Secure Repository]).
  55. [[repository-hdfs-availability]]
  56. [float]
  57. ===== A Note on HDFS Availability
  58. When you initialize a repository, its settings are persisted in the cluster state. When a node comes online, it will
  59. attempt to initialize all repositories for which it has settings. If your cluster has an HDFS repository configured, then
  60. all nodes in the cluster must be able to reach HDFS when starting. If not, then the node will fail to initialize the
  61. repository at start up and the repository will be unusable. If this happens, you will need to remove and re-add the
  62. repository or restart the offending node.
  63. [[repository-hdfs-security]]
  64. ==== Hadoop Security
  65. The HDFS Repository Plugin integrates seamlessly with Hadoop's authentication model. The following authentication
  66. methods are supported by the plugin:
  67. [horizontal]
  68. `simple`::
  69. Also means "no security" and is enabled by default. Uses information from underlying operating system account
  70. running Elasticsearch to inform Hadoop of the name of the current user. Hadoop makes no attempts to verify this
  71. information.
  72. `kerberos`::
  73. Authenticates to Hadoop through the usage of a Kerberos principal and keytab. Interfacing with HDFS clusters
  74. secured with Kerberos requires a few additional steps to enable (See <<repository-hdfs-security-keytabs>> and
  75. <<repository-hdfs-security-runtime>> for more info)
  76. [[repository-hdfs-security-keytabs]]
  77. [float]
  78. ===== Principals and Keytabs
  79. Before attempting to connect to a secured HDFS cluster, provision the Kerberos principals and keytabs that the
  80. Elasticsearch nodes will use for authenticating to Kerberos. For maximum security and to avoid tripping up the Kerberos
  81. replay protection, you should create a service principal per node, following the pattern of
  82. `elasticsearch/hostname@REALM`.
  83. WARNING: In some cases, if the same principal is authenticating from multiple clients at once, services may reject
  84. authentication for those principals under the assumption that they could be replay attacks. If you are running the
  85. plugin in production with multiple nodes you should be using a unique service principal for each node.
  86. On each Elasticsearch node, place the appropriate keytab file in the node's configuration location under the
  87. `repository-hdfs` directory using the name `krb5.keytab`:
  88. [source, bash]
  89. ----
  90. $> cd elasticsearch/config
  91. $> ls
  92. elasticsearch.yml jvm.options log4j2.properties repository-hdfs/ scripts/
  93. $> cd repository-hdfs
  94. $> ls
  95. krb5.keytab
  96. ----
  97. // TEST[skip:this is for demonstration purposes only
  98. NOTE: Make sure you have the correct keytabs! If you are using a service principal per node (like
  99. `elasticsearch/hostname@REALM`) then each node will need its own unique keytab file for the principal assigned to that
  100. host!
  101. // Setup at runtime (principal name)
  102. [[repository-hdfs-security-runtime]]
  103. [float]
  104. ===== Creating the Secure Repository
  105. Once your keytab files are in place and your cluster is started, creating a secured HDFS repository is simple. Just
  106. add the name of the principal that you will be authenticating as in the repository settings under the
  107. `security.principal` option:
  108. [source,js]
  109. ----
  110. PUT _snapshot/my_hdfs_repository
  111. {
  112. "type": "hdfs",
  113. "settings": {
  114. "uri": "hdfs://namenode:8020/",
  115. "path": "/user/elasticsearch/repositories/my_hdfs_repository",
  116. "security.principal": "elasticsearch@REALM"
  117. }
  118. }
  119. ----
  120. // CONSOLE
  121. // TEST[skip:we don't have hdfs set up while testing this]
  122. If you are using different service principals for each node, you can use the `_HOST` pattern in your principal
  123. name. Elasticsearch will automatically replace the pattern with the hostname of the node at runtime:
  124. [source,js]
  125. ----
  126. PUT _snapshot/my_hdfs_repository
  127. {
  128. "type": "hdfs",
  129. "settings": {
  130. "uri": "hdfs://namenode:8020/",
  131. "path": "/user/elasticsearch/repositories/my_hdfs_repository",
  132. "security.principal": "elasticsearch/_HOST@REALM"
  133. }
  134. }
  135. ----
  136. // CONSOLE
  137. // TEST[skip:we don't have hdfs set up while testing this]
  138. [[repository-hdfs-security-authorization]]
  139. [float]
  140. ===== Authorization
  141. Once Elasticsearch is connected and authenticated to HDFS, HDFS will infer a username to use for
  142. authorizing file access for the client. By default, it picks this username from the primary part of
  143. the kerberos principal used to authenticate to the service. For example, in the case of a principal
  144. like `elasticsearch@REALM` or `elasticsearch/hostname@REALM` then the username that HDFS
  145. extracts for file access checks will be `elasticsearch`.
  146. NOTE: The repository plugin makes no assumptions of what Elasticsearch's principal name is. The main fragment of the
  147. Kerberos principal is not required to be `elasticsearch`. If you have a principal or service name that works better
  148. for you or your organization then feel free to use it instead!