Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 1 | [[createdb]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 2 | == Database Setup |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 3 | |
David Pursehouse | 6b1a7db | 2013-01-16 16:34:07 +0900 | [diff] [blame] | 4 | During the init phase of Gerrit you will need to specify which database to use. |
| 5 | |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 6 | [[createdb_h2]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 7 | === H2 |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 8 | |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 9 | If you choose H2, Gerrit will automatically set up the embedded H2 database as |
David Pursehouse | 6b1a7db | 2013-01-16 16:34:07 +0900 | [diff] [blame] | 10 | backend so no set up or configuration is necessary. |
| 11 | |
| 12 | Using the embedded H2 database is the easiest way to get a Gerrit |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 13 | site up and running, making it ideal for proof of concepts or small team |
| 14 | servers. On the flip side, H2 is not the recommended option for large |
| 15 | corporate installations. This is because there is no easy way to interact |
| 16 | with the database while Gerrit is offline, it's not easy to backup the data, |
| 17 | and it's not possible to set up H2 in a load balanced/hotswap configuration. |
| 18 | |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 19 | If this option interests you, you might want to consider link:install-quick.html[the quick guide]. |
| 20 | |
| 21 | [[createdb_postgres]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 22 | === PostgreSQL |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 23 | |
| 24 | This option is more complicated than the H2 option but is recommended |
| 25 | for larger installations. It's the database backend with the largest userbase |
| 26 | in the Gerrit community. |
| 27 | |
| 28 | Create a user for the web application within Postgres, assign it a |
| 29 | password, create a database to store the metadata, and grant the user |
| 30 | full rights on the newly created database: |
| 31 | |
| 32 | ---- |
Shawn Pearce | 53cc8ec | 2013-04-18 17:49:11 -0700 | [diff] [blame] | 33 | $ createuser --username=postgres -RDIElPS gerrit2 |
Jason Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 34 | $ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 35 | ---- |
| 36 | |
Jason Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 37 | Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding |
| 38 | using PostgreSQL. |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 39 | |
| 40 | [[createdb_mysql]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 41 | === MySQL |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 42 | |
| 43 | This option is also more complicated than the H2 option. Just as with |
| 44 | PostgreSQL it's also recommended for larger installations. |
| 45 | |
| 46 | Create a user for the web application within the database, assign it a |
| 47 | password, create a database, and give the newly created user full |
| 48 | rights on it: |
| 49 | |
| 50 | ---- |
| 51 | mysql |
| 52 | |
| 53 | CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret'; |
| 54 | CREATE DATABASE reviewdb; |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 55 | GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost'; |
| 56 | FLUSH PRIVILEGES; |
Jason Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 57 | ---- |
| 58 | |
Julien Pivotto | 13d07ec | 2014-02-18 11:05:07 +0100 | [diff] [blame] | 59 | If 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 Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 67 | Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further |
| 68 | information regarding using MySQL. |
David Ostrovsky | 399793f | 2013-07-14 14:37:17 +0200 | [diff] [blame] | 69 | |
| 70 | [[createdb_oracle]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 71 | === Oracle |
David Ostrovsky | 399793f | 2013-07-14 14:37:17 +0200 | [diff] [blame] | 72 | |
| 73 | PostgreSQL or H2 is the recommended database for Gerrit Code Review. |
| 74 | Oracle is supported for environments where running on an existing Oracle |
| 75 | installation simplifies administrative overheads, such as database backups. |
| 76 | |
| 77 | Create a user for the web application within sqlplus, assign it a |
| 78 | password, 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 | |
| 85 | JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit |
| 86 | initialization 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 | |
| 92 | If this file can not be located at this place, then the alternative location |
| 93 | can be provided. |
| 94 | |
| 95 | Instance 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 | |
| 107 | Sample database section in $site_path/etc/secure.config: |
| 108 | |
| 109 | ---- |
| 110 | [database] |
| 111 | password = secret_pasword |
| 112 | ---- |
Yuxuan 'fishy' Wang | 84065aa | 2013-08-29 15:10:24 -0700 | [diff] [blame] | 113 | |
Stefan Lay | 3e8dee2 | 2013-04-18 16:21:42 +0200 | [diff] [blame] | 114 | [[createdb_maxdb]] |
| 115 | === SAP MaxDB |
| 116 | |
| 117 | SAP MaxDB is a supported database for running Gerrit Code Review. However it is |
| 118 | recommended only for environments where you intend to run Gerrit on an existing |
| 119 | MaxDB installation to reduce administrative overhead. |
| 120 | |
| 121 | In 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 |
| 123 | will also create an associated schema on the database. |
| 124 | |
| 125 | To run Gerrit on MaxDB, you need to obtain the MaxDB JDBC driver. It can be |
| 126 | found 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 | |
| 131 | It needs to be stored in the 'lib' folder of the review site. |
| 132 | |
| 133 | In the following sample database section it is assumed that the database name is |
| 134 | 'reviewdb' and the database is installed on localhost: |
| 135 | |
| 136 | In $site_path/etc/gerrit.config: |
| 137 | |
| 138 | ---- |
| 139 | [database] |
| 140 | type = maxdb |
| 141 | database = reviewdb |
| 142 | hostname = localhost |
| 143 | username = gerrit2 |
| 144 | |
| 145 | ---- |
| 146 | |
| 147 | In $site_path/etc/secure.config: |
| 148 | |
| 149 | ---- |
| 150 | [database] |
| 151 | password = <secret password> |
| 152 | ---- |
| 153 | |
| 154 | Visit SAP MaxDB's link:http://maxdb.sap.com/documentation/[documentation] for further |
| 155 | information regarding using SAP MaxDB. |
| 156 | |
Yuxuan 'fishy' Wang | 84065aa | 2013-08-29 15:10:24 -0700 | [diff] [blame] | 157 | |
| 158 | GERRIT |
| 159 | ------ |
| 160 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 161 | |
| 162 | SEARCHBOX |
| 163 | --------- |