如何搭建基於ldap和mysql的gerrit服務

一.搭建數據庫以及配置數據庫

 

1.使用yum install mysql-server安裝mysql

2.mysqladmin -u root password archermind(第一次設置密碼).設置密碼

3.修改 vi /etc/my.cnf

增加[client]項以及修改[mysqld]項.具體如下所示:

 

 [client]

#password       = your_password

port            = 3306

socket          = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

default-character-set=utf8

 

[mysqld]

default-storage-engine = innodb-----這一行要加上

character-set-server=utf8-----這一行要加上

collation-server=utf8_general_ci-----這一行要加上

 

4.啓動mysql服務

service mysqld start

 

5.新建數據庫

(1).輸入mysql -uroot p(密碼archermind

(2).create database gerritdb;

(3).grant all on gerritdb.* to 'root'@'localhost' identified by 'archermind';

(4).flush privileges;

 

(5).ALTER DATABASE gerritym charset=utf8;

(6). flush privileges;


 二. 搭建gerrit

gerrit-2.11.war包可以在網上找到共享的包

(1).搭建的命令如下所示:

[root@svnnj01 gerrit]# java -jar gerrit-2.11.war init -d review_site

Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore

 

*** Gerrit Code Review 2.11

***

 

 

*** Git Repositories

***

 

Location of Git repositories   [git]:

 

*** SQL Database

***

 

Database server type           [mysql]:

Server hostname                [localhost]:

Server port                    [(mysql default)]:

Database name                  [gerritdb]:

Database username              [root]:

Change root's password         [y/N]? y

root's password                :

              confirm password :

ec

*** Index

***

 

Type                           [LUCENE/?]:

 

The index must be rebuilt before starting Gerrit:

  java -jar gerrit.war reindex -d site_path

 

*** User Authentication

***

 

Authentication method          [LDAP/?]:

LDAP server                    ldap://192.168.100.101:389:

LDAP username                  cn=domainldap.OU=IT.OU=archermind.DC=archermind.DC=com:

Change cn=domainldap.OU=IT.OU=archermind.DC=archermind.DC=com's password [y/N]?

Account BaseDN                 DC=archermind.DC=com:

Group BaseDN                   DC=archermind.DC=com:

 

*** Review Labels

***

 

Install Verified label         [y/N]?

 

*** Email Delivery

***

 

SMTP server hostname           [localhost]:

SMTP server port               [(default)]:

SMTP encryption                [NONE/?]:

SMTP username                  :

 

*** Container Process

***

 

Run as                         [root]:

Java runtime                   [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-28.b13.el6_6.x86_64/jre]:

Upgrade /data1/gerrit/review_site/bin/gerrit.war [Y/n]?

Copying gerrit-2.11.war to /data1/gerrit/review_site/bin/gerrit.war

 

*** SSH Daemon

***

 

Listen on address              [*]:

Listen on port                 [29418]:

 

*** 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 [y/N]?

Install plugin reviewnotes version v2.11 [y/N]?

Install plugin singleusergroup version v2.11 [y/N]?

Install plugin replication version v2.11 [y/N]?

Install plugin commit-message-length-validator version v2.11 [y/N]?

Initializing plugins.

No plugins found with init steps.

 

 

Initialized /data1/gerrit/review_site

 

(2).

修改 /data1/gerrit/review_site/etc/gerrit.config的內容.如下所示:

[gerrit]

        basePath = git

        canonicalWebUrl = http://10.20.70.135:8080/

[database]

        type = mysql

        hostname = localhost

        database = gerritdb

        username = root

[index]

        type = LUCENE

[auth]

        type = LDAP

[ldap]

        server = ldap://192.168.100.101:389

        username = cn=domainldap.OU=IT.OU=archermind.DC=archermind.DC=com

        accountBase = DC=archermind.DC=com

        groupBase = DC=archermind.DC=com

        accountPattern = (sAMAccountName=${username})

        accountFullName = displayName

[sendemail]

        smtpServer = smtp.archermind.com

        smtpServerPort = 25

        smtpUser = mailman

[container]

        user = root

        javaHome = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-28.b13.el6_6.x86_64/jre

[sshd]

        listenAddress = *:29418

[httpd]

        listenUrl = http://*:8080/

[cache]

        directory = cache

 

3.重啓gerrit

/work/gerrit/review_site/bin/gerrit.sh restart

     

三. 網頁訪問gerrit

http://192.168.100.198:8080

 

四. 登錄後頁面

wKiom1bnbQmydKieAAC6VWWlBi8341.png


 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章