discovery-file.asciidoc 3.8 KB

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