keactrl.xml 13 KB

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