タイガー!タイガー!じれったいぞー!(SE編)

AS400, Java, JavaEE, JSF等の開発、習慣など。日々の気づきをまとめたブログ(備忘録)

【Glassfish】CentOS7.0へGlasssfish4.1インストール

CentOS7.0のLinux ServerへGlassfish4.1のインストールにトライします。
今回もVagrant上での作業になります。

(1) JDK8ダウンロード

Java SE Development Kit 8 - Downloads

License同意の必要があるので、同意したうえで、サイトよりダウンロードしました。

Windowsから取得したので、ファイルをwinSCPで「/tmp」へ格納しました。

(2) JDK8インストール

rpmコマンドでインストールします。

# rpm -Uvh /tmp/jdk-8u31-linux-x64.rpm
準備しています...              ################################# [100%]
更新中 / インストール中...
   1:jdk1.8.0_31-2000:1.8.0_31-fcs    ################################# [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        jfxrt.jar...

# java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

# javac -version
javac 1.8.0_31

(3) glassfish4.1ダウンロード・配備

GlassFish Server Open Source Edition 4.1 Download

上記リンクより、Full Profile版のほうをwgetでダウンロードしました。

# wget http://dlc.sun.com.edgesuite.net/glassfish/4.1/release/glassfish-4.1.zip

# unzip glassfish-4.1.zip

# ls
glassfish-4.1.zip  glassfish4

(4) glassfish4.1設定

起動確認

# /opt/glassfish4/bin/asadmin start-domain
Waiting for domain1 to start .............
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

管理者パスワード設定

# /opt/glassfish4/bin/asadmin change-admin-password
Enter admin user name [default: admin]>
Enter the admin password>
Enter the new admin password> ********
Enter the new admin password again> ********
Command change-admin-password executed successfully.

ログインストアにパスワード登録

# /opt/glassfish4/bin/asadmin login
Enter admin user name [Enter to accept default]> admin
Enter admin password> ********
Login information relevant to admin user name [admin] for host [localhost] and admin port [4848] stored at [/root/.gfclient/pass] successfully.
Make sure that this file remains protected. Information stored in this file will be used by administration commands to manage associated domain.
Command login executed successfully.

SSL有効化

# /opt/glassfish4/bin/asadmin enable-secure-admin
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

管理コンソール、公開Webサイト接続確認

Glassfish再起動のうえ、管理コンソール画面と公開Webサイトへアクセスします。

Glassfish再起動
# /opt/glassfish4/bin/asadmin stop-domain
Waiting for the domain to stop .
Command stop-domain executed successfully.

# /opt/glassfish4/bin/asadmin start-domain
Waiting for domain1 to start ........
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
起動確認

f:id:no14141:20150212124146j:plain

f:id:no14141:20150212124156j:plain

起動ユーザーの変更(root→glassfish

glassfishを停止したうえで操作します。

# /opt/glassfish4/bin/asadmin stop-domain
Waiting for the domain to stop .
Command stop-domain executed successfully.

# adduser glassfish

# chown -R glassfish:glassfish /opt/glassfish4

# su - glassfish
$ /opt/glassfish4/bin/asadmin start-domain
Waiting for domain1 to start ........
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

glassfish4のサービス化

風は北向き - Centos7 で glassfish のインストールのサイトを参考にさせていただきました。恐縮です!

# vim /lib/systemd/system/glassfish.service
glassfish.service
[Unit]
Description=GlassFish Server
After=network.target remote-fs.target

[Service]
Type=forking
PIDFile=/opt/glassfish4/glassfish/domains/domain1/config/pid
ExecStart=/opt/glassfish4/bin/asadmin start-domain
ExecReload=/opt/glassfish4/bin/asadmin restart-domain
ExecStop=/opt/glassfish4/bin/asadmin stop-domain
TimeoutStartSec=300
TimeoutStopSec=30
User=glassfish

[Install]
WantedBy=multi-user.target
サービス登録
# systemctl enable glassfish.service
ln -s '/usr/lib/systemd/system/glassfish.service' '/etc/systemd/system/multi-user.target.wants/glassfish.service'
サービス開始
# systemctl start glassfish.service

# top

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
17493 glassfi+  20   0 2613028 161312  20760 S  0.3 32.1   0:11.35 java

※topコマンドにて、javaのUSERが、glassfishになっていることを確認できました。

今日は、ここまでにしておきます。