systemd.asciidoc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ==== Running Elasticsearch with `systemd`
  2. To configure Elasticsearch to start automatically when the system boots up,
  3. run the following commands:
  4. [source,sh]
  5. --------------------------------------------------
  6. sudo /bin/systemctl daemon-reload
  7. sudo /bin/systemctl enable elasticsearch.service
  8. --------------------------------------------------
  9. Elasticsearch can be started and stopped as follows:
  10. [source,sh]
  11. --------------------------------------------
  12. sudo systemctl start elasticsearch.service
  13. sudo systemctl stop elasticsearch.service
  14. --------------------------------------------
  15. These commands provide no feedback as to whether Elasticsearch was started
  16. successfully or not. Instead, this information will be written in the log
  17. files located in `/var/log/elasticsearch/`.
  18. If you have password-protected your {es} keystore, you will need to provide
  19. `systemd` with the keystore password using a local file and systemd environment
  20. variables. This local file should be protected while it exists and may be
  21. safely deleted once Elasticsearch is up and running.
  22. [source,sh]
  23. -----------------------------------------------------------------------------------
  24. echo "keystore_password" > /path/to/my_pwd_file.tmp
  25. chmod 600 /path/to/my_pwd_file.tmp
  26. sudo systemctl set-environment ES_KEYSTORE_PASSPHRASE_FILE=/path/to/my_pwd_file.tmp
  27. sudo systemctl start elasticsearch.service
  28. -----------------------------------------------------------------------------------
  29. By default the Elasticsearch service doesn't log information in the `systemd`
  30. journal. To enable `journalctl` logging, the `--quiet` option must be removed
  31. from the `ExecStart` command line in the `elasticsearch.service` file.
  32. When `systemd` logging is enabled, the logging information are available using
  33. the `journalctl` commands:
  34. To tail the journal:
  35. [source,sh]
  36. --------------------------------------------
  37. sudo journalctl -f
  38. --------------------------------------------
  39. To list journal entries for the elasticsearch service:
  40. [source,sh]
  41. --------------------------------------------
  42. sudo journalctl --unit elasticsearch
  43. --------------------------------------------
  44. To list journal entries for the elasticsearch service starting from a given time:
  45. [source,sh]
  46. --------------------------------------------
  47. sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"
  48. --------------------------------------------
  49. Check `man journalctl` or https://www.freedesktop.org/software/systemd/man/journalctl.html for
  50. more command line options.