gerrit/Documentation/database-setup.txt
David Pursehouse 64a9b7404e Merge branch 'stable-2.9'
* stable-2.9:
  Release notes for Gerrit 2.8.6.1
  Remove reference to MyISAM from database setup documentation
  Update version to 2.8.6.1
  Upgrade gwtorm to 1.7.3
  Fix reference to Forge Committer access right in documentation
  Avoid avatar URL requests on load of change list
  Update 2.8.6 release notes with recent fixes
  Update SSHD to 0.11.1-atlassian-1
  Expose Atlassian's maven repository
  Update gwtorm to 1.7.1
  Buck: Strip SNAPSHOT suffix in artifact names only for GERRIT repositories

Conflicts:
	VERSION
	lib/maven.defs

Change-Id: Iacf4e3634cf4dbd2a1b86558f06cf5cdb0e50475
2014-07-09 10:43:12 +09:00

156 lines
4.5 KiB
Plaintext

[[createdb]]
== Database Setup
During the init phase of Gerrit you will need to specify which database to use.
[[createdb_h2]]
=== H2
If you choose H2, Gerrit will automatically set up the embedded H2 database as
backend so no set up or configuration is necessary.
Using the embedded H2 database is the easiest way to get a Gerrit
site up and running, making it ideal for proof of concepts or small team
servers. On the flip side, H2 is not the recommended option for large
corporate installations. This is because there is no easy way to interact
with the database while Gerrit is offline, it's not easy to backup the data,
and it's not possible to set up H2 in a load balanced/hotswap configuration.
If this option interests you, you might want to consider link:install-quick.html[the quick guide].
[[createdb_postgres]]
=== PostgreSQL
This option is more complicated than the H2 option but is recommended
for larger installations. It's the database backend with the largest userbase
in the Gerrit community.
Create a user for the web application within Postgres, assign it a
password, create a database to store the metadata, and grant the user
full rights on the newly created database:
----
$ createuser --username=postgres -RDIElPS gerrit2
$ createdb --username=postgres -E UTF-8 -O gerrit2 reviewdb
----
Visit PostgreSQL's link:http://www.postgresql.org/docs/9.1/interactive/index.html[documentation] for further information regarding
using PostgreSQL.
[[createdb_mysql]]
=== MySQL
This option is also more complicated than the H2 option. Just as with
PostgreSQL it's also recommended for larger installations.
Create a user for the web application within the database, assign it a
password, create a database, and give the newly created user full
rights on it:
----
mysql
CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
CREATE DATABASE reviewdb;
GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
FLUSH PRIVILEGES;
----
Visit MySQL's link:http://dev.mysql.com/doc/[documentation] for further
information regarding using MySQL.
[[createdb_oracle]]
=== Oracle
PostgreSQL or H2 is the recommended database for Gerrit Code Review.
Oracle is supported for environments where running on an existing Oracle
installation simplifies administrative overheads, such as database backups.
Create a user for the web application within sqlplus, assign it a
password, and grant the user full rights on the newly created database:
----
SQL> create user gerrit2 identified by secret_password default tablespace users;
SQL> grant connect, resources to gerrit2;
----
JDBC driver ojdbc6.jar must be obtained from your Oracle distribution. Gerrit
initialization process tries to copy it from a known location:
----
/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar
----
If this file can not be located at this place, then the alternative location
can be provided.
Instance name is the Oracle SID. Sample database section in
$site_path/etc/gerrit.config:
----
[database]
type = oracle
instance = xe
hostname = localhost
username = gerrit2
port = 1521
----
Sample database section in $site_path/etc/secure.config:
----
[database]
password = secret_pasword
----
[[createdb_maxdb]]
=== SAP MaxDB
SAP MaxDB is a supported database for running Gerrit Code Review. However it is
recommended only for environments where you intend to run Gerrit on an existing
MaxDB installation to reduce administrative overhead.
In the MaxDB studio or using the SQLCLI command line interface create a user
'gerrit2' with the user class 'RESOURCE' and a password <secret password>. This
will also create an associated schema on the database.
To run Gerrit on MaxDB, you need to obtain the MaxDB JDBC driver. It can be
found in your MaxDB installation at the following location:
- on Windows 64bit at "C:\Program Files\sdb\MaxDB\runtime\jar\sapdbc.jar"
- on Linux at "/opt/sdb/MaxDB/runtime/jar/sapdbc.jar"
It needs to be stored in the 'lib' folder of the review site.
In the following sample database section it is assumed that the database name is
'reviewdb' and the database is installed on localhost:
In $site_path/etc/gerrit.config:
----
[database]
type = maxdb
database = reviewdb
hostname = localhost
username = gerrit2
----
In $site_path/etc/secure.config:
----
[database]
password = <secret password>
----
Visit SAP MaxDB's link:http://maxdb.sap.com/documentation/[documentation] for further
information regarding using SAP MaxDB.
GERRIT
------
Part of link:index.html[Gerrit Code Review]
SEARCHBOX
---------