keactrl.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY mdash "&#x2014;" >
  5. ]>
  6. <chapter id="keactrl">
  7. <title>Managing Kea with keactrl</title>
  8. <section id="keactrl-overview">
  9. <title>Overview</title>
  10. <para>keactrl is a shell script which controls the startup, shutdown
  11. and reconfiguration of the Kea servers (<command>kea-dhcp4</command>,
  12. <command>kea-dhcp6</command> and <command>kea-dhcp-ddns</command>). It
  13. also provides the means for checking the current status of the servers
  14. and determining the configuration files in use.
  15. </para>
  16. </section>
  17. <section id="keactrl-usage">
  18. <title>Command Line Options</title>
  19. <para><command>keactrl</command> is run as follows:
  20. <screen>
  21. keactrl &lt;command&gt; [-c keactrl-config-file] [-s server[,server,..]]
  22. </screen>
  23. </para>
  24. <para>
  25. <command>&lt;command&gt;</command> is the one of the commands
  26. described in <xref linkend="keactrl-commands"/>.
  27. </para>
  28. <para>
  29. The optional <command>-c keactrl-config-file</command> switch
  30. allows specification of an alternate <command>keactrl</command>
  31. configuration file. (<command>--ctrl-config</command> is a synonym for
  32. <command>-c</command>.) In the absence of <command>-c</command>,
  33. <command>keactrl</command> will use the default configuration
  34. file <filename>[kea-install-dir]/etc/kea/keactrl.conf</filename>.
  35. </para>
  36. <para>
  37. The optional <command>-s server[,server ...]</command> switch selects
  38. the servers to which the command is issued.
  39. (<command>--server</command> is a synonym for <command>-s</command>.)
  40. If absent, the command is sent to all servers enabled in the keactrl
  41. configuration file.
  42. If multiple servers are specified, they
  43. should be separated by commas with no intervening spaces.
  44. </para>
  45. </section>
  46. <section id="keactrl-config-file">
  47. <title>The keactrl Configuration File</title>
  48. <para>
  49. Depending on requirements, not all of the available servers need
  50. be run. The keactrl configuration file sets which servers are
  51. enabled and which are disabled. The default configuration
  52. file is <filename>[kea-install-dir]/etc/kea/keactrl.conf</filename>,
  53. but this can be overridden on a per-command basis using the
  54. <command>-c</command> switch.
  55. </para>
  56. <para>
  57. The contents of <filename>keactrl.conf</filename> are:
  58. <screen>
  59. # This is a configuration file for keactrl script which controls
  60. # the startup, shutdown, reconfiguration and gathering the status
  61. # of the Kea servers.
  62. # prefix holds the location where the Kea is installed.
  63. prefix=/usr/local
  64. # Location of Kea configuration file.
  65. kea_config_file=${prefix}/etc/kea/kea.conf
  66. # Location of Kea binaries.
  67. exec_prefix=${prefix}
  68. dhcp4_srv=${exec_prefix}/sbin/kea/kea-dhcp4
  69. dhcp6_srv=${exec_prefix}/sbin/kea/kea-dhcp6
  70. dhcp_ddns_srv=${exec_prefix}/sbin/kea/kea-dhcp-ddns
  71. # Start DHCPv4 server?
  72. dhcp4=yes
  73. # Start DHCPv6 server?
  74. dhcp6=yes
  75. # Start DHCP DDNS server?
  76. dhcp_ddns=yes
  77. # Be verbose?
  78. kea_verbose=no
  79. </screen>
  80. </para>
  81. <para>
  82. The <parameter>dhcp4</parameter>, <parameter>dhcp6</parameter> and
  83. <parameter>dhcp_ddns</parameter> parameters set to "yes" configure
  84. <command>keactrl</command> to manage (start, reconfigure) all servers,
  85. i.e. <command>kea-dhcp4</command>, <command>kea-dhcp6</command> and
  86. <command>kea-dhcp-ddns</command>. When any of these parameters is set to
  87. "no" the <command>keactrl</command> will ignore
  88. the corresponding server when starting or reconfiguring Kea.
  89. </para>
  90. <para>
  91. By default, Kea servers managed by <command>keactrl</command> are
  92. located in <filename>[kea-install-dir]/sbin</filename>. This
  93. should work for most installations. If the default
  94. location needs to be altered for any reason, the paths
  95. specified with the <parameter>dhcp4_srv</parameter>,
  96. <parameter>dhcp6_srv</parameter> and <parameter>dhcp_ddns_srv</parameter>
  97. parameters should be modified.
  98. </para>
  99. <para>
  100. The <parameter>kea_verbose</parameter> parameter specifies the verbosity
  101. of the servers being started. When <parameter>kea_verbose</parameter>
  102. is set to "yes" the logging level of the server is set to DEBUG.
  103. Modification of the logging severity in a configuration file, as
  104. described in <xref linkend="logging"/>, will have no effect as long
  105. as the <parameter>kea_verbose</parameter> is set to "yes". Setting
  106. it to "no" will cause the server to use the logging levels specified
  107. in the Kea configuration file for respective loggers. If no
  108. logging configuration is specified, the default settings will be
  109. used.
  110. </para>
  111. <note>
  112. <para>
  113. The verbosity for the server is set when it is started. Once
  114. started, the verbosity can be only changed by stopping the server and
  115. starting it again with the new value of the
  116. <parameter>kea_verbose</parameter> parameter.
  117. </para>
  118. </note>
  119. </section>
  120. <section id="keactrl-commands">
  121. <title>Commands</title>
  122. <para>The following commands are supported by <command>keactrl</command>:
  123. <itemizedlist>
  124. <listitem><simpara>
  125. <command>start</command> - starts selected servers.
  126. </simpara></listitem>
  127. <listitem><simpara>
  128. <command>stop</command> - stops all running servers.
  129. </simpara></listitem>
  130. <listitem><simpara>
  131. <command>reload</command> - triggers reconfiguration of the
  132. selected servers by sending the SIGHUP signal to them.
  133. </simpara></listitem>
  134. <listitem><simpara>
  135. <command>status</command> - returns the status of the servers (active
  136. or inactive) and the names of the configuration files in use.
  137. </simpara></listitem>
  138. </itemizedlist>
  139. </para>
  140. <para>Typical output from <command>keactrl</command> when starting
  141. the servers looks similar to the following:
  142. <screen>
  143. <userinput>$ keactrl start</userinput>
  144. INFO/keactrl: Starting kea-dhcp4 -c /usr/local/etc/kea/kea.conf -d
  145. INFO/keactrl: Starting kea-dhcp6 -c /usr/local/etc/kea/kea.conf -d
  146. INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea.conf -d
  147. </screen>
  148. </para>
  149. <para>Kea's servers create PID files upon startup. These files are used
  150. by keactrl to determine whether or not a given server is running. If
  151. one or more servers are running when the start command is issued, the
  152. output will look similar to the following:
  153. <screen>
  154. <userinput>$ keactrl start</userinput>
  155. INFO/keactrl: kea-dhcp4 appears to be running, see: PID 10918, PID file: /usr/local/var/kea/kea.kea-dhcp4.pid.
  156. INFO/keactrl: kea-dhcp6 appears to be running, see: PID 10924, PID file: /usr/local/var/kea/kea.kea-dhcp6.pid.
  157. INFO/keactrl: kea-dhcp-ddns appears to be running, see: PID 10930, PID file: /usr/local/var/kea/kea.kea-dhcp-ddns.pid.
  158. </screen>
  159. During normal shutdowns these PID files are deleted. They may, however,
  160. be left over as remnants following a system crash. It is possible,
  161. though highly unlikely, that upon system restart the PIDs they contain
  162. actually refer to processes unrelated to Kea. This condition will cause
  163. keactrl to decide that the servers are running, when in fact they are
  164. not. In such a case the PID files as listed in the keactrl output
  165. must be manually deleted.
  166. </para>
  167. <para>The following command stops all servers:
  168. <screen>
  169. <userinput>$ keactrl stop</userinput>
  170. INFO/keactrl: Stopping kea-dhcp4...
  171. INFO/keactrl: Stopping kea-dhcp6...
  172. INFO/keactrl: Stopping kea-dhcp-ddns...
  173. </screen>
  174. Note that the <command>stop</command> will attempt to stop all servers
  175. regardless of whether they are "enabled" in the <filename>keactrl.conf</filename>.
  176. If any of the servers are not running, an informational message
  177. is displayed as in the <command>stop</command> command output below.
  178. <screen>
  179. <userinput>$ keactrl stop</userinput>
  180. INFO/keactrl: kea-dhcp4 isn't running.
  181. INFO/keactrl: kea-dhcp6 isn't running.
  182. INFO/keactrl: kea-dhcp-ddns isn't running.
  183. </screen>
  184. </para>
  185. <para>
  186. As already mentioned, the reconfiguration of each Kea server is
  187. triggered by the SIGHUP signal. The <command>reload</command>
  188. command sends the SIGHUP signal to the servers that are enabled in
  189. the <command>keactrl</command> configuration file and are
  190. currently running. When a server receives the SIGHUP signal it
  191. re-reads its configuration file and, if the new configuration is
  192. valid, uses the new configuration. A reload is executed as follows:
  193. <screen>
  194. <userinput>$ keactrl reload</userinput>
  195. INFO/keactrl: Reloading kea-dhcp4...
  196. INFO/keactrl: Reloading kea-dhcp6...
  197. INFO/keactrl: Reloading kea-dhcp-ddns...
  198. </screen>
  199. If any of the servers are not running, an informational message
  200. is displayed as in the <command>reload</command> command output below.
  201. <screen>
  202. <userinput>$ keactrl stop</userinput>
  203. INFO/keactrl: kea-dhcp4 isn't running.
  204. INFO/keactrl: kea-dhcp6 isn't running.
  205. INFO/keactrl: kea-dhcp-ddns isn't running.
  206. </screen>
  207. </para>
  208. <note>
  209. <para>
  210. Currently <command>keactrl</command> does not report configuration
  211. failures when the server is started or reconfigured. To check if
  212. the server's configuration succeeded the Kea log must be examined
  213. for errors. By default, this is written to the syslog file.
  214. </para>
  215. </note>
  216. <para>
  217. Sometimes it is useful to check which servers are running. The
  218. <command>status</command> reports this, typical output looking like:
  219. <screen>
  220. <userinput>$ keactrl status</userinput>
  221. DHCPv4 server: active
  222. DHCPv6 server: inactive
  223. DHCP DDNS: active
  224. Kea configuration file: /usr/local/etc/kea/kea.conf
  225. keactrl configuration file: /usr/local/etc/kea/keactrl.conf
  226. </screen>
  227. </para>
  228. </section>
  229. <section id="keactrl-overriding-servers">
  230. <title>Overriding the Server Selection</title>
  231. <para>
  232. The optional <command>-s</command> switch allows
  233. the selection of the servers to which <command>keactrl</command>
  234. command is issued. For example, the following
  235. instructs <command>keactrl</command> to stop the
  236. <command>kea-dhcp4</command> and <command>kea-dhcp6</command> servers
  237. and leave the <command>kea-dhcp-ddns</command> server running:
  238. <screen>
  239. <userinput>$ keactrl stop -s dhcp4,dhcp6</userinput>
  240. </screen>
  241. </para>
  242. <para>
  243. Similarly, the following
  244. will only start the <command>kea-dhcp4</command> and
  245. <command>kea-dhcp-ddns</command> servers and not
  246. <command>kea-dhcp6</command>.
  247. <screen>
  248. <userinput>$ keactrl start -s dhcp4,dhcp_ddns</userinput>
  249. </screen>
  250. </para>
  251. <para>
  252. Note that the behavior of the <command>-s</command> switch
  253. with the <command>start</command> and <command>reload</command> commands
  254. is different to its behavior with the <command>stop</command> command.
  255. On <command>start</command> and <command>reload</command>,
  256. <command>keactrl</command> will check if the servers given as
  257. parameters to the <command>-s</command> switch are
  258. enabled in the <command>keactrl</command> configuration file:
  259. if not, the server will be ignored. For <command>stop</command> however,
  260. this check is not made: the command is applied to all listed servers,
  261. regardless of whether they have been enabled in the file.
  262. </para>
  263. <para>
  264. The following keywords can be used with the <command>-s</command>
  265. command line option:
  266. <itemizedlist>
  267. <listitem><simpara>
  268. <command>dhcp4</command> for <command>kea-dhcp4.</command>
  269. </simpara></listitem>
  270. <listitem><simpara>
  271. <command>dhcp6</command> for <command>kea-dhcp6.</command>
  272. </simpara></listitem>
  273. <listitem><simpara>
  274. <command>dhcp_ddns</command> for <command>kea-dhcp-ddns.</command>
  275. </simpara></listitem>
  276. <listitem><simpara>
  277. <command>all</command> for all servers (default).
  278. </simpara></listitem>
  279. </itemizedlist>
  280. </para>
  281. </section>
  282. </chapter>