blob: 4f854fb302678f113a7e1c1fb0b8108acf19b8f5 [file] [log] [blame]
Jason Huntley25bbd512012-08-02 11:10:31 -04001[[createdb]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08002== Database Setup
Jason Huntley25bbd512012-08-02 11:10:31 -04003
David Pursehouse6b1a7db2013-01-16 16:34:07 +09004During the init phase of Gerrit you will need to specify which database to use.
5
Jason Huntley25bbd512012-08-02 11:10:31 -04006[[createdb_h2]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08007=== H2
Jason Huntley25bbd512012-08-02 11:10:31 -04008
Jason Huntley25bbd512012-08-02 11:10:31 -04009If you choose H2, Gerrit will automatically set up the embedded H2 database as
David Pursehouse6b1a7db2013-01-16 16:34:07 +090010backend so no set up or configuration is necessary.
11
12Using the embedded H2 database is the easiest way to get a Gerrit
Jason Huntley25bbd512012-08-02 11:10:31 -040013site up and running, making it ideal for proof of concepts or small team
14servers. On the flip side, H2 is not the recommended option for large
15corporate installations. This is because there is no easy way to interact
16with the database while Gerrit is offline, it's not easy to backup the data,
17and it's not possible to set up H2 in a load balanced/hotswap configuration.
18
Jason Huntley25bbd512012-08-02 11:10:31 -040019If this option interests you, you might want to consider link:install-quick.html[the quick guide].
20
21[[createdb_postgres]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080022=== PostgreSQL
Jason Huntley25bbd512012-08-02 11:10:31 -040023
24This option is more complicated than the H2 option but is recommended
25for larger installations. It's the database backend with the largest userbase
26in the Gerrit community.
27
28Create a user for the web application within Postgres, assign it a
29password, create a database to store the metadata, and grant the user
30full rights on the newly created database:
31
32----
Shawn Pearce53cc8ec2013-04-18 17:49:11 -070033 $ createuser --username=postgres -RDIElPS gerrit2
Jason Huntley6b93d232012-09-24 15:03:00 -040034 $ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb
Jason Huntley25bbd512012-08-02 11:10:31 -040035----
36
Jason Huntley6b93d232012-09-24 15:03:00 -040037Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding
38using PostgreSQL.
Jason Huntley25bbd512012-08-02 11:10:31 -040039
40[[createdb_mysql]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080041=== MySQL
Jason Huntley25bbd512012-08-02 11:10:31 -040042
43This option is also more complicated than the H2 option. Just as with
44PostgreSQL it's also recommended for larger installations.
45
46Create a user for the web application within the database, assign it a
47password, create a database, and give the newly created user full
48rights on it:
49
50----
51 mysql
52
53 CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
54 CREATE DATABASE reviewdb;
Jason Huntley25bbd512012-08-02 11:10:31 -040055 GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
56 FLUSH PRIVILEGES;
Jason Huntley6b93d232012-09-24 15:03:00 -040057----
58
59Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
60information regarding using MySQL.
David Ostrovsky399793f2013-07-14 14:37:17 +020061
62[[createdb_oracle]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080063=== Oracle
David Ostrovsky399793f2013-07-14 14:37:17 +020064
65PostgreSQL or H2 is the recommended database for Gerrit Code Review.
66Oracle is supported for environments where running on an existing Oracle
67installation simplifies administrative overheads, such as database backups.
68
69Create a user for the web application within sqlplus, assign it a
70password, and grant the user full rights on the newly created database:
71
72----
73 SQL> create user gerrit2 identified by secret_password default tablespace users;
74 SQL> grant connect, resources to gerrit2;
75----
76
77JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit
78initialization process tries to copy it from a known location:
79
80----
81/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar
82----
83
84If this file can not be located at this place, then the alternative location
85can be provided.
86
87Instance name is the Oracle SID. Sample database section in
88$site_path/etc/gerrit.config:
89
90----
91[database]
92 type = oracle
93 instance = xe
94 hostname = localhost
95 username = gerrit2
96 port = 1521
97----
98
99Sample database section in $site_path/etc/secure.config:
100
101----
102[database]
103 password = secret_pasword
104----
Yuxuan 'fishy' Wang84065aa2013-08-29 15:10:24 -0700105
Stefan Lay3e8dee22013-04-18 16:21:42 +0200106[[createdb_maxdb]]
107=== SAP MaxDB
108
109SAP MaxDB is a supported database for running Gerrit Code Review. However it is
110recommended only for environments where you intend to run Gerrit on an existing
111MaxDB installation to reduce administrative overhead.
112
113In the MaxDB studio or using the SQLCLI command line interface create a user
114'gerrit2' with the user class 'RESOURCE' and a password <secret password>. This
115will also create an associated schema on the database.
116
117To run Gerrit on MaxDB, you need to obtain the MaxDB JDBC driver. It can be
118found in your MaxDB installation at the following location:
119
120- on Windows 64bit at "C:\Program Files\sdb\MaxDB\runtime\jar\sapdbc.jar"
121- on Linux at "/opt/sdb/MaxDB/runtime/jar/sapdbc.jar"
122
123It needs to be stored in the 'lib' folder of the review site.
124
125In the following sample database section it is assumed that the database name is
126'reviewdb' and the database is installed on localhost:
127
128In $site_path/etc/gerrit.config:
129
130----
131[database]
132 type = maxdb
133 database = reviewdb
134 hostname = localhost
135 username = gerrit2
136
137----
138
139In $site_path/etc/secure.config:
140
141----
142[database]
143 password = <secret password>
144----
145
146Visit SAP MaxDB's link:http://maxdb.sap.com/documentation/[documentation] for further
147information regarding using SAP MaxDB.
148
Yuxuan 'fishy' Wang84065aa2013-08-29 15:10:24 -0700149
150GERRIT
151------
152Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700153
154SEARCHBOX
155---------