keactrl.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. Otherwise, the default logging level is used.
  104. </para>
  105. <note>
  106. <para>
  107. The verbosity for the server is set when it is started. Once
  108. started, the verbosity can be only changed by stopping the server and
  109. starting it again with the new value of the
  110. <parameter>kea_verbose</parameter> parameter.
  111. </para>
  112. </note>
  113. </section>
  114. <section id="keactrl-commands">
  115. <title>Commands</title>
  116. <para>The following commands are supported by <command>keactrl</command>
  117. to perform specific operations on the Kea servers:
  118. <itemizedlist>
  119. <listitem><simpara>
  120. <command>start</command> - starts selected servers.
  121. </simpara></listitem>
  122. <listitem><simpara>
  123. <command>stop</command> - stops all running servers.
  124. </simpara></listitem>
  125. <listitem><simpara>
  126. <command>reload</command> - triggers reconfiguration of the
  127. selected servers by sending the SIGHUP signal to them.
  128. </simpara></listitem>
  129. <listitem><simpara>
  130. <command>status</command> - returns the status of the servers (active
  131. or inactive) and the names of the configuration files in use.
  132. </simpara></listitem>
  133. </itemizedlist>
  134. </para>
  135. <para>Typical output from <command>keactrl</command> when starting
  136. the servers looks similar to the following:
  137. <screen>
  138. <userinput>$ keactrl start</userinput>
  139. INFO/keactrl: Starting kea-dhcp4 -c /usr/local/etc/kea/kea.conf -d
  140. INFO/keactrl: Starting kea-dhcp6 -c /usr/local/etc/kea/kea.conf -d
  141. INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea.conf -d
  142. </screen>
  143. </para>
  144. <para>Kea's servers create PID files upon startup. These files are used
  145. by keactrl to deteremine whether or not a given server is running. If
  146. one or more servers are running when the start command is issued, the
  147. output will look similiar to the following:
  148. <screen>
  149. <userinput>$ keactrl start</userinput>
  150. INFO/keactrl: kea-dhcp4 appears to be running, see: PID 10918, PID file: /usr/local/var/kea/kea.kea-dhcp4.pid.
  151. INFO/keactrl: kea-dhcp6 appears to be running, see: PID 10924, PID file: /usr/local/var/kea/kea.kea-dhcp6.pid.
  152. INFO/keactrl: kea-dhcp-ddns appears to be running, see: PID 10930, PID file: /usr/local/var/kea/kea.kea-dhcp-ddns.pid.
  153. </screen>
  154. During normal shutdowns these PID files are deleted. They may, however,
  155. be left over as remnants following a system crash. It is possible,
  156. though highly unlikely, that upon system restart the PIDs they contain
  157. actually refer to processes unrelated to Kea. This condition will cause
  158. keactrl to decide that the servers are running, when in fact they are
  159. not. In such a case the PID files as listed in the keactrl output
  160. must be manually deleted.
  161. </para>
  162. <para>The following command stops all servers:
  163. <screen>
  164. <userinput>$ keactrl stop</userinput>
  165. INFO/keactrl: Stopping kea-dhcp4...
  166. INFO/keactrl: Stopping kea-dhcp6...
  167. INFO/keactrl: Stopping kea-dhcp-ddns...
  168. </screen>
  169. Note that the <command>stop</command> will attempt to stop all servers
  170. regardless of whether they are "enabled" in the <filename>keactrl.conf</filename>.
  171. If any of the servers are not running, an informational message
  172. is displayed as in the <command>stop</command> command output below.
  173. <screen>
  174. <userinput>$ keactrl stop</userinput>
  175. INFO/keactrl: kea-dhcp4 isn't running.
  176. INFO/keactrl: kea-dhcp6 isn't running.
  177. INFO/keactrl: kea-dhcp-ddns isn't running.
  178. </screen>
  179. </para>
  180. <para>
  181. As already mentioned, the reconfiguration of each Kea server is
  182. triggered by the SIGHUP signal. The <command>reload</command>
  183. command sends the SIGHUP signal to the servers that are enabled in
  184. the <command>keactrl</command> configuration file and are
  185. currently running. When a server receives the SIGHUP signal it
  186. re-reads its configuration file and, if the new configuration is
  187. valid, uses the new configuration. A reload is executed as follows:
  188. <screen>
  189. <userinput>$ keactrl reload</userinput>
  190. INFO/keactrl: Reloading kea-dhcp4...
  191. INFO/keactrl: Reloading kea-dhcp6...
  192. INFO/keactrl: Reloading kea-dhcp-ddns...
  193. </screen>
  194. If any of the servers are not running, an informational message
  195. is displayed as in the <command>reload</command> command output below.
  196. <screen>
  197. <userinput>$ keactrl stop</userinput>
  198. INFO/keactrl: kea-dhcp4 isn't running.
  199. INFO/keactrl: kea-dhcp6 isn't running.
  200. INFO/keactrl: kea-dhcp-ddns isn't running.
  201. </screen>
  202. </para>
  203. <note>
  204. <para>
  205. Currently <command>keactrl</command> does not report configuration
  206. failures when the server is started or reconfigured. To check if
  207. the server's configuration succeeded the Kea log must be examined
  208. for errors. By default, this is written to the syslog file.
  209. </para>
  210. </note>
  211. <para>
  212. Sometimes it is useful to check which servers are running. The
  213. <command>status</command> reports this, typical output looking like:
  214. <screen>
  215. <userinput>$ keactrl status</userinput>
  216. DHCPv4 server: active
  217. DHCPv6 server: inactive
  218. DHCP DDNS: active
  219. Kea configuration file: /usr/local/etc/kea/kea.conf
  220. keactrl configuration file: /usr/local/etc/kea/keactrl.conf
  221. </screen>
  222. </para>
  223. </section>
  224. <section id="keactrl-overriding-servers">
  225. <title>Overriding the Server Selection</title>
  226. <para>
  227. The optional <command>-s</command> switch allows
  228. the selection of the servers to which <command>keactrl</command>
  229. command is issued. For example, the following
  230. instructs <command>keactrl</command> to stop the
  231. <command>kea-dhcp4</command> and <command>kea-dhcp6</command> servers
  232. and leave the <command>kea-dhcp-ddns</command> server running:
  233. <screen>
  234. <userinput>$ keactrl stop -s dhcp4,dhcp6</userinput>
  235. </screen>
  236. </para>
  237. <para>
  238. Similarly, the following
  239. will only start the <command>kea-dhcp4</command> and
  240. <command>kea-dhcp-ddns</command> servers and not
  241. <command>kea-dhcp6</command>.
  242. <screen>
  243. <userinput>$ keactrl start -s dhcp4,dhcp_ddns</userinput>
  244. </screen>
  245. </para>
  246. <para>
  247. Note that the behavior of the <command>-s</command> switch
  248. with the <command>start</command> and <command>reload</command> commands
  249. is different to its behavior with the <command>stop</command> command.
  250. On <command>start</command> and <command>reload</command>,
  251. <command>keactrl</command> will check if the servers given as
  252. parameters to the <command>-s</command> switch are
  253. enabled in the <command>keactrl</command> configuration file:
  254. if not, the server will be ignored. For <command>stop</command> however,
  255. this check is not made: the command is applied to all listed servers,
  256. regardless of whether they have been enabled in the file.
  257. </para>
  258. <para>
  259. The following keywords can be used with the <command>-s</command>
  260. command line option:
  261. <itemizedlist>
  262. <listitem><simpara>
  263. <command>dhcp4</command> for <command>kea-dhcp4.</command>
  264. </simpara></listitem>
  265. <listitem><simpara>
  266. <command>dhcp6</command> for <command>kea-dhcp6.</command>
  267. </simpara></listitem>
  268. <listitem><simpara>
  269. <command>dhcp_ddns</command> for <command>kea-dhcp-ddns.</command>
  270. </simpara></listitem>
  271. <listitem><simpara>
  272. <command>all</command> for all servers (default).
  273. </simpara></listitem>
  274. </itemizedlist>
  275. </para>
  276. </section>
  277. </chapter>