admin.xml 28 KB

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