Artifactory:別のTomcatで動作させる
※artifactoryについての投稿は/tag/artifactoryにあるので参照されたい。
他にTomcatを動作させているので、Artifactory付属のTomcatを動作させると、二つもTomcatが動くことになる。
これを一つのTomcatで済ませることはできないものか?
また、Artifactoryの使用するデータ領域やデータベースはどのように決められているのだろうか?
問題
Artifactoryを起動しようとすると、以下のエラーが出て起動してくれない。
ERROR: Artifactory Tomcat server did not start in 60 seconds. Please check the logs
OSはCentOS-6.9である。ログを見てみると以下だ。要するにメモリが足りないという。
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 536870912 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /var/opt/jfrog/artifactory/hs_err_pid7303.log
たしかに足りないかもしれない。これとは他にtomcatを動作させており、メモリは2Gしかない。
既存のtomcatに載せられないか?
そもそも一つTomcatを起動しているのに、Artifactory専用に別のtomcatを起動するのは、いかにも効率が悪い。既存のtomcatに載せられないものか?
これに関してDeploy Artifactory in existing Tomcatという書き込みがある。2016/11の時点でtomcat8が必要だという。
ともあれ、各バージョンを確認する。
artifactoryのバージョン
rpmでインストールしたので、以下で確認できる。
rpm -qa | grep artifactory
jfrog-artifactory-oss-4.14.0-40293.noarch
今現在はArtifactory PROというのが出ているようだが、これは評価版のようだ。
CentOS-6.9で最新のRPMを調べてみると、
[root@www8321uj artifactory]# yum list | grep artifactory
jfrog-artifactory-oss.noarch 4.14.0-40293 installed
となっており、最新版のようである。別にこれで不満は無い。
このArtifactoryの使うtomcatについては、tomcat/RELEASE-NOTESにバージョンがある。
Apache Tomcat Version 8.0.32
Release Notes
既存のtomcatのバージョン
別立てで使用しているtomcatについては、トップのRELEASE-NOTESにバージョンがある。
Apache Tomcat Version 8.0.5
Release Notes
Artifactory 4.14のディレクトリ構造
ディレクトリ構造は以下のようになっている。ただし、tomcat以下はごく普通の構造なので省略。
[root@www8321uj artifactory]# ls -lR
.:
total 16
drwxrwxr-x 2 root root 4096 Oct 30 2016 bin
drwxr-xr-x 6 root root 4096 Oct 30 2016 misc
drwxrwxr-x 6 artifactory artifactory 4096 Oct 30 2016 tomcat
drwxr-xr-x 2 root root 4096 Oct 30 2016 webapps
./bin:
total 160
-rwxrwxr-x 1 root root 103424 Oct 20 2016 artifactory-service.exe
-rwxrwxr-x 1 root root 1956 Oct 20 2016 artifactory.bat
-rwxrwxr-x 1 root root 632 Oct 20 2016 artifactory.default
-rwxrwxr-x 1 root root 5525 Oct 20 2016 artifactory.sh
-rwxrwxr-x 1 root root 242 Oct 20 2016 artifactoryctl
-rwxrwxr-x 1 root root 7634 Oct 20 2016 configure.mysql.sh
-rwxrwxr-x 1 root root 4411 Oct 20 2016 installService.bat
-rwxrwxr-x 1 root root 7898 Oct 20 2016 installService.sh
-rwxrwxr-x 1 root root 368 Oct 20 2016 uninstallService.bat
-rwxrwxr-x 1 root root 4150 Oct 20 2016 uninstallService.sh
./misc:
total 16
drwxr-xr-x 3 root root 4096 Oct 30 2016 db
drwxr-xr-x 2 root root 4096 Oct 30 2016 ha
drwxr-xr-x 2 root root 4096 Oct 30 2016 service
drwxr-xr-x 2 root root 4096 Oct 30 2016 tomcat
./misc/db:
total 20
drwxr-xr-x 2 root root 4096 Oct 30 2016 createdb
-rw-r--r-- 1 root root 1755 Oct 20 2016 mssql.properties
-rw-r--r-- 1 root root 1676 Oct 20 2016 mysql.properties
-rw-r--r-- 1 root root 1635 Oct 20 2016 oracle.properties
-rw-r--r-- 1 root root 1762 Oct 20 2016 postgresql.properties
./misc/db/createdb:
total 16
-rw-r--r-- 1 root root 904 Oct 20 2016 createdb_mssql.sql
-rw-r--r-- 1 root root 1132 Oct 20 2016 createdb_mssqlBlob.sql
-rw-r--r-- 1 root root 697 Oct 20 2016 createdb_mssqlRecreateBlob.sql
-rw-r--r-- 1 root root 152 Oct 20 2016 createdb_mysql.sql
./misc/ha:
total 4
-rw-r--r-- 1 root root 704 Oct 20 2016 ha-node.properties.template
./misc/service:
total 16
-rw-r--r-- 1 root root 8783 Oct 20 2016 artifactory
-rw-r--r-- 1 root root 604 Oct 20 2016 setenv.sh
./misc/tomcat:
total 188
-rw-r--r-- 1 root root 118 Oct 20 2016 NGNIX.txt
-rw-r--r-- 1 root root 230 Oct 20 2016 artifactory.httpd.conf
-rw-r--r-- 1 root root 239 Oct 20 2016 artifactory.xml
-rw-r--r-- 1 root root 103 Oct 20 2016 index.html
-rw-r--r-- 1 root root 3443 Oct 20 2016 logging.properties
-rw-r--r-- 1 root root 367 Oct 30 2016 server.xml
-rw-r--r-- 1 root root 367 Oct 20 2016 server.xml~
-rw-r--r-- 1 root root 162939 Oct 20 2016 web.xml
./tomcat:
(省略)
./webapps:
total 36928
-rwxr-xr-x 1 root root 37812279 Oct 20 2016 artifactory.war
どう考えてもartifactory.warを既存のtomcatに入れれば良いだけの話に思える。
ArtifactoryはどのようにROOTアプリになっているのか?
artifactory組み込みのTomcatでは、artifactory.warというファイルをデプロイしているようだが、このままではパスが/artifactoryになっているはずなのだが、ROOTとしてアクセスできる。
artifactory.warという名称のままROOTとするには、通常はserver.xmlに記述するようだが、それが無い。
しかし、webapp/ROOTの中身を見てみると、index.htmlがただ一つあり、その中身は以下だ。
<html>
<head>
<meta http-equiv="refresh" content="0;URL=/artifactory">
</head>
<body>
</body>
</html>
つまり、/にアクセスされたら/artifactoryにリダイレクトしているだけだった。
※ただし、リポジトリとしては、あくまでも/artifactoryになっている。管理画面が/になっているだけだ。
実際に既存のtomcatに配備してみる
結局は、単純にartifactory.warを既存のtomcatのwebappsにコピーすれば良いだけ。。。と思ったら、何かおかしい。
データ領域が、もともとあった/var/opt/jfrog/artifactory/dataではなく、なぜか/root/.artifactory/dataになっている。
これは、Admin>Advanced>Storageで確認できる。
つまり、勝手に新たなデータ領域を使うようになってしまい、以前のものが無視されている。これはどうしたら良いのだろう?
ARTIFACTORY_HOMEを指定する
https://www.jfrog.com/confluence/pages/viewpage.action?pageId=10683126に記述がある。
"Drop the War" (Dedicated or Shared Instance)
Artifactory can be installed under Tomcat by simply dropping the artifactory.war file into Tomcat's webapps folder.
It is recommended you also set the $ARTIFACTORY_HOME environment variable (otherwise $HOME/.artifactory will be used).
The $ARTIFACTORY_HOME directory will be created automatically the first time you run Artifactory and populated with default configuration files.
ここで言っている通りのことが起こった。ARTIFACTORY_HOMEを指定しないと、$HOME/.artifactoryがホームになってしまうと。
そこで、tomcatのstartup.shの冒頭に以下を追加する。いかにも無理やりだが。。。
ARTIFACTORY_HOME=/var/opt/jfrog/artifactory
export ARTIFACTORY_HOME
これでうまく行った。もちろん、この際には、/ではなく、/artifactoryというパスになってしまうのだが、仕方がない。既にROOTは使っているので。
まとめ
Artifactoryを組み込みのtomcatではなく、既存のTomcatで動作させるのは簡単だ。単純にartifactory.warを放り込めばいい。
その際には、ARTIFACTORY_HOMEを設定しておかないと、組み込みTomcatの場合とは異なる場所が使われてしまう(データベースのみならず、ログ等も)。
しかし、そもそものインストールの時点で組み込みのDerbyデータベースを使うのではなく、MySQLにしておいた方がよいだろう。もちろん、この場合にもARTIFACTORY_HOMEを指定する必要はある。
ディスカッション
コメント一覧
まだ、コメントがありません