discovery-file.asciidoc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. [[discovery-file]]
  2. === File-Based Discovery Plugin
  3. The file-based discovery plugin uses a list of hosts/ports in a `unicast_hosts.txt` file
  4. in the `config/discovery-file` directory for unicast discovery.
  5. [[discovery-file-install]]
  6. [float]
  7. ==== Installation
  8. This plugin can be installed using the plugin manager:
  9. [source,sh]
  10. ----------------------------------------------------------------
  11. sudo bin/elasticsearch-plugin install discovery-file
  12. ----------------------------------------------------------------
  13. The plugin must be installed on every node in the cluster, and each node must
  14. be restarted after installation. Note that installing the plugin will add a
  15. `discovery-file` directory to the `config` folder, and a default `unicast_hosts.txt`
  16. file that must be edited with the correct unicast hosts list before starting the node.
  17. This plugin can be downloaded for <<plugin-management-custom-url,offline install>> from
  18. {plugin_url}/discovery-file/discovery-file-{version}.zip.
  19. [[discovery-file-remove]]
  20. [float]
  21. ==== Removal
  22. The plugin can be removed with the following command:
  23. [source,sh]
  24. ----------------------------------------------------------------
  25. sudo bin/elasticsearch-plugin remove discovery-file
  26. ----------------------------------------------------------------
  27. The node must be stopped before removing the plugin.
  28. [[discovery-file-usage]]
  29. [float]
  30. ==== Using the file-based discovery plugin
  31. The file-based discovery plugin provides the ability to specify the
  32. unicast hosts list through a simple `unicast_hosts.txt` file that can
  33. be dynamically updated at any time. To enable, add the following in `elasticsearch.yml`:
  34. [source,yaml]
  35. ----
  36. discovery.zen.hosts_provider: file
  37. ----
  38. This plugin simply provides a facility to supply the unicast hosts list for
  39. zen discovery through an external file that can be updated at any time by a side process.
  40. For example, this gives a convenient mechanism for an Elasticsearch instance
  41. that is run in docker containers to be dynamically supplied a list of IP
  42. addresses to connect to for zen discovery when those IP addresses may not be
  43. known at node startup.
  44. Note that the file-based discovery plugin is meant to augment the unicast
  45. hosts list in `elasticsearch.yml` (if specified), not replace it. Therefore,
  46. if there are valid unicast host entries in `discovery.zen.ping.unicast.hosts`,
  47. they will be used in addition to those supplied in `unicast_hosts.txt`.
  48. Anytime a change is made to the `unicast_hosts.txt` file, even as Elasticsearch
  49. continues to run, the new changes will be picked up by the plugin and the
  50. new hosts list will be used for the next pinging round for master election.
  51. Upon installation of the plugin, a default `unicast_hosts.txt` file will
  52. be found in the `$CONFIG_DIR/discovery-file` directory. This default file
  53. will contain some comments about what the file should contain. All comments
  54. for this file must appear on their lines starting with `#` (i.e. comments
  55. cannot start in the middle of a line).
  56. [[discovery-file-format]]
  57. [float]
  58. ==== unicast_hosts.txt file format
  59. The format of the file is to specify one unicast host entry per line.
  60. Each unicast host entry consists of the host (host name or IP address) and
  61. an optional transport port number. If the port number is specified, is must
  62. come immediately after the host (on the same line) separated by a `:`.
  63. If the port number is not specified, a default value of 9300 is used.
  64. For example, this is an example of `unicast_hosts.txt` for a cluster with
  65. four nodes that participate in unicast discovery, some of which are not
  66. running on the default port:
  67. [source,txt]
  68. ----------------------------------------------------------------
  69. 10.10.10.5
  70. 10.10.10.6:9305
  71. 10.10.10.5:10005
  72. # an IPv6 address
  73. [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:9301
  74. ----------------------------------------------------------------
  75. Host names are allowed instead of IP addresses (similar to
  76. `discovery.zen.ping.unicast.hosts`), and IPv6 addresses must be
  77. specified in brackets with the port coming after the brackets.