| 1 |
Author: Pierangelo Masarati <[email protected]> |
| 2 |
|
| 3 |
Back-sql can be tested with sql-test000-read; it requires a bit of work |
| 4 |
to get everything up and running appropriately. |
| 5 |
|
| 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 exhaustive source of info about how to setup the ODBC; |
| 10 |
refer to the docs for any problem or detail. |
| 11 |
|
| 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/). |
| 18 |
|
| 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 |
| 21 |
to be installed. |
| 22 |
|
| 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 |
| 28 |
file resides. |
| 29 |
Relevant info for our test setup is highlighted with '<===' on the right. |
| 30 |
|
| 31 |
2.1) PostgreSQL |
| 32 |
|
| 33 |
2.1.1) Add to the odbc.ini file a block of the form |
| 34 |
|
| 35 |
[example] <=== |
| 36 |
Description = Example for OpenLDAP's back-sql |
| 37 |
Driver = PostgreSQL |
| 38 |
Trace = No |
| 39 |
Database = example <=== |
| 40 |
Servername = localhost |
| 41 |
UserName = manager <=== |
| 42 |
Password = secret <=== |
| 43 |
Port = 5432 |
| 44 |
;Protocol = 6.4 |
| 45 |
ReadOnly = No |
| 46 |
RowVersioning = No |
| 47 |
ShowSystemTables = No |
| 48 |
ShowOidColumn = No |
| 49 |
FakeOidIndex = No |
| 50 |
ConnSettings = |
| 51 |
|
| 52 |
2.1.2) Add to the odbcinst.ini file a block of the form |
| 53 |
|
| 54 |
[PostgreSQL] |
| 55 |
Description = ODBC for PostgreSQL |
| 56 |
Driver = /usr/lib/libodbcpsql.so |
| 57 |
Setup = /usr/lib/libodbcpsqlS.so |
| 58 |
FileUsage = 1 |
| 59 |
|
| 60 |
2.2) MySQL |
| 61 |
|
| 62 |
2.2.1) Add to the odbc.ini file a block of the form |
| 63 |
|
| 64 |
[example] <=== |
| 65 |
Description = Example for OpenLDAP's back-sql |
| 66 |
Driver = MySQL |
| 67 |
Trace = No |
| 68 |
Database = example <=== |
| 69 |
Servername = localhost |
| 70 |
UserName = manager <=== |
| 71 |
Password = secret <=== |
| 72 |
ReadOnly = No |
| 73 |
RowVersioning = No |
| 74 |
ShowSystemTables = No |
| 75 |
ShowOidColumn = No |
| 76 |
FakeOidIndex = No |
| 77 |
ConnSettings = |
| 78 |
SOCKET = /var/lib/mysql/mysql.sock |
| 79 |
|
| 80 |
2.2.2) Add to the odbcinst.ini file a block of the form |
| 81 |
|
| 82 |
[MySQL] |
| 83 |
Description = ODBC for MySQL |
| 84 |
Driver = /usr/lib/libmyodbc.so |
| 85 |
FileUsage = 1 |
| 86 |
|
| 87 |
2.3) IBM db2 |
| 88 |
[n.a.] |
| 89 |
|
| 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. |
| 94 |
|
| 95 |
3.1) PostgreSQL |
| 96 |
|
| 97 |
3.1.1) Start the server |
| 98 |
on RedHat: |
| 99 |
[root@localhost]# service postgresql start |
| 100 |
on other systems: read the docs... |
| 101 |
|
| 102 |
3.1.2) Create the database: |
| 103 |
[root@localhost]# su - postgres |
| 104 |
[postgres@localhost]$ createdb example |
| 105 |
|
| 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> |
| 111 |
|
| 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 |
| 120 |
|
| 121 |
3.1.5) Run the test: |
| 122 |
[root@localhost]# cd $SOURCES/tests |
| 123 |
[root@localhost]# SLAPD_USE_SQL=pgsql ./run sql-test000 |
| 124 |
|
| 125 |
3.2) MySQL |
| 126 |
|
| 127 |
3.2.1) Start the server |
| 128 |
on RedHat: |
| 129 |
[root@localhost]# service mysqld start |
| 130 |
on other systems: read the docs... |
| 131 |
|
| 132 |
3.2.2) Create the database: |
| 133 |
[root@localhost]# mysqladmin -u root -p create example |
| 134 |
(hit <return> for the empty password). |
| 135 |
|
| 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; |
| 141 |
mysql> exit; |
| 142 |
|
| 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 |
| 149 |
|
| 150 |
3.2.5) Run the test: |
| 151 |
[root@localhost]# cd $SOURCES/tests |
| 152 |
[root@localhost]# SLAPD_USE_SQL=mysql ./run sql-test000 |
| 153 |
|
| 154 |
3.3) IBM db2 |
| 155 |
[n.a.] |
| 156 |
|
| 157 |
3.3.1) Start the server: |
| 158 |
|
| 159 |
3.3.2) Create the database: |
| 160 |
|
| 161 |
3.3.3) Create the user: |
| 162 |
|
| 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" |
| 173 |
|
| 174 |
3.3.5) Run the test: |
| 175 |
[root@localhost]# cd $SOURCES/tests |
| 176 |
[root@localhost]# SLAPD_USE_SQL=ibmdb2 ./run sql-test000 |
| 177 |
|
| 178 |
4) Cleanup: |
| 179 |
The test is basically readonly; this can be performed by all RDBMSes |
| 180 |
(listed above). |
| 181 |
|
| 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. |
| 186 |
|
| 187 |
More tests are to come; PostgreSQL is known to allow a full reload |
| 188 |
of the test database starting from an empty database. |
| 189 |
|