blob: f324a5e0cd8b6317e12492f8bbb2724d61eebdbf [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
Julien Pivotto13d07ec2014-02-18 11:05:07 +010059If you are using the MyISAM engine, you need to set latin1 as charset:
60
61----
62 mysql
63
64 ALTER DATABASE reviewdb charset=latin1;
65----
66
Jason Huntley6b93d232012-09-24 15:03:00 -040067Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
68information regarding using MySQL.
David Ostrovsky399793f2013-07-14 14:37:17 +020069
70[[createdb_oracle]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080071=== Oracle
David Ostrovsky399793f2013-07-14 14:37:17 +020072
73PostgreSQL or H2 is the recommended database for Gerrit Code Review.
74Oracle is supported for environments where running on an existing Oracle
75installation simplifies administrative overheads, such as database backups.
76
77Create a user for the web application within sqlplus, assign it a
78password, and grant the user full rights on the newly created database:
79
80----
81 SQL> create user gerrit2 identified by secret_password default tablespace users;
82 SQL> grant connect, resources to gerrit2;
83----
84
85JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit
86initialization process tries to copy it from a known location:
87
88----
89/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar
90----
91
92If this file can not be located at this place, then the alternative location
93can be provided.
94
95Instance name is the Oracle SID. Sample database section in
96$site_path/etc/gerrit.config:
97
98----
99[database]
100 type = oracle
101 instance = xe
102 hostname = localhost
103 username = gerrit2
104 port = 1521
105----
106
107Sample database section in $site_path/etc/secure.config:
108
109----
110[database]
111 password = secret_pasword
112----
Yuxuan 'fishy' Wang84065aa2013-08-29 15:10:24 -0700113
Stefan Lay3e8dee22013-04-18 16:21:42 +0200114[[createdb_maxdb]]
115=== SAP MaxDB
116
117SAP MaxDB is a supported database for running Gerrit Code Review. However it is
118recommended only for environments where you intend to run Gerrit on an existing
119MaxDB installation to reduce administrative overhead.
120
121In the MaxDB studio or using the SQLCLI command line interface create a user
122'gerrit2' with the user class 'RESOURCE' and a password <secret password>. This
123will also create an associated schema on the database.
124
125To run Gerrit on MaxDB, you need to obtain the MaxDB JDBC driver. It can be
126found in your MaxDB installation at the following location:
127
128- on Windows 64bit at "C:\Program Files\sdb\MaxDB\runtime\jar\sapdbc.jar"
129- on Linux at "/opt/sdb/MaxDB/runtime/jar/sapdbc.jar"
130
131It needs to be stored in the 'lib' folder of the review site.
132
133In the following sample database section it is assumed that the database name is
134'reviewdb' and the database is installed on localhost:
135
136In $site_path/etc/gerrit.config:
137
138----
139[database]
140 type = maxdb
141 database = reviewdb
142 hostname = localhost
143 username = gerrit2
144
145----
146
147In $site_path/etc/secure.config:
148
149----
150[database]
151 password = <secret password>
152----
153
154Visit SAP MaxDB's link:http://maxdb.sap.com/documentation/[documentation] for further
155information regarding using SAP MaxDB.
156
Yuxuan 'fishy' Wang84065aa2013-08-29 15:10:24 -0700157
158GERRIT
159------
160Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700161
162SEARCHBOX
163---------