admin.xml 28 KB

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