update-settings.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. [[cluster-update-settings]]
  2. === Cluster update settings API
  3. ++++
  4. <titleabbrev>Cluster update settings</titleabbrev>
  5. ++++
  6. Updates cluster-wide settings.
  7. [[cluster-update-settings-api-request]]
  8. ==== {api-request-title}
  9. `PUT /_cluster/settings`
  10. [[cluster-update-settings-api-prereqs]]
  11. ==== {api-prereq-title}
  12. * If the {es} {security-features} are enabled, you must have the `manage`
  13. <<privileges-list-cluster,cluster privilege>> to use this API.
  14. [[cluster-update-settings-api-desc]]
  15. ==== {api-description-title}
  16. With specifications in the request body, this API call can update cluster
  17. settings. Updates to settings can be persistent, meaning they apply across
  18. restarts, or transient, where they don't survive a full cluster restart.
  19. You can reset persistent or transient settings by assigning a `null` value. If a
  20. transient setting is reset, the first one of these values that is defined is
  21. applied:
  22. * the persistent setting
  23. * the setting in the configuration file
  24. * the default value.
  25. The order of precedence for cluster settings is:
  26. 1. transient cluster settings
  27. 2. persistent cluster settings
  28. 3. settings in the `elasticsearch.yml` configuration file.
  29. It's best to set all cluster-wide settings with the `settings` API and use the
  30. `elasticsearch.yml` file only for local configurations. This way you can be sure that
  31. the setting is the same on all nodes. If, on the other hand, you define different
  32. settings on different nodes by accident using the configuration file, it is very
  33. difficult to notice these discrepancies.
  34. NOTE: Transient settings are deprecated and will be removed in a future release.
  35. Prefer using persistent cluster settings instead.
  36. [[cluster-update-settings-api-query-params]]
  37. ==== {api-query-parms-title}
  38. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
  39. `include_defaults`::
  40. (Optional, Boolean) If `true`, returns all default cluster settings.
  41. Defaults to `false`.
  42. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  43. [[cluster-update-settings-api-example]]
  44. ==== {api-examples-title}
  45. An example of a persistent update:
  46. [source,console]
  47. --------------------------------------------------
  48. PUT /_cluster/settings
  49. {
  50. "persistent" : {
  51. "indices.recovery.max_bytes_per_sec" : "50mb"
  52. }
  53. }
  54. --------------------------------------------------
  55. An example of a transient update:
  56. [source,console]
  57. --------------------------------------------------
  58. PUT /_cluster/settings?flat_settings=true
  59. {
  60. "transient" : {
  61. "indices.recovery.max_bytes_per_sec" : "20mb"
  62. }
  63. }
  64. --------------------------------------------------
  65. // TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
  66. The response to an update returns the changed setting, as in this response to
  67. the transient example:
  68. [source,console-result]
  69. --------------------------------------------------
  70. {
  71. ...
  72. "persistent" : { },
  73. "transient" : {
  74. "indices.recovery.max_bytes_per_sec" : "20mb"
  75. }
  76. }
  77. --------------------------------------------------
  78. // TESTRESPONSE[s/\.\.\./"acknowledged": true,/]
  79. This example resets a setting:
  80. [source,console]
  81. --------------------------------------------------
  82. PUT /_cluster/settings
  83. {
  84. "transient" : {
  85. "indices.recovery.max_bytes_per_sec" : null
  86. }
  87. }
  88. --------------------------------------------------
  89. // TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
  90. The response does not include settings that have been reset:
  91. [source,console-result]
  92. --------------------------------------------------
  93. {
  94. ...
  95. "persistent" : {},
  96. "transient" : {}
  97. }
  98. --------------------------------------------------
  99. // TESTRESPONSE[s/\.\.\./"acknowledged": true,/]
  100. You can also reset settings using wildcards. For example, to reset
  101. all dynamic `indices.recovery` settings:
  102. [source,console]
  103. --------------------------------------------------
  104. PUT /_cluster/settings
  105. {
  106. "transient" : {
  107. "indices.recovery.*" : null
  108. }
  109. }
  110. --------------------------------------------------
  111. // TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]