Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 1 | [[createdb]] |
| 2 | Database Setup |
| 3 | -------------- |
| 4 | |
David Pursehouse | 6b1a7db | 2013-01-16 16:34:07 +0900 | [diff] [blame] | 5 | During the init phase of Gerrit you will need to specify which database to use. |
| 6 | |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 7 | [[createdb_h2]] |
| 8 | H2 |
| 9 | ~~ |
| 10 | |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 11 | 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] | 12 | backend so no set up or configuration is necessary. |
| 13 | |
| 14 | 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] | 15 | site up and running, making it ideal for proof of concepts or small team |
| 16 | servers. On the flip side, H2 is not the recommended option for large |
| 17 | corporate installations. This is because there is no easy way to interact |
| 18 | with the database while Gerrit is offline, it's not easy to backup the data, |
| 19 | and it's not possible to set up H2 in a load balanced/hotswap configuration. |
| 20 | |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 21 | If this option interests you, you might want to consider link:install-quick.html[the quick guide]. |
| 22 | |
| 23 | [[createdb_postgres]] |
| 24 | PostgreSQL |
| 25 | ~~~~~~~~~~ |
| 26 | |
| 27 | This option is more complicated than the H2 option but is recommended |
| 28 | for larger installations. It's the database backend with the largest userbase |
| 29 | in the Gerrit community. |
| 30 | |
| 31 | Create a user for the web application within Postgres, assign it a |
| 32 | password, create a database to store the metadata, and grant the user |
| 33 | full rights on the newly created database: |
| 34 | |
| 35 | ---- |
Shawn Pearce | 53cc8ec | 2013-04-18 17:49:11 -0700 | [diff] [blame] | 36 | $ createuser --username=postgres -RDIElPS gerrit2 |
Jason Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 37 | $ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 38 | ---- |
| 39 | |
Jason Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 40 | Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding |
| 41 | using PostgreSQL. |
Jason Huntley | 25bbd51 | 2012-08-02 11:10:31 -0400 | [diff] [blame] | 42 | |
| 43 | [[createdb_mysql]] |
| 44 | MySQL |
| 45 | ~~~~~ |
| 46 | |
| 47 | This option is also more complicated than the H2 option. Just as with |
| 48 | PostgreSQL it's also recommended for larger installations. |
| 49 | |
| 50 | Create a user for the web application within the database, assign it a |
| 51 | password, create a database, and give the newly created user full |
| 52 | rights 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 Huntley | 6b93d23 | 2012-09-24 15:03:00 -0400 | [diff] [blame] | 62 | ---- |
| 63 | |
| 64 | Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further |
| 65 | information regarding using MySQL. |
David Ostrovsky | 399793f | 2013-07-14 14:37:17 +0200 | [diff] [blame^] | 66 | |
| 67 | [[createdb_oracle]] |
| 68 | Oracle |
| 69 | ~~~~~~ |
| 70 | |
| 71 | PostgreSQL or H2 is the recommended database for Gerrit Code Review. |
| 72 | Oracle is supported for environments where running on an existing Oracle |
| 73 | installation simplifies administrative overheads, such as database backups. |
| 74 | |
| 75 | Create a user for the web application within sqlplus, assign it a |
| 76 | password, 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 | |
| 83 | JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit |
| 84 | initialization 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 | |
| 90 | If this file can not be located at this place, then the alternative location |
| 91 | can be provided. |
| 92 | |
| 93 | Instance 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 | |
| 105 | Sample database section in $site_path/etc/secure.config: |
| 106 | |
| 107 | ---- |
| 108 | [database] |
| 109 | password = secret_pasword |
| 110 | ---- |