2015年7月19日日曜日

CentOS7 on Amazon EC2(3) glassfish on amazon ec2

Amazon EC2上のCentOS7にglassfishをインストールする。

1、JDK8ダウンロード、インストール

yumのリポジトリにはjavac入りのJDKはない模様
sudo yum provides javac

以下サイトからOracle JDKをインストールする
http://www.oracle.com/technetwork/java/javase/downloads/index.html

(1)コマンドラインからダウンロード

参考:Think deeply, Do less, More effective

$ sudo yum install wget -y
$ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.rpm"

(2)インストール

$ sudo rpm -ivh jdk-7u71-linux-x64.rpm 

2、glassfish ダウンロード&インストール

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

(1)ダウンロード

サイト:https://glassfish.java.net/download.html

Full Platformをダウンロードする。

コマンド
$ wget http://download.java.net/glassfish/4.1/release/glassfish-4.1.zip

(2)glassfish起動ユーザー追加

$ sudo useradd glassfish

(3)解凍&インストール

$ sudo yum install unzip -y
$ sudo su - glassfish
glassfish$ unzip glassfish-4.1.zip
glassfish$ mv glassfish4 /opt/.

3、起動テスト&セキュア設定

$ cd /opt/glassfish4/bin
$ ./asadmin change-admin-password --user admin
Enter the admin password> 
Enter the new admin password> 
Enter the new admin password again> 
Command change-admin-password executed successfully.
$ ./asadmin start-domain
$ ./asadmin enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin"> 
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.
$ ./asadmin stop-domain
Waiting for the domain to stop ..
Command stop-domain executed successfully.
$ ./asadmin start-domain
Waiting for domain1 to start ...............................................................
Successfully started the domain : domain1
domain  Location: /home/pi/glassfish4/glassfish/domains/domain1
Log File: /home/pi/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

4、サービス作成

$ sudo vi /lib/systemd/system/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

5、サービス有効化

$ sudo systemctl enable glassfish.service
ln -s '/usr/lib/systemd/system/glassfish.service' '/etc/systemd/system/multi-user.target.wants/glassfish.service'

6、停止・起動

$ sudo systemctl stop glassfish.service
$ sudo systemctl start glassfish.service

7、ログを確認

less /var/log/messages

0 件のコメント:

コメントを投稿