Jas*_*ley 11 windows-server-2008 tomcat ldap gerrit
我正在尝试找到在 Tomcat 下使用 LDAP 支持安装 Gerrit 的良好说明。我最好将它安装在 Windows 2008 Server 上。但是,如果不可能,我可以选择 Linux。
Gerrit 说明仅涵盖在码头下安装:
http://gerrit.googlecode.com/svn/documentation/2.1.3/install-j2ee.html#installation
如果我想在不同的环境下设置它,没有多少工作要做。
我确实找到了一些有用的链接,但没有将设置整合在一起。
http://codeslife.com/2011/06/08/install-gerrit-locally-under-windows/ http://gerrit.googlecode.com/svn/documentation/2.1.7/config-gerrit.html#_a_id_ldap_a_section_ldap http ://code.google.com/p/gerrit/issues/detail?id=292
我总是可以通过反复试验来设置它,但如果有人已经解决了这些问题,我更愿意节省时间。
Jas*_*ley 21
我决定继续回答这个问题,因为 Gerrit 社区需要它。目前,没有很多教程涵盖 Gerrit 的高级设置。我希望这将帮助其他人探索 XP/敏捷实践并启动和运行 Gerrit。一旦您克服了所有微妙的设置挑战和细节,它就是一个很好的工具。
这个安装教程相当独特,因为它服务于特定的环境:
在开始之前,请确保您的系统上安装了 git。从http://code.google.com/p/msysgit/downloads/list下载适用于 Windows 的最新 msysgit 命令行工具
确保您获得了“Windows 官方 Git 的完整安装程序”。
如果你打算在 msysgit 中使用 GitWeb 版本,你会注意到一些关于 CGI.pm 的问题。我想提一下解决此问题的修复程序。
从 1.7.8 开始,msysgit 发行版中包含的 perl 已损坏,http: //groups.google.com/group/msysgit/browse_thread/thread/ba3501f1f0ed95af 。unicore 文件夹与 utf8_heavy.pl 和 CGI.pm 一起丢失。您可以通过检查 perl 模块来验证:
perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e "" 您可能会遇到以下异常:
$ perl -mCGI -mEncode -mFcntl -mFile::Find -mFile::Basename -e "" 在@INC 中找不到CGI.pm (@INC 包含:/usr/lib/perl5/5.8.8/msys / usr/lib/p erl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys /usr/lib/perl5/site_perl/5.8.8 /u sr/lib/perl5/site_perl .)。BEGIN 失败——编译中止。
如果您缺少 CGI.pm,则必须将该模块部署到 msys 环境:您必须从 5.8.8 发行版中检索它们:
http://strawberryperl.com/releases.html
文件:草莓-perl-5.8.8.3.zip
内容:bin/lib/site/
将 lib 的内容复制到 msysgit/lib/perl5/5.8.8 并覆盖现有文件。
如果使用命令行 git,请将全局配置设置添加到 git:
git config --global user.name "Your Name"
git config --global user.email you@corporation.com
git config --global core.autocrlf false
Run Code Online (Sandbox Code Playgroud)
确保此处使用的凭据与 gerrit 中的凭据匹配。否则,gerrit 将拒绝您的请求。
Gerrit的安装和配置说明如下:
java -jar gerrit-2.4-rc0.war
init -d config
执行:
C:\your_path\gerrit>java -jar gerrit-2.4-rc0.war init -d config
*** Gerrit Code Review 2.4-rc0
***
Create 'C:\your_path\gitserver\gerrit\config' [Y/n]? Y
*** Git Repositories
***
Location of Git repositories [git]: C:\your_path\gitserver\repository\ha
*** SQL Database
***
Database server type [H2/?]: postgresql
Server hostname [localhost]: database.corp.local
Server port [(POSTGRESQL default)]:
Database name [reviewdb]:
Database username [Administrator]: gerrit2
gerrit2's password :
confirm password :
*** User Authentication
***
Authentication method [OPENID/?]: LDAP
LDAP server [ldap://localhost]: ldaps://ldap.corp.local:
636
LDAP username : CN=Administrator,CN=Users,DC=corp,DC=local
CN=Administrator,CN=Users,DC=corp,DC=local's password :
confirm password :
Account BaseDN [DC=corp,DC=local:636]: CN=Users,DC=corp,DC=l
ocal
Group BaseDN [CN=Users,DC=corp,DC=local]:
*** Email Delivery
***
SMTP server hostname [localhost]: smtp.corporation.com
SMTP server port [(default)]: 465
SMTP encryption [NONE/?]: SSL
SMTP username [Administrator]: build@corporation.com
build@corporation.com's password :
confirm password :
*** Container Process
***
Run as [Administrator]:
Java runtime [C:\Program Files\Java\jre6]:
Copy gerrit.war to C:\your_path\gitserver\gerrit\config\bin\gerrit.war [Y/n]?
Copying gerrit.war to C:\your_path\gitserver\gerrit\config\bin\gerrit.war
*** SSH Daemon
***
Listen on address [*]:
Listen on port [29418]:
Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]? 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]:
Initialized C:\your_path\gitserver\gerrit\config
Automatic startup not supported on Win32.
Run Code Online (Sandbox Code Playgroud)
gerrit.config 更新:
[gitweb]
cgi = C:\\path to msysgit\\Git\\share\\gitweb\\gitweb.cgi
url = https://gitweb.corporation.com
type = custom
project = ?p=${project};a=summary
revision = ?p=${project};a=commit;h=${commit}
branch = ?p=${project};a=shortlog;h=${branch}
filehistory = ?p=${project};a=history;hb=${branch};f=${file}
Run Code Online (Sandbox Code Playgroud)
gerrit.config 更新:
[download]
scheme = http
Run Code Online (Sandbox Code Playgroud)
gerrit.config 更新:
[ldap]
sslVerify = true
server = ldaps://ldap.corp.local:636
username = CN=Administrator,CN=Users,DC=corp,DC=local
accountBase = CN=Users,DC=corp,DC=local
accountPattern = (&(objectClass=person)(sAMAccountName=${username}))
accountFullName = displayName
accountEmailAddress = mail
accountSshUserName = sAMAccountName
groupBase = CN=Users,DC=corp,DC=local
groupMemberPattern = (sAMAccountName=${username})
groupName = cn
Run Code Online (Sandbox Code Playgroud)
服务器.xml:
<Server port="8006" shutdown="SHUTDOWN">
<Service name="Catalina">
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true">
<Context path="" docBase="C:\your_path\gitserver\gerrit\gerrit-2.4" debug="0" reloadable="false">
<Resource
name="jdbc/ReviewDb"
type="javax.sql.DataSource"
username="gerrit2"
driverClassName="org.postgresql.Driver"
password="secret"
url="dbc:postgresql://yourPsqlServer:5432/reviewdb"
/>
</Context>
</Host>
</Engine>
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"/>
<Connector port="8011" protocol="AJP/1.3" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
disableUploadTimeout="true" enableLookups="false"
acceptCount="100" URIEncoding="UTF-8" />
</Service>
</Server>
Run Code Online (Sandbox Code Playgroud)
除非您打算使用 Apache HTTP Server 进行代理,否则您不需要 AJP 连接器。我用它来卸载 SSL 加密和管理证书。如果不需要,只需将其删除。如果您打算独立运行,请务必将 HTTP 连接器端口更改为 80。
上面的配置是用于 postgres 的。如果您使用的是 MySQL,则必须将资源替换为 MySQL 的以下内容:
服务器.xml:
<Resource
name="jdbc/ReviewDb"
type="javax.sql.DataSource"
username="gerrit2"
driverClassName="org.gjt.mm.mysql.Driver"
password="secret"
url="jdbc:mysql://yourMsqlServer/reviewdb?autoReconnect=true"
/>
Run Code Online (Sandbox Code Playgroud)
此时,您现在已准备好将 Gerrit 配置为服务并使审查系统联机。
jvm 选项是为 nt 服务单独设置的。您必须在安装 nt 服务之前修改您的 service.bat 文件。该文件与其他 startup.bat 和关闭脚本位于 tomcat/bin 目录中。向下滚动到以下部分:
"%EXECUTABLE%" //US//%SERVICE_NAME% \++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" \--JvmMs 128 \--JvmMx 256
Run Code Online (Sandbox Code Playgroud)
修改此行以匹配以下内容:
"%EXECUTABLE%" //US//%SERVICE_NAME% \++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" \++JvmOptions="-XX:MaxPermSize=256m" \++JvmOptions="-XX:+CMSClassUnloadingEnabled" \++JvmOptions="-XX:+CMSPermGenSweepingEnabled" \--JvmMs 512 \--JvmMx 1024
Run Code Online (Sandbox Code Playgroud)
对于 gerrit,初始内存 jvmMs 绝对应该设置为 512Mb,而扩展内存 JvmMx 应该设置为 1024Mb。
现在您已准备好在 Windows 下将 gerrit 作为服务部署。只需执行以下操作:
C:\your_path\gitserver\gerrit\tomcat\bin>service install gerrit
Installing the service 'gerrit' ...
Using CATALINA_HOME: "C:\your_path\gitserver\gerrit\tomcat"
Using CATALINA_BASE: "C:\your_path\gitserver\gerrit\tomcat"
Using JAVA_HOME: "C:\Program Files\Java\jdk1.6.0_31"
Using JVM: "C:\Program Files\Java\jdk1.6.0_31\jre\bin\server\jvm.dl
l"
The service 'gerrit' has been installed.
C:\your_path\gitserver\gerrit\tomcat\bin>
Run Code Online (Sandbox Code Playgroud)
转到您的服务器管理器并打开服务节点。打开 Gerrit 的属性并确保将启动类型设置为自动:
应用和关闭对话框。
好的...我们完成了吗?不幸的是,没有,只需再走几步。挂在那里。
现在您已准备好启动服务。只需突出显示 Gerrit 服务,然后单击左侧的 Start 选项。
查看 tomcat/log 目录下的日志。确保没有未解决的错误。如果您有问题,可以在此处或在 gerrit 邮件列表上提问:http ://groups.google.com/group/repo-discuss
您现在应该可以转到浏览器并输入服务器的 url 以查看 Gerrit:http ://review.corporation.com: 8080
系统将提示您输入 ssh 公钥。仅当您打算通过 ssh 而不是 HTTP 使用 Git/Gerrit 时才需要这样做。我继续进行设置,因为这是一个不错的选择。
配置 SSH
生成用于访问的 ssh 密钥:
管理员@SERVER~/test $ ssh-keygen -t rsa
通过 Web 界面使用您选择的电子邮件地址在 Gerrit 中注册一个新帐户。第一个登录并注册帐户的用户将被自动置于完全特权的管理员组中,从而允许通过 Web 和 SSH 进行服务器管理。后续用户将自动注册为非特权用户。
以您的用户身份登录后,您会找到一个小向导来帮助您入门。该向导可帮助您填写:
服务器将要求您提供 RSA 公钥。这是我们上面生成的密钥,现在是时候确保 Gerrit 知道我们的新密钥并可以通过它识别我们。
用户@主机:~$ cat .ssh/id_rsa.pub
仅为注册用户配置 HTTP 访问,除非您的项目对公众开放:
生成 HTTP 密码
尽管已经配置了自己的登录名,但您仍然需要通过 http/https 为 gerrit 生成一个密码到服务器。转到您的设置-> HTTP 密码配置,然后单击“生成密码”。将此密码用于所有通过 http(s) 的 git 操作。
现在我们可以通过 HTTP 测试 Gerrit。您应该能够克隆您在 Gerrit 配置中引用的存储库中存在的任何项目。
使用克隆操作进行测试
Administrator@SERVER ~/test
$ git clone https://review.corporation.com/sandbox
Run Code Online (Sandbox Code Playgroud)
测试您的 ssh 帐户
Administrator@SERVER~/test
$ ssh jhuntley@localhost -p 29418
**** Welcome to Gerrit Code Review ****
Hi Jason Huntley, you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://jhuntley@review.corporation.com:29418/REPOSITORY_NAME.g
it
Connection to localhost closed.
Run Code Online (Sandbox Code Playgroud)
通过 SSH 从 Gerrit 克隆一个项目:
Administrator@SERVER~/test
$ git clone ssh://jhuntley@127.0.0.1:29418/sandbox
Cloning into 'sandbox'...
remote: Counting objects: 183, done
remote: Finding sources: 100% (183/183)
remote: Total 183 (delta 0), reused 0 (delta 0)Receiving objects: 50% (92/183)
Receiving objects: 52% (96/183)
Receiving objects: 100% (183/183), 23.76 KiB, done.
Run Code Online (Sandbox Code Playgroud)
如果你现在还没有放弃,你可以放松一下,你应该会发现自己有一个由 Windows 2008 服务器托管的工作 Gerrit 代码审查系统 :) 它不像设置那么常见,正如你所知,保证所有额外的脚步。但是,我们中的一些人资源有限,只能使用所提供的资源。我希望本教程可以帮助那些寻求在类似环境中运行 Gerrit 的人。您现在应该准备好开始使用 Gerrit 了!享受!
有关使用 Gerrit 的更多信息,请参阅 Gerrit 项目的用户指南:
http://gerrit-documentation.googlecode.com/svn/Documentation/2.3/index.html
感谢Shawn Pierce在 IRC 上的帮助!
教程已转换为 Gerrit 项目的文档。对于那些有兴趣并需要一个很好的参考。请在此处查看补丁请求:
https://gerrit-review.googlesource.com/#/c/37072
归档时间: |
|
查看次数: |
15934 次 |
最近记录: |