summaryrefslogtreecommitdiffstats
path: root/Documentation/database-setup.txt
blob: de4fb20254ce4a463d2dcf6e289796ad47838081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
[[createdb]]
== Database Setup

During the init phase of Gerrit you will need to specify which database to use.

[[createdb_h2]]
=== H2

If you choose H2, Gerrit will automatically set up the embedded H2 database as
backend so no set up or configuration is necessary.

Using the embedded H2 database is the easiest way to get a Gerrit
site up and running, making it ideal for proof of concepts or small team
servers.  On the flip side, H2 is not the recommended option for large
corporate installations when using ReviewDb. This is because there is no easy way to interact
with the database while Gerrit is offline, it's not easy to backup the data,
and it's not possible to set up H2 in a load balanced/hotswap configuration.

If this option interests you, you might want to consider
link:linux-quickstart.html[the quick guide].

[[createdb_derby]]
=== Apache Derby

If Derby is selected, Gerrit will automatically set up the embedded Derby
database as backend so no set up or configuration is necessary.

Currently only support for embedded mode is added. There are two other
deployment options for Apache Derby that can be added later:

* link:http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Network+Server+Options[
Derby Network Server (standalone mode)]

* link:http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#Embedded+Server[
Embedded Server (hybrid mode)]

[[createdb_postgres]]
=== PostgreSQL

This option is more complicated than the H2 option but is recommended
for larger installations. It's the database backend with the largest userbase
in the Gerrit community.

Create a user for the web application within PostgreSQL, assign it a
password, create a database to store the metadata, and grant the user
full rights on the newly created database:

----
  $ createuser --username=postgres -RDIElPS gerrit
  $ createdb --username=postgres -E UTF-8 -O gerrit reviewdb
----

Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding
using PostgreSQL.

[[createdb_mysql]]
=== MySQL

Requirements: MySQL version 5.1 or later.

This option is also more complicated than the H2 option. Just as with
PostgreSQL it's also recommended for larger installations.

Create a user for the web application within the database, assign it a
password, create a database, and give the newly created user full
rights on it:

----
  mysql

  CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'secret';
  CREATE DATABASE reviewdb DEFAULT CHARACTER SET 'utf8';
  GRANT ALL ON reviewdb.* TO 'gerrit'@'localhost';
  FLUSH PRIVILEGES;
----

Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
information regarding using MySQL.

[[createdb_mariadb]]
=== MariaDB

Requirements: MariaDB version 5.5 or later.

Refer to MySQL section above how to create MariaDB database.

Visit MariaDB's link:https://mariadb.com/kb/en/mariadb/[documentation] for further
information regarding using MariaDB.

[[createdb_oracle]]
=== Oracle

PostgreSQL or H2 is the recommended database for Gerrit Code Review.
Oracle is supported for environments where running on an existing Oracle
installation simplifies administrative overheads, such as database backups.

Create a user for the web application within sqlplus, assign it a
password, and grant the user full rights on the newly created database:

----
  SQL> create user gerrit identified by secret_password default tablespace users;
  SQL> grant connect, resources to gerrit;
----

JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit
initialization process tries to copy it from a known location:

----
/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar
----

If this file can not be located at this place, then the alternative location
can be provided.

Instance name is the Oracle SID. Sample database section in
$site_path/etc/gerrit.config:

----
[database]
        type = oracle
        instance = xe
        hostname = localhost
        username = gerrit
        port = 1521
----

Sample database section in $site_path/etc/secure.config:

----
[database]
        password = secret_password
----

[[createdb_maxdb]]
=== SAP MaxDB

SAP MaxDB is a supported database for running Gerrit Code Review. However it is
recommended only for environments where you intend to run Gerrit on an existing
MaxDB installation to reduce administrative overhead.

In the MaxDB studio or using the SQLCLI command line interface create a user
'gerrit' with the user class 'RESOURCE' and a password <secret password>. This
will also create an associated schema on the database.

To run Gerrit on MaxDB, you need to obtain the MaxDB JDBC driver. It can be
found in your MaxDB installation at the following location:

- on Windows 64bit at "C:\Program Files\sdb\MaxDB\runtime\jar\sapdbc.jar"
- on Linux at "/opt/sdb/MaxDB/runtime/jar/sapdbc.jar"

It needs to be stored in the 'lib' folder of the review site.

In the following sample database section it is assumed that the database name is
'reviewdb' and the database is installed on localhost:

In $site_path/etc/gerrit.config:

----
[database]
        type = maxdb
        database = reviewdb
        hostname = localhost
        username = gerrit

----

In $site_path/etc/secure.config:

----
[database]
        password = <secret password>
----

Visit SAP MaxDB's link:http://maxdb.sap.com/documentation/[documentation] for further
information regarding using SAP MaxDB.

[[createdb_db2]]
=== DB2

IBM DB2 is a supported database for running Gerrit Code Review. However it is
recommended only for environments where you intend to run Gerrit on an existing
DB2 installation to reduce administrative overhead.

Create a system wide user for the Gerrit application, and grant the user
full rights on the newly created database:

----
  db2 => create database gerrit
  db2 => connect to gerrit
  db2 => grant connect,accessctrl,dataaccess,dbadm,secadm on database to gerrit;
----

JDBC driver db2jcc4.jar and db2jcc_license_cu.jar must be obtained
from your DB2 distribution. Gerrit initialization process tries to copy
it from a known location:

----
/opt/ibm/db2/V10.5/java/db2jcc4.jar
/opt/ibm/db2/V10.5/java/db2jcc_license_cu.jar
----

If these files cannot be located at this place, then an alternative location
can be provided during init step execution.

Sample database section in $site_path/etc/gerrit.config:

----
[database]
        type = db2
        database = gerrit
        hostname = localhost
        username = gerrit
        port = 50001
----

Sample database section in $site_path/etc/secure.config:

----
[database]
        password = secret_password
----

[[createdb_hana]]
=== SAP HANA

SAP HANA is a supported database for running Gerrit Code Review. However it is
recommended only for environments where you intend to run Gerrit on an existing
HANA installation to reduce administrative overhead.

In the HANA studio or the SAP HANA Web-based Development Workbench create a user
'GERRIT2' with the role 'RESTRICTED_USER_JDBC_ACCESS' and a password
<secret password>. This will also create an associated schema on the database.
As this user would be required to change the password upon first login you might
want to to disable the password lifetime check by executing
'ALTER USER GERRIT2 DISABLE PASSWORD LIFETIME'.

To run Gerrit on HANA, you need to obtain the HANA JDBC driver. It can be found
as described
link:http://help.sap.com/saphelp_hanaplatform/helpdata/en/ff/15928cf5594d78b841fbbe649f04b4/frameset.htm[here].
It needs to be stored in the 'lib' folder of the review site.

In the following sample database section it is assumed that HANA is running on
the host 'hana.host' and listening on port '4242' where a schema/user GERRIT2
was created:

In $site_path/etc/gerrit.config:

----
[database]
        type = hana
        hostname = hana.host
        port = 4242
        username = GERRIT2

----

In order to configure a specific database in a multi-database environment (MDC)
the database name has to be specified additionally:

In $site_path/etc/gerrit.config:

----
[database]
        type = hana
        hostname = hana.host
        database = tdb1
        port = 4242
        username = GERRIT2

----

In $site_path/etc/secure.config:

----
[database]
        password = <secret password>
----

Visit SAP HANA's link:http://help.sap.com/hana_appliance/[documentation] for
further information regarding using SAP HANA.