]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/rdbms_depend/README
blind update of IBM db2 example data
[openldap] / servers / slapd / back-sql / rdbms_depend / README
1 Author: Pierangelo Masarati <ando@OpenLDAP.org>
2
3 Back-sql can be tested with test031-sql; it requires a bit of work to get
4 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 exaustive 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 PostgreSQL and with MySQL;
13 basic support and test data for other RDBMSes is in place, but as of
14 today (August 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
89 3) The RDBMS must be setup; examples are provided for my installations 
90 of PostgreSQL and MySQL, but details may change; other RDBMSes should
91 be configured in a similar manner, you need to find out the details by
92 reading their documentation.
93
94 3.1) PostgreSQL
95
96 3.1.1) Start the server
97 on RedHat:
98 [root@localhost]# service postgresql start
99 on other systems: read the docs...
100
101 3.1.2) Create the database:
102 [root@localhost]# su - postgres
103 [postgres@localhost]$ createdb example
104
105 3.1.3) Create the user:
106 [root@localhost]# su - postgres
107 [postgres@localhost]$ psql example
108 example=> create user manager with password 'secret';
109 example=> <control-D>
110
111 3.1.4) Populate the database:
112 [root@localhost]# cd $SOURCES/servers/slapd/back-sql/rdbms_depend/pgsql/
113 [root@localhost]# psql -U manager -W example
114 example=> <control-D>
115 [root@localhost]# psql -U manager example < backsql_create.sql
116 [root@localhost]# psql -U manager example < testdb_create.sql
117 [root@localhost]# psql -U manager example < testdb_data.sql
118 [root@localhost]# psql -U manager example < testdb_metadata.sql
119
120 3.1.5) Run the test:
121 [root@localhost]# cd $SOURCES/tests
122 [root@localhost]# SLAPD_USE_SQL=postgres ./run test031
123
124 3.2) MySQL
125
126 3.2.1) Start the server
127 on RedHat:
128 [root@localhost]# service mysqld start
129 on other systems: read the docs...
130
131 3.2.2) Create the database:
132 [root@localhost]# mysqladmin -u root -p create example
133 (hit <return> for the empty password).
134
135 3.2.3) Create the user:
136 [root@localhost]# mysql -u root -p example
137 (hit <return> for the empty password)
138 mysql> grant all privileges on *.* \
139   to 'manager'@'localhost' identified by 'secret' with grant option;
140 mysql> exit;
141
142 3.2.4) Populate the database:
143 [root@localhost]# cd $SOURCES/servers/slapd/back-sql/rdbms_depend/mysql/
144 [root@localhost]# mysql -u manager -p example < backsql_create.sql
145 [root@localhost]# mysql -u manager -p example < testdb_create.sql
146 [root@localhost]# mysql -u manager -p example < testdb_data.sql
147 [root@localhost]# mysql -u manager -p example < testdb_metadata.sql
148
149 3.2.5) Run the test:
150 [root@localhost]# cd $SOURCES/tests
151 [root@localhost]# SLAPD_USE_SQL=mysql ./run test031
152
153 3.3) IBM db2
154
155 3.3.1) Start the server:
156
157 3.3.2) Create the database:
158
159 3.3.3) Create the user:
160
161 3.3.4) Populate the database:
162 connect to the database as user manager, and execute the test files
163 in auto-commit mode (-c)
164 [root@localhost]# su - manager
165 [manager@localhost]$ db2 "connect to example user manager using secret"
166 [manager@localhost]$ db2 -ctvf backsql_create.sql
167 [manager@localhost]$ db2 -ctvf testdb_create.sql
168 [manager@localhost]$ db2 -ctvf testdb_data.sql
169 [manager@localhost]$ db2 -ctvf testdb_metadata.sql
170 [manager@localhost]$ db2 "connect reset"
171
172 3.3.5) Run the test:
173 [root@localhost]# cd $SOURCES/tests
174 [root@localhost]# SLAPD_USE_SQL=ibmdb2 ./run test031
175
176 4) Cleanup:
177 The basic portion of the test is readonly; this is performed by all RDBMSes.
178 The secondary part involves write operations.  Currently, the write
179 portion of the test is enabled only for PostgreSQL and IBM db2.
180 Note that after a successful run of the write portion, the database is 
181 no longer in the correct state to restart the test, and step 3.X.4 needs 
182 to be re-run first.
183