1
0

index.rst 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. .. _troubleshooting:
  2. ===============
  3. Troubleshooting
  4. ===============
  5. The intent of the troubleshooting section is to introduce solutions to a
  6. number of common issues encountered by users and the tools that are available
  7. to aid in developing States and Salt code.
  8. Troubleshooting the Salt Master
  9. ===============================
  10. If your Salt master is having issues such as minions not returning data, slow
  11. execution times, or a variety of other issues, the following links contain
  12. details on troubleshooting the most common issues encountered:
  13. .. toctree::
  14. :maxdepth: 2
  15. master
  16. Troubleshooting the Salt Minion
  17. ===============================
  18. In the event that your Salt minion is having issues, a variety of solutions
  19. and suggestions are available. Please refer to the following links for more information:
  20. .. toctree::
  21. :maxdepth: 2
  22. minion
  23. Running in the Foreground
  24. =========================
  25. A great deal of information is available via the debug logging system, if you
  26. are having issues with minions connecting or not starting run the minion and/or
  27. master in the foreground:
  28. .. code-block:: bash
  29. salt-master -l debug
  30. salt-minion -l debug
  31. Anyone wanting to run Salt daemons via a process supervisor such as `monit`_,
  32. `runit`_, or `supervisord`_, should omit the ``-d`` argument to the daemons and
  33. run them in the foreground.
  34. .. _`monit`: https://mmonit.com/monit/
  35. .. _`runit`: http://smarden.org/runit/
  36. .. _`supervisord`: http://supervisord.org/
  37. What Ports do the Master and Minion Need Open?
  38. ==============================================
  39. No ports need to be opened up on each minion. For the master, TCP ports 4505
  40. and 4506 need to be open. If you've put both your Salt master and minion in
  41. debug mode and don't see an acknowledgment that your minion has connected,
  42. it could very well be a firewall.
  43. You can check port connectivity from the minion with the nc command:
  44. .. code-block:: bash
  45. nc -v -z salt.master.ip 4505
  46. nc -v -z salt.master.ip 4506
  47. There is also a :ref:`firewall configuration<firewall>`
  48. document that might help as well.
  49. If you've enabled the right TCP ports on your operating system or Linux
  50. distribution's firewall and still aren't seeing connections, check that no
  51. additional access control system such as `SELinux`_ or `AppArmor`_ is blocking
  52. Salt.
  53. .. _`SELinux`: https://en.wikipedia.org/wiki/Security-Enhanced_Linux
  54. .. _`AppArmor`: https://gitlab.com/apparmor/apparmor/-/wikis/home
  55. .. _using-salt-call:
  56. Using salt-call
  57. ===============
  58. The ``salt-call`` command was originally developed for aiding in the development
  59. of new Salt modules. Since then, many applications have been developed for
  60. running any Salt module locally on a minion. These range from the original
  61. intent of salt-call, development assistance, to gathering more verbose output
  62. from calls like :mod:`state.apply <salt.modules.state.apply_>`.
  63. When initially creating your state tree, it is generally recommended to invoke
  64. :mod:`state.apply <salt.modules.state.apply_>` directly from the minion with
  65. ``salt-call``, rather than remotely from the master. This displays far more
  66. information about the execution than calling it remotely. For even more
  67. verbosity, increase the loglevel using the ``-l`` argument:
  68. .. code-block:: bash
  69. salt-call -l debug state.apply
  70. The main difference between using ``salt`` and using ``salt-call`` is that
  71. ``salt-call`` is run from the minion, and it only runs the selected function on
  72. that minion. By contrast, ``salt`` is run from the master, and requires you to
  73. specify the minions on which to run the command using salt's :ref:`targeting
  74. system <targeting>`.
  75. Too many open files
  76. ===================
  77. The salt-master needs at least 2 sockets per host that connects to it, one for
  78. the Publisher and one for response port. Thus, large installations may, upon
  79. scaling up the number of minions accessing a given master, encounter:
  80. .. code-block:: bash
  81. 12:45:29,289 [salt.master ][INFO ] Starting Salt worker process 38
  82. Too many open files
  83. sock != -1 (tcp_listener.cpp:335)
  84. The solution to this would be to check the number of files allowed to be
  85. opened by the user running salt-master (root by default):
  86. .. code-block:: bash
  87. [root@salt-master ~]# ulimit -n
  88. 1024
  89. And modify that value to be at least equal to the number of minions x 2.
  90. This setting can be changed in limits.conf as the nofile value(s),
  91. and activated upon new a login of the specified user.
  92. So, an environment with 1800 minions, would need 1800 x 2 = 3600 as a minimum.
  93. Salt Master Stops Responding
  94. ============================
  95. There are known bugs with ZeroMQ versions less than 2.1.11 which can cause the
  96. Salt master to not respond properly. If you're running a ZeroMQ version greater
  97. than or equal to 2.1.9, you can work around the bug by setting the sysctls
  98. ``net.core.rmem_max`` and ``net.core.wmem_max`` to 16777216. Next, set the third
  99. field in ``net.ipv4.tcp_rmem`` and ``net.ipv4.tcp_wmem`` to at least 16777216.
  100. You can do it manually with something like:
  101. .. code-block:: bash
  102. # echo 16777216 > /proc/sys/net/core/rmem_max
  103. # echo 16777216 > /proc/sys/net/core/wmem_max
  104. # echo "4096 87380 16777216" > /proc/sys/net/ipv4/tcp_rmem
  105. # echo "4096 87380 16777216" > /proc/sys/net/ipv4/tcp_wmem
  106. Or with the following Salt state:
  107. .. code-block:: yaml
  108. :linenos:
  109. net.core.rmem_max:
  110. sysctl:
  111. - present
  112. - value: 16777216
  113. net.core.wmem_max:
  114. sysctl:
  115. - present
  116. - value: 16777216
  117. net.ipv4.tcp_rmem:
  118. sysctl:
  119. - present
  120. - value: 4096 87380 16777216
  121. net.ipv4.tcp_wmem:
  122. sysctl:
  123. - present
  124. - value: 4096 87380 16777216
  125. Salt and SELinux
  126. ================
  127. Currently there are no SELinux policies for Salt. For the most part Salt runs
  128. without issue when SELinux is running in Enforcing mode. This is because when
  129. the minion executes as a daemon the type context is changed to ``initrc_t``.
  130. The problem with SELinux arises when using salt-call or running the minion in
  131. the foreground, since the type context stays ``unconfined_t``.
  132. This problem is generally manifest in the rpm install scripts when using the
  133. pkg module. Until a full SELinux Policy is available for Salt the solution
  134. to this issue is to set the execution context of ``salt-call`` and
  135. ``salt-minion`` to rpm_exec_t:
  136. .. code-block:: bash
  137. # CentOS 5 and RHEL 5:
  138. chcon -t system_u:system_r:rpm_exec_t:s0 /usr/bin/salt-minion
  139. chcon -t system_u:system_r:rpm_exec_t:s0 /usr/bin/salt-call
  140. # CentOS 6 and RHEL 6:
  141. chcon system_u:object_r:rpm_exec_t:s0 /usr/bin/salt-minion
  142. chcon system_u:object_r:rpm_exec_t:s0 /usr/bin/salt-call
  143. This works well, because the ``rpm_exec_t`` context has very broad control over
  144. other types.
  145. Red Hat Enterprise Linux 5
  146. ==========================
  147. Salt requires Python 2.6 or 2.7. Red Hat Enterprise Linux 5 and its variants
  148. come with Python 2.4 installed by default. When installing on RHEL 5 from the
  149. `EPEL repository`_ this is handled for you. But, if you run Salt from git, be
  150. advised that its dependencies need to be installed from EPEL and that Salt
  151. needs to be run with the ``python26`` executable.
  152. .. _`EPEL repository`: https://fedoraproject.org/wiki/EPEL
  153. Common YAML Gotchas
  154. ===================
  155. An extensive list of YAML idiosyncrasies has been compiled:
  156. .. toctree::
  157. :maxdepth: 2
  158. yaml_idiosyncrasies
  159. Live Python Debug Output
  160. ========================
  161. If the minion or master seems to be unresponsive, a SIGUSR1 can be passed to
  162. the processes to display where in the code they are running. If encountering a
  163. situation like this, this debug information can be invaluable. First make
  164. sure the master of minion are running in the foreground:
  165. .. code-block:: bash
  166. salt-master -l debug
  167. salt-minion -l debug
  168. Then pass the signal to the master or minion when it seems to be unresponsive:
  169. .. code-block:: bash
  170. killall -SIGUSR1 salt-master
  171. killall -SIGUSR1 salt-minion
  172. Also under BSD and macOS in addition to SIGUSR1 signal, debug subroutine set
  173. up for SIGINFO which has an advantage of being sent by Ctrl+T shortcut.
  174. When filing an issue or sending questions to the mailing list for a problem
  175. with an unresponsive daemon this information can be invaluable.
  176. Salt 0.16.x minions cannot communicate with a 0.17.x master
  177. ===========================================================
  178. As of release 0.17.1 you can no longer run different versions of Salt on your
  179. Master and Minion servers. This is due to a protocol change for security
  180. purposes. The Salt team will continue to attempt to ensure versions are as
  181. backwards compatible as possible.
  182. Debugging the Master and Minion
  183. ===============================
  184. A list of common :ref:`master<troubleshooting-salt-master>` and
  185. :ref:`minion<troubleshooting-minion-salt-call>` troubleshooting steps provide a
  186. starting point for resolving issues you may encounter.