blob: b1561cb5712c4db906f3b4400536595f5bae1903 [file] [log] [blame]
Jason Huntley25bbd512012-08-02 11:10:31 -04001[[createdb]]
2Database Setup
3--------------
4
David Pursehouse6b1a7db2013-01-16 16:34:07 +09005During the init phase of Gerrit you will need to specify which database to use.
6
Jason Huntley25bbd512012-08-02 11:10:31 -04007[[createdb_h2]]
8H2
9~~
10
Jason Huntley25bbd512012-08-02 11:10:31 -040011If you choose H2, Gerrit will automatically set up the embedded H2 database as
David Pursehouse6b1a7db2013-01-16 16:34:07 +090012backend so no set up or configuration is necessary.
13
14Using the embedded H2 database is the easiest way to get a Gerrit
Jason Huntley25bbd512012-08-02 11:10:31 -040015site up and running, making it ideal for proof of concepts or small team
16servers. On the flip side, H2 is not the recommended option for large
17corporate installations. This is because there is no easy way to interact
18with the database while Gerrit is offline, it's not easy to backup the data,
19and it's not possible to set up H2 in a load balanced/hotswap configuration.
20
Jason Huntley25bbd512012-08-02 11:10:31 -040021If this option interests you, you might want to consider link:install-quick.html[the quick guide].
22
23[[createdb_postgres]]
24PostgreSQL
25~~~~~~~~~~
26
27This option is more complicated than the H2 option but is recommended
28for larger installations. It's the database backend with the largest userbase
29in the Gerrit community.
30
31Create a user for the web application within Postgres, assign it a
32password, create a database to store the metadata, and grant the user
33full rights on the newly created database:
34
35----
Shawn Pearce53cc8ec2013-04-18 17:49:11 -070036 $ createuser --username=postgres -RDIElPS gerrit2
Jason Huntley6b93d232012-09-24 15:03:00 -040037 $ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb
Jason Huntley25bbd512012-08-02 11:10:31 -040038----
39
Jason Huntley6b93d232012-09-24 15:03:00 -040040Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding
41using PostgreSQL.
Jason Huntley25bbd512012-08-02 11:10:31 -040042
43[[createdb_mysql]]
44MySQL
45~~~~~
46
47This option is also more complicated than the H2 option. Just as with
48PostgreSQL it's also recommended for larger installations.
49
50Create a user for the web application within the database, assign it a
51password, create a database, and give the newly created user full
52rights on it:
53
54----
55 mysql
56
57 CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
58 CREATE DATABASE reviewdb;
59 ALTER DATABASE reviewdb charset=latin1;
60 GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
61 FLUSH PRIVILEGES;
Jason Huntley6b93d232012-09-24 15:03:00 -040062----
63
64Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
65information regarding using MySQL.
David Ostrovsky399793f2013-07-14 14:37:17 +020066
67[[createdb_oracle]]
68Oracle
69~~~~~~
70
71PostgreSQL or H2 is the recommended database for Gerrit Code Review.
72Oracle is supported for environments where running on an existing Oracle
73installation simplifies administrative overheads, such as database backups.
74
75Create a user for the web application within sqlplus, assign it a
76password, and grant the user full rights on the newly created database:
77
78----
79 SQL> create user gerrit2 identified by secret_password default tablespace users;
80 SQL> grant connect, resources to gerrit2;
81----
82
83JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit
84initialization process tries to copy it from a known location:
85
86----
87/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar
88----
89
90If this file can not be located at this place, then the alternative location
91can be provided.
92
93Instance name is the Oracle SID. Sample database section in
94$site_path/etc/gerrit.config:
95
96----
97[database]
98 type = oracle
99 instance = xe
100 hostname = localhost
101 username = gerrit2
102 port = 1521
103----
104
105Sample database section in $site_path/etc/secure.config:
106
107----
108[database]
109 password = secret_pasword
110----