admin.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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="admin">
  7. <title>Kea Database Administration</title>
  8. <section id="kea-database-version">
  9. <title>Databases and Database Version Numbers</title>
  10. <para>
  11. Kea supports storing leases and host reservations (i.e. static
  12. assignments of addresses, prefixes and options) in one of
  13. the several supported databases. As future versions of Kea
  14. are released, the structure of those databases will change.
  15. For example, Kea currently only stores lease information
  16. and host reservations. Future versions of Kea will store
  17. additional data such as subnet definitions: the database
  18. structure will need to be updated to accommodate the extra
  19. information.
  20. </para>
  21. <para>
  22. A given version of Kea expects a particular structure in
  23. the database and checks for this by examining the version of
  24. database it is using. Separate version numbers are maintained for
  25. backend databases, independent of the version of Kea itself. It
  26. is possible that the backend database version will stay the same
  27. through several Kea revisions: similarly, it is possible that the
  28. version of backend database may go up several revisions during a
  29. Kea upgrade. Versions for each database are independent, so an
  30. increment in the MySQL database version does not imply an increment
  31. in that of PostgreSQL.
  32. </para>
  33. <para>
  34. Backend versions are specified in
  35. a <replaceable>major.minor</replaceable> format. The minor
  36. number is increased when there are backward compatible changes
  37. introduced. For example, the addition of a new index. It is
  38. desirable, but not mandatory to apply such a change; you
  39. can run on older database version if you want to. (Although, in
  40. the example given, running without the new index may be at the
  41. expense of a performance penalty.) On the other hand, the major
  42. number is increased when an incompatible change is introduced,
  43. for example an extra column is added to a table. If you try to
  44. run Kea software on a database that is too old (as signified by
  45. mismatched backend major version number), Kea will refuse to run:
  46. administrative action will be required to upgrade the database.
  47. </para>
  48. </section>
  49. <section id="kea-admin">
  50. <title>The kea-admin Tool</title>
  51. <para>
  52. To manage the databases, Kea provides the
  53. <command>kea-admin</command> tool. It is able to initialize
  54. a new database, check its version number, perform a
  55. database upgrade, and dump lease data to a text file.
  56. </para>
  57. <para>
  58. <command>kea-admin</command> takes two mandatory
  59. parameters: <command>command</command> and
  60. <command>backend</command>. Additional, non-mandatory options
  61. may be specified. Currently supported commands are:
  62. <itemizedlist>
  63. <listitem>
  64. <simpara>
  65. <command>lease-init</command> &mdash;
  66. Initializes a new lease database. This is useful during a new
  67. Kea installation. The database is initialized to the
  68. latest version supported by the version of the software being
  69. installed.
  70. </simpara>
  71. </listitem>
  72. <listitem>
  73. <simpara>
  74. <command>lease-version</command> &mdash;
  75. Reports the lease database version number. This is
  76. not necessarily equal to the Kea version number as
  77. each backend has its own versioning scheme.
  78. </simpara>
  79. </listitem>
  80. <listitem>
  81. <simpara>
  82. <command>lease-upgrade</command> &mdash;
  83. Conducts a lease database upgrade. This is useful when
  84. upgrading Kea.
  85. </simpara>
  86. </listitem>
  87. <listitem>
  88. <simpara>
  89. <command>lease-dump</command> &mdash;
  90. Dumps the contents of the lease database (for MySQL, PostgreSQL or
  91. CQL backends) to a CSV (comma separated values) text file. The first
  92. line of the file contains the column names. This is meant to be
  93. used as a diagnostic tool, so it provides a portable, human-readable
  94. form of the lease data.
  95. </simpara>
  96. </listitem>
  97. </itemizedlist>
  98. <command>backend</command> specifies the backend type. Currently
  99. supported types are:
  100. <itemizedlist>
  101. <listitem>
  102. <simpara>
  103. <command>memfile</command> &mdash; Lease information is
  104. stored on disk in a text file.
  105. </simpara>
  106. </listitem>
  107. <listitem>
  108. <simpara>
  109. <command>mysql</command> &mdash;
  110. Lease information is stored in a MySQL relational database.
  111. </simpara>
  112. </listitem>
  113. <listitem>
  114. <simpara>
  115. <command>pgsql</command> &mdash;
  116. Lease information is stored in a PostgreSQL relational database.
  117. </simpara>
  118. </listitem>
  119. <listitem>
  120. <simpara>
  121. <command>cql</command> &mdash;
  122. Lease information is stored in a CQL database.
  123. </simpara>
  124. </listitem>
  125. </itemizedlist>
  126. Additional parameters may be needed, depending on your setup
  127. and specific operation: username, password and database name or
  128. the directory where specific files are located. See the appropriate
  129. manual page for details (<command>man 8 kea-admin</command>).
  130. </para>
  131. </section>
  132. <section id="supported-databases">
  133. <title>Supported Databases</title>
  134. <para>The following table presents the capabilities of available
  135. backends. Please refer to the specific sections dedicated to each backend to
  136. better understand their capabilities and limitations. Choosing the right
  137. backend may be essential for success or failure of your deployment.</para>
  138. <para>
  139. <table frame="all" id="backends">
  140. <title>List of available backends</title>
  141. <tgroup cols='2'>
  142. <colspec colname='feature'/>
  143. <colspec colname='memfile'/>
  144. <colspec colname='mysql'/>
  145. <colspec colname='pgsql'/>
  146. <colspec colname='cql'/>
  147. <thead>
  148. <row>
  149. <entry>Feature</entry>
  150. <entry>Memfile</entry>
  151. <entry>MySQL</entry>
  152. <entry>PostgreSQL</entry>
  153. <entry>CQL(Cassandra)</entry>
  154. </row>
  155. </thead>
  156. <tbody>
  157. <row>
  158. <entry>Status</entry>
  159. <entry>Stable</entry>
  160. <entry>Stable</entry>
  161. <entry>Stable</entry>
  162. <entry>Experimental</entry>
  163. </row>
  164. <row>
  165. <entry>Data format</entry>
  166. <entry>CSV file</entry>
  167. <entry>SQL RMDB</entry>
  168. <entry>SQL RMDB</entry>
  169. <entry>NoSQL database (CQL)</entry>
  170. </row>
  171. <row>
  172. <entry>Leases</entry>
  173. <entry>yes</entry>
  174. <entry>yes</entry>
  175. <entry>yes</entry>
  176. <entry>yes</entry>
  177. </row>
  178. <row>
  179. <entry>Host Reservations</entry>
  180. <entry>no</entry>
  181. <entry>yes</entry>
  182. <entry>yes</entry>
  183. <entry>no</entry>
  184. </row>
  185. <row>
  186. <entry>Options defined on per host basis</entry>
  187. <entry>no</entry>
  188. <entry>yes</entry>
  189. <entry>yes</entry>
  190. <entry>no</entry>
  191. </row>
  192. </tbody>
  193. </tgroup>
  194. </table>
  195. </para>
  196. <section>
  197. <title>memfile</title>
  198. <para>
  199. The memfile backend is able to store lease information, but is not able to
  200. store host reservation details: these must be stored in the configuration
  201. file. (There are no plans to add a host reservations storage capability to
  202. this backend.)
  203. </para>
  204. <para>
  205. No special initialization steps are necessary
  206. for the memfile backend. During the first run, both
  207. <command>kea-dhcp4</command> and <command>kea-dhcp6</command>
  208. will create an empty lease file if one is not
  209. present. Necessary disk write permission is required.
  210. </para>
  211. <section id="memfile-upgrade">
  212. <title>Upgrading Memfile Lease Files from an Earlier Version of Kea</title>
  213. <para>
  214. There are no special steps required to upgrade memfile lease files
  215. from an earlier version of Kea to a new version of Kea.
  216. During startup the servers will check the schema version of the lease
  217. files against their own. If there is a mismatch, the servers will
  218. automatically launch the LFC process to convert the files to the
  219. server's schema version. While this mechanism is primarily meant to
  220. ease the process of upgrading to newer versions of Kea, it can also
  221. be used for downgrading should the need arise. When upgrading, any
  222. values not present in the original lease files will be assigned
  223. appropriate default values. When downgrading, any data present in
  224. the files but not in the server's schema will be dropped.
  225. If you wish to convert the files manually, prior to starting the
  226. servers you may do so by running the LFC process yourself.
  227. See <xref linkend="kea-lfc"/> for more information.
  228. </para>
  229. </section>
  230. <!-- @todo: document lease file upgrades once they are implemented in kea-admin -->
  231. </section>
  232. <section>
  233. <title>MySQL</title>
  234. <para>
  235. MySQL is able to store leases, host reservations and options defined on
  236. a per host basis. This section can be safely ignored
  237. if you chose to store the data in other backends.
  238. </para>
  239. <section id="mysql-database-create">
  240. <title>First Time Creation of the MySQL Database</title>
  241. <para>
  242. If you are setting the MySQL database for the first time,
  243. you need to create the database area within MySQL and set up
  244. the MySQL user ID under which Kea will access the database.
  245. This needs to be done manually: <command>kea-admin</command>
  246. is not able to do this for you.
  247. </para>
  248. <para>
  249. To create the database:
  250. <orderedlist>
  251. <listitem>
  252. <para>
  253. Log into MySQL as "root":
  254. <screen>
  255. $ <userinput>mysql -u root -p</userinput>
  256. Enter password:
  257. mysql>
  258. </screen>
  259. </para>
  260. </listitem>
  261. <listitem>
  262. <para>
  263. Create the MySQL database:
  264. <screen>
  265. mysql> <userinput>CREATE DATABASE <replaceable>database-name</replaceable>;</userinput>
  266. </screen>
  267. (<replaceable>database-name</replaceable> is the name
  268. you have chosen for the database.)
  269. </para>
  270. </listitem>
  271. <listitem>
  272. <para>
  273. Create the user under which Kea will access the database
  274. (and give it a password), then grant it access to the
  275. database tables:
  276. <screen>
  277. mysql> <userinput>CREATE USER '<replaceable>user-name</replaceable>'@'localhost' IDENTIFIED BY '<replaceable>password</replaceable>';</userinput>
  278. mysql> <userinput>GRANT ALL ON <replaceable>database-name</replaceable>.* TO '<replaceable>user-name</replaceable>'@'localhost';</userinput>
  279. </screen>
  280. (<replaceable>user-name</replaceable> and
  281. <replaceable>password</replaceable> are the user ID
  282. and password you are using to allow Keas access to the
  283. MySQL instance. All apostrophes in the command lines
  284. above are required.)
  285. </para>
  286. </listitem>
  287. <listitem>
  288. <para>
  289. At this point, you may elect to create the database
  290. tables. (Alternatively, you can exit MySQL and create
  291. the tables using the <command>kea-admin</command> tool,
  292. as explained below.) To do this:
  293. <screen>
  294. mysql> <userinput>CONNECT <replaceable>database-name</replaceable>;</userinput>
  295. mysql> <userinput>SOURCE <replaceable>path-to-kea</replaceable>/share/kea/scripts/mysql/dhcpdb_create.mysql</userinput>
  296. </screen>
  297. (<replaceable>path-to-kea</replaceable> is the
  298. location where you installed Kea.)
  299. </para>
  300. </listitem>
  301. <listitem>
  302. <para>
  303. Exit MySQL:
  304. <screen>
  305. mysql> <userinput>quit</userinput>
  306. Bye
  307. $
  308. </screen>
  309. </para>
  310. </listitem>
  311. </orderedlist>
  312. </para>
  313. <para>
  314. If you elected not to create the tables in step 4, you can do
  315. so now by running the <command>kea-admin</command> tool:
  316. <screen>
  317. $ <userinput>kea-admin lease-init mysql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  318. </screen>
  319. (Do not do this if you did create the tables in step 4.)
  320. <command>kea-admin</command> implements rudimentary checks:
  321. it will refuse to initialize a database that contains any
  322. existing tables. If you want to start from scratch, you
  323. must remove all data manually. (This process is a manual
  324. operation on purpose to avoid possibly irretrievable mistakes
  325. by <command>kea-admin</command>.)
  326. </para>
  327. </section>
  328. <section id="mysql-upgrade">
  329. <title>Upgrading a MySQL Database from an Earlier Version of Kea</title>
  330. <para>
  331. Sometimes a new Kea version may use newer database schema, so
  332. there will be a need to upgrade the existing database. This can
  333. be done using the <command>kea-admin lease-upgrade</command>
  334. command.
  335. </para>
  336. <para>
  337. To check the current version of the database, use the following command:
  338. <screen>
  339. $ <userinput>kea-admin lease-version mysql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  340. </screen>
  341. (See <xref linkend="kea-database-version"/> for a discussion
  342. about versioning.) If the version does not match the minimum
  343. required for the new version of Kea (as described in the
  344. release notes), the database needs to be upgraded.
  345. </para>
  346. <para>
  347. Before upgrading, please make sure that the database is
  348. backed up. The upgrade process does not discard any data but,
  349. depending on the nature of the changes, it may be impossible
  350. to subsequently downgrade to an earlier version. To perform
  351. an upgrade, issue the following command:
  352. <screen>
  353. $ <userinput>kea-admin lease-upgrade mysql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  354. </screen>
  355. </para>
  356. </section>
  357. </section> <!-- end of MySQL sections -->
  358. <section>
  359. <title>PostgreSQL</title>
  360. <para>
  361. A PostgreSQL database must be set up if you want Kea to store
  362. lease and other information in PostgreSQL. This step can be
  363. safely ignored if you are using other database backends.
  364. </para>
  365. <section id="pgsql-database-create">
  366. <title>First Time Creation of the PostgreSQL Database</title>
  367. <para>
  368. The first task is to create both the lease database and the
  369. user under which the servers will access it. A number of steps
  370. are required:
  371. <orderedlist>
  372. <listitem>
  373. <para>
  374. Log into PostgreSQL as "root":
  375. <screen>
  376. $ <userinput>sudo -u postgres psql postgres</userinput>
  377. Enter password:
  378. postgres=#
  379. </screen>
  380. </para>
  381. </listitem>
  382. <listitem>
  383. <para>
  384. Create the database:
  385. <screen>
  386. postgres=#<userinput> CREATE DATABASE <replaceable>database-name</replaceable>;</userinput>
  387. CREATE DATABASE
  388. postgres=#
  389. </screen>
  390. (<replaceable>database-name</replaceable> is the name
  391. you have chosen for the database.)
  392. </para>
  393. </listitem>
  394. <listitem>
  395. <para>
  396. Create the user under which Kea will access the database
  397. (and give it a password), then grant it access to the
  398. database:
  399. <screen>
  400. postgres=#<userinput> CREATE USER <replaceable>user-name</replaceable> WITH PASSWORD '<replaceable>password</replaceable>';</userinput>
  401. CREATE ROLE
  402. postgres=#<userinput> GRANT ALL PRIVILEGES ON DATABASE <replaceable>database-name</replaceable> TO <replaceable>user-name</replaceable>;</userinput>
  403. GRANT
  404. postgres=#
  405. </screen>
  406. </para>
  407. </listitem>
  408. <listitem>
  409. <para>
  410. Exit PostgreSQL:
  411. <screen>
  412. postgres=# <userinput>\q</userinput>
  413. Bye
  414. $
  415. </screen>
  416. </para>
  417. </listitem>
  418. <listitem>
  419. <para>
  420. At this point you are ready to create the database tables.
  421. This can be done using the <command>kea-admin</command> tool
  422. as explained in the next section (recommended), or manually.
  423. To create the tables manually enter the following command.
  424. Note that PostgreSQL will prompt you to enter the new user's
  425. password you specified in Step 3. When the command completes
  426. you will be returned to the shell prompt. You should see output
  427. similar to following:
  428. <screen>
  429. $ <userinput>psql -d <replaceable>database-name</replaceable> -U <replaceable>user-name</replaceable> -f <replaceable>path-to-kea</replaceable>/share/kea/scripts/pgsql/dhcpdb_create.pgsql</userinput>
  430. Password for user <replaceable>user-name</replaceable>:
  431. CREATE TABLE
  432. CREATE INDEX
  433. CREATE INDEX
  434. CREATE TABLE
  435. CREATE INDEX
  436. CREATE TABLE
  437. START TRANSACTION
  438. INSERT 0 1
  439. INSERT 0 1
  440. INSERT 0 1
  441. COMMIT
  442. CREATE TABLE
  443. START TRANSACTION
  444. INSERT 0 1
  445. COMMIT
  446. $
  447. </screen>
  448. (<replaceable>path-to-kea</replaceable> is the location
  449. where you installed Kea.)
  450. </para>
  451. <para>
  452. If instead you encounter an error like:
  453. <screen>
  454. psql: FATAL: no pg_hba.conf entry for host "[local]", user "<replaceable>user-name</replaceable>", database "<replaceable>database-name</replaceable>", SSL off
  455. </screen>
  456. ... you will need to alter the PostgreSQL configuration.
  457. Kea uses password authentication when connecting to
  458. the database and must have the appropriate entries
  459. added to PostgreSQL's pg_hba.conf file. This file is
  460. normally located in the primary data directory for your
  461. PostgreSQL server. The precise path may vary but the
  462. default location for PostgreSQL 9.3 on Centos 6.5 is:
  463. <filename>/var/lib/pgsql/9.3/data/pg_hba.conf</filename>.
  464. </para>
  465. <para>
  466. Assuming Kea is running on the same host as PostgreSQL,
  467. adding lines similar to following should be sufficient to
  468. provide password-authenticated access to Kea's database:
  469. <screen>
  470. local <replaceable>database-name</replaceable> <replaceable>user-name</replaceable> password
  471. host <replaceable>database-name</replaceable> <replaceable>user-name</replaceable> 127.0.0.1/32 password
  472. host <replaceable>database-name</replaceable> <replaceable>user-name</replaceable> ::1/128 password
  473. </screen>
  474. </para>
  475. <para>
  476. These edits are primarily intended as a starting point
  477. not a definitive reference on PostgreSQL administration or
  478. database security. Please consult your PostgreSQL user
  479. manual before making these changes as they may expose
  480. other databases that you run. It may be necessary to
  481. restart PostgreSQL in order for these changes to take effect.
  482. </para>
  483. </listitem>
  484. </orderedlist>
  485. </para>
  486. </section>
  487. <section>
  488. <title>Initialize the PostgreSQL Database Using kea-admin</title>
  489. <para>
  490. If you elected not to create the tables manually, you can do
  491. so now by running the <command>kea-admin</command> tool:
  492. <screen>
  493. $ <userinput>kea-admin lease-init pgsql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  494. </screen>
  495. Do not do this if you already created the tables in manually.
  496. <command>kea-admin</command> implements rudimentary checks:
  497. it will refuse to initialize a database that contains any
  498. existing tables. If you want to start from scratch, you
  499. must remove all data manually. (This process is a manual
  500. operation on purpose to avoid possibly irretrievable mistakes
  501. by <command>kea-admin</command>.)
  502. </para>
  503. </section>
  504. <section id="pgsql-upgrade">
  505. <title>Upgrading a PostgreSQL Database from an Earlier Version of Kea</title>
  506. <para>
  507. The PostgreSQL database schema can be upgraded using the same tool and
  508. commands as described in <xref linkend="mysql-upgrade"/>, with the
  509. exception that the "pgsql" database backend type must be used in
  510. the commands.
  511. </para>
  512. <para>
  513. Use the following command to check the current schema version:
  514. <screen>
  515. $ <userinput>kea-admin lease-version pgsql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  516. </screen>
  517. Use the following command to perform an upgrade:
  518. <screen>
  519. $ <userinput>kea-admin lease-upgrade pgsql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  520. </screen>
  521. </para>
  522. </section>
  523. </section> <!-- end of PostgreSQL sections -->
  524. <section>
  525. <title>CQL (Cassandra)</title>
  526. <para>
  527. Cassandra, or Cassandra Query Language (CQL), is the newest backend
  528. added to Kea. Since it was added recently and has not undergone as much
  529. testing as other backends, it is considered experimental: please use
  530. with caution. The CQL backend is currently able to store leases only. The
  531. ability to store host reservations will likely be added some time in the
  532. future.
  533. </para>
  534. <para>
  535. The CQL database must be properly set up if you want Kea to store
  536. information in CQL. This section can be safely ignored if you chose to
  537. store the data in other backends.
  538. </para>
  539. <section id="cql-database-create">
  540. <title>First Time Creation of the Cassandra Database</title>
  541. <para>
  542. If you are setting up the CQL database for the first time, you need to
  543. create the keyspace area within CQL. This needs to be done manually:
  544. <command>kea-admin</command> is not able to do this for you.
  545. </para>
  546. <para>
  547. To create the database:
  548. <orderedlist>
  549. <listitem>
  550. <para>
  551. Export CQLSH_HOST environment variable:
  552. <screen>
  553. $ <userinput>export CQLSH_HOST=localhost</userinput>
  554. </screen>
  555. </para>
  556. </listitem>
  557. <listitem>
  558. <para>
  559. Log into CQL:
  560. <screen>
  561. $ <userinput>cqlsh</userinput>
  562. cql>
  563. </screen>
  564. </para>
  565. </listitem>
  566. <listitem>
  567. <para>
  568. Create the CQL keyspace:
  569. <screen>
  570. cql> <userinput>CREATE KEYSPACE keyspace-name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};</userinput>
  571. </screen>
  572. (<replaceable>keyspace-name</replaceable> is the name you have
  573. chosen for the keyspace)
  574. </para>
  575. </listitem>
  576. <listitem>
  577. <para>
  578. At this point, you may elect to create the database tables.
  579. (Alternatively, you can exit CQL and create the tables using the
  580. <command>kea-admin</command> tool, as explained below) To do this:
  581. <screen>
  582. <userinput>cqslh -k <replaceable>keyspace-name</replaceable> -f <replaceable>path-to-kea</replaceable>/share/kea/scripts/cql/dhcpdb_create.cql</userinput>
  583. </screen>
  584. (<replaceable>path-to-kea</replaceable> is the location where you
  585. installed Kea)
  586. </para>
  587. </listitem>
  588. </orderedlist>
  589. </para>
  590. <para>
  591. If you elected not to create the tables in step 4, you can do
  592. so now by running the <command>kea-admin</command> tool:
  593. <screen>
  594. $ <userinput>kea-admin lease-init cql -n <replaceable>database-name</replaceable></userinput>
  595. </screen>
  596. (Do not do this if you did create the tables in step 4.)
  597. <command>kea-admin</command> implements rudimentary checks:
  598. it will refuse to initialize a database that contains any
  599. existing tables. If you want to start from scratch, you
  600. must remove all data manually. (This process is a manual
  601. operation on purpose to avoid possibly irretrievable mistakes
  602. by <command>kea-admin</command>)
  603. </para>
  604. </section>
  605. <section id="cql-upgrade">
  606. <title>Upgrading a CQL Database from an Earlier Version of Kea</title>
  607. <para>
  608. Sometimes a new Kea version may use newer database schema, so
  609. there will be a need to upgrade the existing database. This can
  610. be done using the <command>kea-admin lease-upgrade</command>
  611. command.
  612. </para>
  613. <para>
  614. To check the current version of the database, use the following command:
  615. <screen>
  616. $ <userinput>kea-admin lease-version cql -n <replaceable>database-name</replaceable></userinput>
  617. </screen>
  618. (See <xref linkend="kea-database-version"/> for a discussion
  619. about versioning) If the version does not match the minimum
  620. required for the new version of Kea (as described in the
  621. release notes), the database needs to be upgraded.
  622. </para>
  623. <para>
  624. Before upgrading, please make sure that the database is
  625. backed up. The upgrade process does not discard any data but,
  626. depending on the nature of the changes, it may be impossible
  627. to subsequently downgrade to an earlier version. To perform
  628. an upgrade, issue the following command:
  629. <screen>
  630. $ <userinput>kea-admin lease-upgrade cql -n <replaceable>database-name</replaceable></userinput>
  631. </screen>
  632. </para>
  633. </section>
  634. </section> <!-- end of CQL sections -->
  635. <section>
  636. <title>Using Read-Only Databases with Host Reservations</title>
  637. <para>If a read-only database is used for storing host reservations,
  638. Kea must be explicitly configured to operate on the database in
  639. read-only mode.
  640. Sections <xref linkend="read-only-database-configuration4"/> and
  641. <xref linkend="read-only-database-configuration6"/> describe when
  642. such configuration may be required and how to configure Kea to
  643. operate using a read-only host database.
  644. </para>
  645. </section>
  646. <section>
  647. <title>Limitations Related to the use of SQL Databases</title>
  648. <section>
  649. <title>Year 2038 issue</title>
  650. <para>
  651. The lease expiration time is stored in the SQL database for each lease
  652. as a timestamp value. Kea developers observed that MySQL database doesn't
  653. accept timestamps beyond 2147483647 seconds (maximum signed 32-bit number)
  654. from the beginning of the epoch. At the same time, some versions of PostgreSQL
  655. do accept greater values but the value is altered when it is read back.
  656. For this reason the lease database backends put the restriction for the
  657. maximum timestamp to be stored in the database, which is equal to the
  658. maximum signed 32-bit number. This effectively means that the current
  659. Kea version can't store the leases which expiration time is later than
  660. 2147483647 seconds since the beginning of the epoch (around year 2038).
  661. This will be fixed when the database support for longer timestamps
  662. is available.
  663. </para>
  664. </section>
  665. <section>
  666. <title>Server Terminates when Database Connection is Lost</title>
  667. <para>
  668. If Kea is configured to use an external database it opens a connection
  669. to the database and requires that this connection is not interrupted.
  670. When the database connection breaks, e.g. as a result of SQL server
  671. restart, DHCP servers will terminate indicating a fatal error. In such
  672. a case, the system administrator is required to start the database and
  673. then "manually" start Kea to resume the service.
  674. </para>
  675. <para>
  676. Although the engineering team is planning to implement some form of
  677. reconnect mechanism in the future, this will mostly be applicable in
  678. cases when the database service is restarted and the connection
  679. down time is relatively short. The DHCP server can't provide its
  680. service as long as the database is down, because it can't store
  681. leases being assigned to the clients. The server will have to
  682. reject any DHCP messages as long as the connection is down and
  683. terminate if the reconnection attempt fails multiple times.
  684. </para>
  685. <para>
  686. Because the database connection is critical for the operation of the
  687. DHCP service, the current behavior is to terminate when that
  688. connection is unavailable to indicate that server is in inconsistent
  689. state and can't serve clients.
  690. </para>
  691. </section>
  692. </section>
  693. </section> <!-- End of Database sections -->
  694. </chapter>