database_backends.dox 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. /**
  15. @page dhcpDatabaseBackends DHCP Database Back-Ends
  16. All DHCP lease data is stored in some form of database, the interface
  17. to this being through the Lease Manager.
  18. All backend classes such as isc::dhcp::MySqlLeaseMgr are derived from
  19. the abstract isc::dhcp::LeaseMgr class. This provides methods to
  20. create, retrieve, modify and delete leases in the database.
  21. There are currently two available Lease Managers, MySQL and Memfile:
  22. - The MySQL lease manager uses the freely available MySQL as its backend
  23. database. This is not included in BIND 10 DHCP by default:
  24. the --with-dhcp-mysql switch must be supplied to "configure" for support
  25. to be compiled into the software.
  26. - Memfile is an in-memory lease database, with (currently) nothing being
  27. written to persistent storage. The long-term plans for the backend do
  28. include the ability to store this on disk, but it is currently a
  29. low-priority item.
  30. @section dhcpdb-instantiation Instantiation of Lease Managers
  31. A lease manager is instantiated through the LeaseMgrFactory class. This
  32. has three methods:
  33. - isc::dhcp::LeaseMgrFactory::create - Creates a singleton Lease
  34. Manager of the appropriate type.
  35. - isc::dhcp::LeaseMgrFactory::instance - Returns a reference to the
  36. the instance of the Lease Manager.
  37. - isc::dhcp::LeaseMgrFactory::destroy - Destroys the singleton lease manager.
  38. The selection of the Lease Manager (and thus the backend database) is
  39. controlled by the connection string passed to
  40. isc::dhcp::LeaseMgrFactory::create. This is a set of "keyword=value" pairs
  41. (no embedded spaces), each pair separated by a space from the others, e.g.
  42. \code
  43. type=mysql user=keatest password=keatest name=keatest host=localhost
  44. \endcode
  45. The following keywords are used for all backends:
  46. - <b>type</b> - specifies the type of database backend. The following values
  47. for the type keyword are supported:
  48. - <B>memfile</b> - In-memory database. Nothing is written to any
  49. external storage, so this should not be used in production.
  50. - <b>mysql</b> - Use MySQL as the database
  51. The following sections list the database-specific keywords:
  52. @subsection dhcpdb-keywords-mysql MySQL connection string keywords
  53. - <b>host</b> - host on which the selected database is running. If not
  54. supplied, "localhost" is assumed.
  55. - <b>name</b> - name of the MySQL database to access. There is no default -
  56. this must always be supplied.
  57. - <b>password</b> - password for the selected user ID (see below). If not
  58. specified, no password is used.
  59. - <b>user</b> - database user ID under which the database is accessed. If not
  60. specified, no user ID is used - the database is assumed to be open.
  61. @section dhcp-backend-unittest Running Unit Tests
  62. With the use of databases requiring separate authorisation, there are
  63. certain database-specific pre-requisites for successfully running the unit
  64. tests. These are listed in the following sections.
  65. @subsection dhcp-mysql-unittest MySQL
  66. A database called <i>keatest</i> must be created. A database user, also called
  67. <i>keatest</i> (and with a password <i>keatest</i>) must also be created and
  68. be given full privileges in that database. The unit tests create the schema
  69. in the database before each test and delete it afterwards.
  70. In detail, the steps to create the database and user are:
  71. -# Log into MySQL as root:
  72. @verbatim
  73. % mysql -u root -p
  74. Enter password:
  75. :
  76. mysql>@endverbatim\n
  77. -# Create the test database. This must be called "keatest":
  78. @verbatim
  79. mysql> CREATE DATABASE keatest;
  80. mysql>@endverbatim\n
  81. -# Create the user under which the test client will connect to the database
  82. (the apostrophes around the words <i>keatest</i> and <i>localhost</i> are
  83. required):
  84. @verbatim
  85. mysql> CREATE USER 'keatest'@'localhost' IDENTIFIED BY 'keatest';
  86. mysql>@endverbatim\n
  87. -# Grant the created user permissions to access the <i>keatest</i> database
  88. (again, the apostrophes around the words <i>keatest</i> and <i>localhost</i>
  89. are required):
  90. @verbatim
  91. mysql> GRANT ALL ON keatest.* TO 'keatest'@'localhost';
  92. mysql>@endverbatim\n
  93. -# Exit MySQL:
  94. @verbatim
  95. mysql> quit
  96. Bye
  97. %@endverbatim
  98. The unit tests are run automatically when "make check" is executed (providing
  99. that BIND 10 has been build with the --with-dhcp-mysql switch (see the installation
  100. section in the <a href="http://bind10.isc.org/docs/bind10-guide.html">BIND 10 Guide</a>).
  101. */