[root@wulaoer ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.48-log Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database gerritdb CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.07 sec)
mysql> grant all on gerritdb.* to 'gerrituser'@'localhost' identified by 'gerritpass';
Query OK, 0 rows affected (0.06 sec)
[root@wulaoer ~]# su - gerrit
[gerrit@wulaoer ~]$ java -jar gerrit-2.11.3.war init -d ~/gerrit_site
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
*** Gerrit Code Review 2.11.3
***
*** Git Repositories
***
Location of Git repositories [git]:
*** SQL Database
***
Database server type [h3]: mysql #选择mysql
Server hostname [localhost]:
Server port [(mysql default)]:
Database name [reviewdb]: gerritdb #数据库名
Database username [gerrit]: gerrituser #数据库用户名
gerrituser's password :
confirm password : #数据库密码
*** Index
***
Type [LUCENE/?]:
The index must be rebuilt before starting Gerrit:
java -jar gerrit.war reindex -d site_path
*** User Authentication
***
Authentication method [OPENID/?]: http
Get username from custom HTTP header [y/N]?
SSO logout URL :
*** Review Labels
***
Install Verified label [y/N]? y
*** Email Delivery
***
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [NONE/?]:
SMTP username :
*** Container Process
***
Run as [gerrit]:
Java runtime [/usr/local/jvm/jdk1.8.0_101/jre]:
Copy gerrit-2.11.3.war to /home/gerrit/gerrit_site/bin/gerrit.war [Y/n]?
Copying gerrit-2.11.3.war to /home/gerrit/gerrit_site/bin/gerrit.war
*** SSH Daemon
***
Listen on address [*]:
Listen on port [29418]:
Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v151
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]?
Renaming bcpkix-jdk15on-1.52.jar to .bcpkix-jdk15on-1.52.jar.backupDownloading http://www.bouncycastle.org/download/bcpkix-jdk15on-151.jar ... !! FAIL !!
error: http://www.bouncycastle.org/download/bcpkix-jdk15on-151.jar: 302 Found
Please download:
http://www.bouncycastle.org/download/bcpkix-jdk15on-151.jar
and save as:
/home/gerrit/gerrit_site/lib/bcpkix-jdk15on-151.jar
Press enter to continue
Continue without this library [Y/n]?
Generating SSH host key ... rsa(simple)... done
*** HTTP Daemon
***
Behind reverse proxy [y/N]?
Use SSL (https://) [y/N]?
Listen on address [*]:
Listen on port [8080]:
Canonical URL [http://localhost:8080/]:
*** Plugins
***
Installing plugins.
Install plugin download-commands version v2.11.3 [y/N]?
Install plugin reviewnotes version v2.11.3 [y/N]?
Install plugin singleusergroup version v2.11.3 [y/N]?
Install plugin replication version v2.11.3 [y/N]?
Install plugin commit-message-length-validator version v2.11.3 [y/N]?
Initializing plugins.
No plugins found with init steps.
Initialized /home/gerrit/gerrit_site
[gerrit@wulaoer ~]$ java -jar gerrit-2.11.3.war reindex -d /home/gerrit/gerrit_site
[2016-09-06 10:22:27,387] INFO com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 61m
[2016-09-06 10:22:28,067] INFO com.google.gerrit.server.cache.h3.H2CacheFactory : Enabling disk cache /home/gerrit/gerrit_site/cache
Reindexing changes: done
Reindexed 0 changes in 0.0s (0.0/s)
Warning: InterruptedException
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Thread.join(Thread.java:1253)
at org.h3.util.MathUtils.getSecureRandom(MathUtils.java:104)
at org.h3.util.MathUtils.secureRandomBytes(MathUtils.java:301)
at org.h3.store.FileLock.setUniqueId(FileLock.java:309)
at org.h3.store.FileLock.lockFile(FileLock.java:339)
at org.h3.store.FileLock.lock(FileLock.java:133)
at org.h3.engine.Database.open(Database.java:575)
at org.h3.engine.Database.openDatabase(Database.java:236)
at org.h3.engine.Database.(Database.java:231)
at org.h3.engine.Engine.openSession(Engine.java:56)
at org.h3.engine.Engine.openSession(Engine.java:160)
at org.h3.engine.Engine.createSessionAndValidate(Engine.java:139)
at org.h3.engine.Engine.createSession(Engine.java:122)
at org.h3.engine.Engine.createSession(Engine.java:28)
at org.h3.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:323)
at org.h3.jdbc.JdbcConnection.(JdbcConnection.java:105)
at org.h3.jdbc.JdbcConnection.(JdbcConnection.java:90)
at org.h3.Driver.connect(Driver.java:73)
at com.google.gerrit.server.cache.h3.H2CacheImpl$SqlHandle.(H2CacheImpl.java:636)
at com.google.gerrit.server.cache.h3.H2CacheImpl$SqlStore.acquire(H2CacheImpl.java:604)
at com.google.gerrit.server.cache.h3.H2CacheImpl$SqlStore.buildBloomFilter(H2CacheImpl.java:365)
at com.google.gerrit.server.cache.h3.H2CacheImpl$SqlStore.open(H2CacheImpl.java:337)
at com.google.gerrit.server.cache.h3.H2CacheImpl.start(H2CacheImpl.java:167)
at com.google.gerrit.server.cache.h3.H2CacheFactory$1.run(H2CacheFactory.java:113)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[2016-09-06 10:22:29,825] INFO com.google.gerrit.server.cache.h3.H2CacheFactory : Finishing 4 disk cache updates
启动一次看看
[gerrit@wulaoer ~]$ /home/gerrit/gerrit_site/bin/gerrit.sh start
Starting Gerrit Code Review: OK
如果出现
[gerrit@wulaoer ~]$ /home/gerrit/gerrit_site/bin/gerrit.sh start
** ERROR: GERRIT_SITE not set
[root@wulaoer ~]# htpasswd -c /home/gerrit/gerrit_site/etc/passwords gerrit
New password:
Re-type new password:
Adding password for user gerrit
[root@wulaoer ~]# htpasswd /home/gerrit/gerrit_site/etc/passwords wulaoer
New password:
Re-type new password:
Adding password for user wulaoer
[root@wulaoer ~]# htpasswd /home/gerrit/gerrit_site/etc/passwords jenkins
New password:
Re-type new password:
Adding password for user jenkins
[root@wulaoer ~]# su - gerrit
[gerrit@wulaoer ~]$ ssh-keygen -t rsa -C 99317069@qq.com
Generating public/private rsa key pair.
Enter file in which to save the key (/home/gerrit/.ssh/id_rsa):
Created directory '/home/gerrit/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/gerrit/.ssh/id_rsa.
Your public key has been saved in /home/gerrit/.ssh/id_rsa.pub.
The key fingerprint is:
bc:58:5a:8d:73:0b:ac:01:39:ac:96:02:85:45:92:ba 99317069@qq.com
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
|.=+ |
|oo . . |
|o = |
|o o o o o |
|..+ . S o |
|Eo B = . |
| + . . |
| |
| |
+-----------------+
[gerrit@wulaoer ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2e/iJxw7FG0rhSZkSy2M31JBW/lnNewRgu6cyC2jMheqYVHZhf9XlAR9gfR8V8h2nqBo8GWraNchdOAdTNTZ1nqfrE4iDRd2FKhL2zx47oErj3H/Hv6747r0pagP+kCt7c2hglHXhhs4SLWg3BSK+tXOM1Db7kgp+QhwrbmjkbLXJ+G/LwlLJMY1q6mI5fmEUmCC+QfZgZ9e9vKO6fjFDjD5nHsRd70Jnf1fUQC99FvqiYhw8e/YJNnY+dMoczTDDwzx6zsB0qx6Cpw5GskCUPVztqDeH7TgRZgY6Ttkakglied2sv11sRzVV0sn3msCgmu1qsIdTeCDx5gdJQEI0w== 99317069@qq.com
[gerrit@wulaoer ~]$ vi .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
然后让文件生效
[gerrit@wulaoer ~]$ source .bashrc
[gerrit@wulaoer ~]$ ssh-gerrit
The authenticity of host '[192.168.0.145]:29418 ([192.168.0.145]:29418)' can't be established.
RSA key fingerprint is 4f:6a:ec:3c:7e:52:2e:56:0a:e0:b1:fb:38:86:da:42.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.0.145]:29418' (RSA) to the list of known hosts.
**** Welcome to Gerrit Code Review ****
Hi gerrit管理员, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://gerrit@192.168.0.145:29418/REPOSITORY_NAME.git
Connection to 192.168.0.145 closed.