1 Author: Pierangelo Masarati <ando@OpenLDAP.org>
3 Back-sql can be tested with sql-test000-read; it requires a bit of work
4 to get everything up and running appropriately.
6 This document briefly describes the steps that are required to prepare
7 a quick'n'dirty installation of back-sql and of the related RDBMS
8 and ODBC; Examples are provided, but by no means they pretent
9 to represent an exaustive source of info about how to setup the ODBC;
10 refer to the docs for any problem or detail.
12 Currently, the system has been tested with IBM db2, PostgreSQL and MySQL;
13 basic support and test data for other RDBMSes is in place, but as of
14 today (November 2004) it's totally untested. If you succeed in running
15 any of the other RDBMSes, please provide feedback about any required
16 change either in the code or in the test scripts by means of OpenLDAP's
17 Issue Tracking System (http://www.openldap.org/its/).
19 1) slapd must be compiled with back-sql support, i.e. configure
20 with --enable-sql switch. This requires an implementation of the ODBC
23 2) The ODBC must be set up appropriately, by editing the odbc.ini file
24 in /etc/ (or wherever your installation puts it) and, if appropriate,
25 the odbcinst.ini file. Note: you can also use custom odbc.ini and
26 odbcinst.ini files, provided you export in ODBCINI the full path to the
27 odbc.ini file, and in ODBCSYSINI the directory where the odbcinst.ini
29 Relevant info for our test setup is highlighted with '<===' on the right.
33 2.1.1) Add to the odbc.ini file a block of the form
36 Description = Example for OpenLDAP's back-sql
39 Database = example <===
40 Servername = localhost
41 UserName = manager <===
42 Password = secret <===
52 2.1.2) Add to the odbcinst.ini file a block of the form
55 Description = ODBC for PostgreSQL
56 Driver = /usr/lib/libodbcpsql.so
57 Setup = /usr/lib/libodbcpsqlS.so
62 2.2.1) Add to the odbc.ini file a block of the form
65 Description = Example for OpenLDAP's back-sql
68 Database = example <===
69 Servername = localhost
70 UserName = manager <===
71 Password = secret <===
78 SOCKET = /var/lib/mysql/mysql.sock
80 2.2.2) Add to the odbcinst.ini file a block of the form
83 Description = ODBC for MySQL
84 Driver = /usr/lib/libmyodbc.so
90 3) The RDBMS must be setup; examples are provided for my installations
91 of PostgreSQL and MySQL, but details may change; other RDBMSes should
92 be configured in a similar manner, you need to find out the details by
93 reading their documentation.
97 3.1.1) Start the server
99 [root@localhost]# service postgresql start
100 on other systems: read the docs...
102 3.1.2) Create the database:
103 [root@localhost]# su - postgres
104 [postgres@localhost]$ createdb example
106 3.1.3) Create the user:
107 [root@localhost]# su - postgres
108 [postgres@localhost]$ psql example
109 example=> create user manager with password 'secret';
110 example=> <control-D>
112 3.1.4) Populate the database:
113 [root@localhost]# cd $SOURCES/servers/slapd/back-sql/rdbms_depend/pgsql/
114 [root@localhost]# psql -U manager -W example
115 example=> <control-D>
116 [root@localhost]# psql -U manager example < backsql_create.sql
117 [root@localhost]# psql -U manager example < testdb_create.sql
118 [root@localhost]# psql -U manager example < testdb_data.sql
119 [root@localhost]# psql -U manager example < testdb_metadata.sql
122 [root@localhost]# cd $SOURCES/tests
123 [root@localhost]# SLAPD_USE_SQL=pgsql ./run sql-test000
127 3.2.1) Start the server
129 [root@localhost]# service mysqld start
130 on other systems: read the docs...
132 3.2.2) Create the database:
133 [root@localhost]# mysqladmin -u root -p create example
134 (hit <return> for the empty password).
136 3.2.3) Create the user:
137 [root@localhost]# mysql -u root -p example
138 (hit <return> for the empty password)
139 mysql> grant all privileges on *.* \
140 to 'manager'@'localhost' identified by 'secret' with grant option;
143 3.2.4) Populate the database:
144 [root@localhost]# cd $SOURCES/servers/slapd/back-sql/rdbms_depend/mysql/
145 [root@localhost]# mysql -u manager -p example < backsql_create.sql
146 [root@localhost]# mysql -u manager -p example < testdb_create.sql
147 [root@localhost]# mysql -u manager -p example < testdb_data.sql
148 [root@localhost]# mysql -u manager -p example < testdb_metadata.sql
151 [root@localhost]# cd $SOURCES/tests
152 [root@localhost]# SLAPD_USE_SQL=mysql ./run sql-test000
157 3.3.1) Start the server:
159 3.3.2) Create the database:
161 3.3.3) Create the user:
163 3.3.4) Populate the database:
164 connect to the database as user manager, and execute the test files
165 in auto-commit mode (-c)
166 [root@localhost]# su - manager
167 [manager@localhost]$ db2 "connect to example user manager using secret"
168 [manager@localhost]$ db2 -ctvf backsql_create.sql
169 [manager@localhost]$ db2 -ctvf testdb_create.sql
170 [manager@localhost]$ db2 -ctvf testdb_data.sql
171 [manager@localhost]$ db2 -ctvf testdb_metadata.sql
172 [manager@localhost]$ db2 "connect reset"
175 [root@localhost]# cd $SOURCES/tests
176 [root@localhost]# SLAPD_USE_SQL=ibmdb2 ./run sql-test000
179 The test is basically readonly; this can be performed by all RDBMSes
182 There is another test, sql-test900-write, which is currently enabled
183 only for PostgreSQL and IBM db2. Note that after a successful run
184 of the write test, the database is no longer in the correct state
185 to restart either of the tests, and step 3.X.4 needs to be re-run first.
187 More tests are to come; PostgreSQL is known to allow a full reload
188 of the test database starting from an empty database.