気ままなつぶやき

おべんきょしたこととか

【maven】帰ってきたnexusのインストール 

すごく昔に、nexusを構築したんだけど、最近また構築しなきゃいけなくなったー


ReleaseNote

Sonatype Nexus Release Notes Index : Sonatype Support

2.11.1にしよう。

何気に、最終更新日が2014/12/19だし。
Sonatype Nexus 2.11.1 Release Notes : Sonatype Support

ダウンロード

Pro版もあるけど、OSS版を入れます

Download and Install Nexus OSS | TheNEXUS
ブラウザ上でダウンロードして、scpした。

今回は/data/nexus配下にnexusを入れる

$ cd /data
$ mkdir nexus

ローカルに落としてきたnexusを移動して展開

$mv nexus-2.11.1-01-bundle.tar.gz /usr/local/src/
$cd /usr/local/src/
$tar -xzvf nexus-2.11.1-01-bundle.tar.gz -C /data/nexus/
#確認
$cd /data/nexus/
$ls
nexus-2.11.1-01  sonatype-work

2つディレクトリができた
nexusディレクトリは,nexus自体のアプリケーション,sonatype-workディレクトリは,リポジトリに関連する情報が入っている.
nexusのバージョンをあげる場合はnexusディレクトリのみ更新すれば問題なく動作する(たぶん).

バージョンまた変わったときに便利なように、シンボリックリンク貼っておく

$ln -s nexus-2.11.1-01 nexus
$ll | grep nexus
lrwxrwxrwx 1 root root   15  16 17:51 2015 nexus -> nexus-2.11.1-01
drwxr-xr-x 8 root root 4096 1217 10:23 2014 nexus-2.11.1-01

nexus用のユーザ作成

えいっ

$groupadd cy_nexus
$ useradd cy_nexus -g cy_nexus
#確認
$id cy_nexus
uid=10001(cy_nexus) gid=10001(cy_nexus) 所属グループ=10001(cy_nexus)

やあっ

$ll /data | grep nexus
drwxr-xr-x 4 root root  4096  16 17:51 2015 nexus
$chown -R cy_nexus. nexus
$ll /data | grep nexus
drwxr-xr-x 4 cy_nexus cy_nexus  4096  16 17:51 2015 nexus

起動

さてはて。

Sonatype Nexus 2.0 through 2.8.1 Release Notes : Sonatype Support
なんか2.7のところで、2.0からOS毎のスクリプトはdeprecatedしてたけど削除したよって書いてる
(あるけど)

Legacy Startup Scripts Removed
The old startup scripts (located under $NEXUS_HOME/bin/jsw/$ARCH in the installation directory) have finally been removed. These have been deprecated since Nexus 2.0. Users should use the new startup scripts introduced in Nexus 2.0, located in $NEXUS_HOME/bin (NEXUS-5781). The 'clickable' Windows batch files (*-nexus.bat) have remained, but the only use case for these are to be 'clicked' to perform a specific named action.


nexusさんオススメのやり方でやろう。

ちょっと実行してみる

$/data/nexus/nexus/bin/nexus
Usage: /data/nexus/nexus/bin/nexus { console | start | stop | restart | status | dump }

ほほ。

起動スクリプト

以前作ったやつの引用(冒頭)

$vi /etc/init.d/nexus 

中身はこんな感じ

#!/bin/sh
# description: nexus start/stop Script

# 実行ユーザの指定
export RUN_AS_USER=cy_nexus

# user check
if [ `/usr/bin/whoami` != "root" ];
then
    echo "This script is only for root."
    exit 1
fi

NEXUS_HOME=/data/nexus/nexus
#nexusの起動
${NEXUS_HOME}/bin/nexus $@
exit 0

実行権限付与

$ chmod +x  /etc/init.d/nexus 
$ ll /etc/init.d/nexus 
-rwxr-xr-x 1 root root 295  16 19:09 2015 /etc/init.d/nexus

よし。実行

$/etc/init.d/nexus start
Starting Nexus OSS...
Started Nexus OSS.

http://xxx.xxx.xxx.xxx:8081/nexus/#welcome

立ち上がった
f:id:pnsk:20150106183657p:plain

admin/admin123
でログインできる

ちなみに

jdk入ってるか確認

jdk入れ忘れてると、起動時に落ちる

すでに起動してるとき

nexusさんが怒ってくれる

/etc/init.d/nexus start
Starting Nexus OSS...
Nexus OSS is already running.