Gerrit/Running in Cloud VPS
To get a Gerrit instance running on a Cloud VPS instance, first setup a DB backend, then the actual Gerrit server. (Or use the existing DB instance gerrit-mysql).
The following instructions are outdated. Gerrit does not use MySQL anymore. It keeps all the data in in the local file system in .h2 files.
Setting up MySQL (DB and db user)
1. create an instance that you will be hosting MySQL on.
2. ssh into your MySQL instance you just created
3. install mysql: apt-get install MySQL-server-5.5 (note it will ask you to create a password, set to something random or leave this blank for testing purposes, there is no private data in Cloud VPS and users who have access to the instance will be able to reset it anyways)
4. vim /etc/mysql/my.cnf ; (add these under [mysqld_safe], [mysqld] and [mysqldump])
character-set-server=utf8 collation-server=utf8_unicode_ci
under [mysqld] look for
bind-address
you will need to change the ip in bind-address to the one of gerrit host
(press esc and then :wq and enter)
5. mysql -p (enter the password if you have one. If you created the password use the one you just used in the mysql setup) (press enter again if you haven't a password otherwise enter your password)
6. CREATE USER 'gerrit'@'10.68.23.148' IDENTIFIED BY 'l5uCkoYX+zYtH'; (Note where it says 10.68.23.148 please use your gerrit instance ip there instead) (This is the puppetized Gerrit application password, in Cloud VPS it comes from the public so called "labs/private" repo, in prod it's obviously different and comes from an actually private repo.)
7. CREATE DATABASE reviewdb;
8. GRANT ALL ON reviewdb.* TO 'gerrit'@'10.68.23.148'; (Note where it says 10.68.23.148 please use your gerrit instance ip there instead)
9. FLUSH PRIVILEGES; (not really needed but Gerrit docs claim it is :p)
10. type exit, done. continue setting up a seperate Gerrit instance as described in https://phabricator.wikimedia.org/P3637
Setting up gerrit
1. Create a fresh instance to run Gerrit itself
2. Before you apply any role on it, make sure if you: either use the existing "gerrit-mysql" instance as db backend or follow mysql setup instructions at https://phabricator.wikimedia.org/P3939 to make a new one. (don't manually install mysql on localhost). If you don't use "gerrit-mysql",make sure the "gerrit::jetty::db_host" is set to the correct server in Hiera (example: https://wikitech.wikimedia.org/w/index.php?title=Hiera%3AGit&type=revision&diff=819031&oldid=816844) The DB part should be running _before_ you start the Gerrit service.
3. Look in https://wikitech.wikimedia.org/wiki/Special:NovaInstance (Instance ID) for instance address to put in "gerrit::jetty::db_host": <id>
4. go to hiera in wikitech (Hiera:<project_name>) https://wikitech.wikimedia.org/wiki/Hiera:Git and add this unless it's already there from before "gerrit::jetty::db_host": <from step 3> "role::gerrit::server::ipv4": <instance-ip> "gerrit::host": <the domain you setup in horizon>
5. apply role::gerrit::server in wikitech
6. sudo puppet agent -tv
7. /usr/bin/java -jar gerrit.war init -d review_site --batch --no-auto-start
8. sudo apt-get --purge remove gerrit
9. sudo puppet agent -tv (<< that should reinstall it). (it's normal to see some errors until here)
10. cd /var/lib/gerrit2/ & java -jar gerrit.war reindex -d review_site --threads 4
11. sudo puppet agent -tv
12. sudo puppet agent -tv
Notices
This is by @Paladox and @Dzahn.
Thanks to @ostriches (demon|^demon) for fixing up puppet and getting it to run on Cloud VPS.