admin.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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>
  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. PostgreSQL is able to store leases. The capability to store host
  364. reservations (that include addresses, prefixes and options) is planned
  365. for upcoming Kea 1.1.0.
  366. </para>
  367. <para>
  368. A PostgreSQL database must be set up if you want Kea to store
  369. lease and other information in PostgreSQL. This step can be
  370. safely ignored if you are using other database backends.
  371. </para>
  372. <section id="pgsql-database-create">
  373. <title>Manually Create the PostgreSQL Database and the Kea User</title>
  374. <para>
  375. The first task is to create both the lease database and the
  376. user under which the servers will access it. A number of steps
  377. are required:
  378. <orderedlist>
  379. <listitem>
  380. <para>
  381. Log into PostgreSQL as "root":
  382. <screen>
  383. $ <userinput>sudo -u postgres psql postgres</userinput>
  384. Enter password:
  385. postgres=#
  386. </screen>
  387. </para>
  388. </listitem>
  389. <listitem>
  390. <para>
  391. Create the database:
  392. <screen>
  393. postgres=#<userinput> CREATE DATABASE <replaceable>database-name</replaceable>;</userinput>
  394. CREATE DATABASE
  395. postgres=#
  396. </screen>
  397. (<replaceable>database-name</replaceable> is the name
  398. you have chosen for the database.)
  399. </para>
  400. </listitem>
  401. <listitem>
  402. <para>
  403. Create the user under which Kea will access the database
  404. (and give it a password), then grant it access to the
  405. database:
  406. <screen>
  407. postgres=#<userinput> CREATE USER <replaceable>user-name</replaceable> WITH PASSWORD '<replaceable>password</replaceable>';</userinput>
  408. CREATE ROLE
  409. postgres=#
  410. postgres=#<userinput> GRANT ALL PRIVILEGES ON DATABASE <replaceable>database-name</replaceable> TO <replaceable>user-name</replaceable>;</userinput>
  411. GRANT
  412. postgres=#
  413. </screen>
  414. </para>
  415. </listitem>
  416. <listitem>
  417. <para>
  418. Exit PostgreSQL:
  419. <screen>
  420. postgres=# <userinput>\q</userinput>
  421. Bye
  422. $
  423. </screen>
  424. </para>
  425. </listitem>
  426. <listitem>
  427. <para>
  428. At this point you are ready to create the database tables.
  429. This can be done using the <command>kea-admin</command> tool
  430. as explained in the next section (recommended), or manually.
  431. To create the tables manually enter the following command.
  432. Note that PostgreSQL will prompt you to enter the new user's
  433. password you specified in Step 3. When the command completes
  434. you will be returned to the shell prompt. You should see output
  435. similar to following:
  436. <screen>
  437. $ <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>
  438. Password for user <replaceable>user-name</replaceable>:
  439. CREATE TABLE
  440. CREATE INDEX
  441. CREATE INDEX
  442. CREATE TABLE
  443. CREATE INDEX
  444. CREATE TABLE
  445. START TRANSACTION
  446. INSERT 0 1
  447. INSERT 0 1
  448. INSERT 0 1
  449. COMMIT
  450. CREATE TABLE
  451. START TRANSACTION
  452. INSERT 0 1
  453. COMMIT
  454. $
  455. </screen>
  456. (<replaceable>path-to-kea</replaceable> is the location
  457. where you installed Kea.)
  458. </para>
  459. <para>
  460. If instead you encounter an error like:
  461. <screen>
  462. psql: FATAL: no pg_hba.conf entry for host "[local]", user "<replaceable>user-name</replaceable>", database "<replaceable>database-name</replaceable>", SSL off
  463. </screen>
  464. ... you will need to alter the PostgreSQL configuration.
  465. Kea uses password authentication when connecting to
  466. the database and must have the appropriate entries
  467. added to PostgreSQL's pg_hba.conf file. This file is
  468. normally located in the primary data directory for your
  469. PostgreSQL server. The precise path may vary but the
  470. default location for PostgreSQL 9.3 on Centos 6.5 is:
  471. <filename>/var/lib/pgsql/9.3/data/pg_hba.conf</filename>.
  472. </para>
  473. <para>
  474. Assuming Kea is running on the same host as PostgreSQL,
  475. adding lines similar to following should be sufficient to
  476. provide password-authenticated access to Kea's database:
  477. <screen>
  478. local <replaceable>database-name</replaceable> <replaceable>user-name</replaceable> password
  479. host <replaceable>database-name</replaceable> <replaceable>user-name</replaceable> 127.0.0.1/32 password
  480. host <replaceable>database-name</replaceable> <replaceable>user-name</replaceable> ::1/128 password
  481. </screen>
  482. </para>
  483. <para>
  484. These edits are primarily intended as a starting point
  485. not a definitive reference on PostgreSQL administration or
  486. database security. Please consult your PostgreSQL user
  487. manual before making these changes as they may expose
  488. other databases that you run. It may be necessary to
  489. restart PostgreSQL in order for these changes to take effect.
  490. </para>
  491. </listitem>
  492. </orderedlist>
  493. </para>
  494. </section>
  495. <section>
  496. <title>Initialize the PostgreSQL Database Using kea-admin</title>
  497. <para>
  498. If you elected not to create the tables manually, you can do
  499. so now by running the <command>kea-admin</command> tool:
  500. <screen>
  501. $ <userinput>kea-admin lease-init pgsql -u <replaceable>database-user</replaceable> -p <replaceable>database-password</replaceable> -n <replaceable>database-name</replaceable></userinput>
  502. </screen>
  503. Do not do this if you already created the tables in manually.
  504. <command>kea-admin</command> implements rudimentary checks:
  505. it will refuse to initialize a database that contains any
  506. existing tables. If you want to start from scratch, you
  507. must remove all data manually. (This process is a manual
  508. operation on purpose to avoid possibly irretrievable mistakes
  509. by <command>kea-admin</command>.)
  510. </para>
  511. </section>
  512. <section id="pgsql-upgrade">
  513. <title>Upgrading a PostgreSQL Database from an Earlier Version of Kea</title>
  514. <para>
  515. Currently, PostgreSQL only supports Kea schema version 1.0 so no upgrades
  516. are available. As upgrades become available, <command>kea-admin</command>
  517. will support them.
  518. </para>
  519. </section>
  520. </section> <!-- end of PostgreSQL sections -->
  521. <section>
  522. <title>CQL (Cassandra)</title>
  523. <para>
  524. Cassandra, or Cassandra Query Language (CQL), is the newest backend
  525. added to Kea. Since it was added recently and has not undergone as much
  526. testing as other backends, it is considered experimental. Please use
  527. with caution. CQL backend is currently able to store leases only. The
  528. ability to store host reservations will likely be added some time in the
  529. future.
  530. </para>
  531. <para>
  532. The CQL database must be properly set up if you want Kea to store
  533. information in CQL. This section can be safely ignored if you chose to
  534. store the data in other backends.
  535. </para>
  536. <section id="cql-database-create">
  537. <title>First Time Creation of Kea Database</title>
  538. <para>
  539. If you are setting up the CQL database for the first time, you need to
  540. create the keyspace area within CQL. This needs to be done manually:
  541. <command>kea-admin</command> is not able to do this for you.
  542. </para>
  543. <para>
  544. To create the database:
  545. <orderedlist>
  546. <listitem>
  547. <para>
  548. Export CQLSH_HOST environemnt variable:
  549. <screen>
  550. $ <userinput>export CQLSH_HOST=localhost</userinput>
  551. </screen>
  552. </para>
  553. </listitem>
  554. <listitem>
  555. <para>
  556. Log into CQL:
  557. <screen>
  558. $ <userinput>cqlsh</userinput>
  559. cql>
  560. </screen>
  561. </para>
  562. </listitem>
  563. <listitem>
  564. <para>
  565. Create the CQL keyspace:
  566. <screen>
  567. cql> <userinput>CREATE KEYSPACE keyspace-name WITH replication = {'class' : 'SimpleStrategy','replication_factor' : 1};</userinput>
  568. </screen>
  569. (<replaceable>keyspace-name</replaceable> is the name you have
  570. chosen for the keyspace)
  571. </para>
  572. </listitem>
  573. <listitem>
  574. <para>
  575. At this point, you may elect to create the database tables.
  576. (Alternatively, you can exit CQL and create the tables using the
  577. <command>kea-admin</command> tool, as explained below) To do this:
  578. <screen>
  579. <userinput>cqslh -k <replaceable>keyspace-name</replaceable> -f <replaceable>path-to-kea</replaceable>/share/kea/scripts/cql/dhcpdb_create.cql</userinput>
  580. </screen>
  581. (<replaceable>path-to-kea</replaceable> is the location where you
  582. installed Kea)
  583. </para>
  584. </listitem>
  585. </orderedlist>
  586. </para>
  587. <para>
  588. If you elected not to create the tables in step 4, you can do
  589. so now by running the <command>kea-admin</command> tool:
  590. <screen>
  591. $ <userinput>kea-admin lease-init cql -n <replaceable>database-name</replaceable></userinput>
  592. </screen>
  593. (Do not do this if you did create the tables in step 4.)
  594. <command>kea-admin</command> implements rudimentary checks:
  595. it will refuse to initialize a database that contains any
  596. existing tables. If you want to start from scratch, you
  597. must remove all data manually. (This process is a manual
  598. operation on purpose to avoid possibly irretrievable mistakes
  599. by <command>kea-admin</command>)
  600. </para>
  601. </section>
  602. <section id="cql-upgrade">
  603. <title>Upgrading a CQL Database from an Earlier Version of Kea</title>
  604. <para>
  605. Sometimes a new Kea version may use newer database schema, so
  606. there will be a need to upgrade the existing database. This can
  607. be done using the <command>kea-admin lease-upgrade</command>
  608. command.
  609. </para>
  610. <para>
  611. To check the current version of the database, use the following command:
  612. <screen>
  613. $ <userinput>kea-admin lease-version cql -n <replaceable>database-name</replaceable></userinput>
  614. </screen>
  615. (See <xref linkend="kea-database-version"/> for a discussion
  616. about versioning) If the version does not match the minimum
  617. required for the new version of Kea (as described in the
  618. release notes), the database needs to be upgraded.
  619. </para>
  620. <para>
  621. Before upgrading, please make sure that the database is
  622. backed up. The upgrade process does not discard any data but,
  623. depending on the nature of the changes, it may be impossible
  624. to subsequently downgrade to an earlier version. To perform
  625. an upgrade, issue the following command:
  626. <screen>
  627. $ <userinput>kea-admin lease-upgrade cql -n <replaceable>database-name</replaceable></userinput>
  628. </screen>
  629. </para>
  630. </section>
  631. </section> <!-- end of CQL sections -->
  632. <section>
  633. <title>Using read only databases with host reservations</title>
  634. <para>If read only database is used for storing host reservations,
  635. Kea must be explicitly configured to operate on the database in
  636. the read only mode.
  637. Sections <xref linkend="read-only-database-configuration4"/> and
  638. <xref linkend="read-only-database-configuration6"/> describe when
  639. such configuration may be reqired and how to configure Kea to
  640. operate using read only host database.
  641. </para>
  642. </section>
  643. <section>
  644. <title>Limitations related to the use of the SQL databases</title>
  645. <para>
  646. The lease expiration time is stored in the SQL database for each lease
  647. as a timestamp value. Kea developers observed that MySQL database doesn't
  648. accept timestamps beyond 2147483647 seconds (maximum signed 32-bit number)
  649. from the beginning of the epoch. At the same time, some versions of PostgreSQL
  650. do accept greater values but the value is altered when it is read back.
  651. For this reason the lease database backends put the restriction for the
  652. maximum timestamp to be stored in the database, which is equal to the
  653. maximum signed 32-bit number. This effectively means that the current
  654. Kea version can't store the leases which expiration time is later than
  655. 2147483647 seconds since the beginning of the epoch (around year 2038).
  656. </para>
  657. </section>
  658. </section> <!-- End of Database sections -->
  659. </chapter>