deploy-glassfish-on-oracle-linux

2026-01-14 Linux Oracle Linux

mkdir -p /usr/local/lib/jvm
wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.17%2B10/OpenJDK17U-jdk_x64_linux_hotspot_17.0.17_10.tar.gz
wget https://ftp.jaist.ac.jp/pub/eclipse/ee4j/glassfish/glassfish-7.1.0.zip
tar -zxf OpenJDK17U-jdk_x64_linux_hotspot_17.0.17_10.tar.gz -C /usr/local/lib/jvm
ln -s /usr/local/lib/jvm/jdk-17.0.17+10 /usr/local/lib/jvm/jdk-17-lasted
unzip -q glassfish-7.1.0.zip -d /opt/

sudo useradd -s /bin/bash -d /opt/glassfish7 --system glassfish

chown -R glassfish: /opt/glassfish7
export JAVA_HOME="/usr/local/lib/jvm/jdk-17-lasted"
export PATH=${PATH}:${JAVA_HOME}/bin
# 啟動網域
/opt/glassfish7/bin/asadmin start-domain
# 設定管理員密碼
/opt/glassfish7/bin/asadmin change-admin-password
# 啟用遠端管理介面 (GUI)
/opt/glassfish7/bin/asadmin enable-secure-admin
/opt/glassfish7/bin/asadmin restart-domain
[glassfish@test-ap-150 ~]$ export JAVA_HOME="/usr/local/lib/jvm/jdk-17-lasted"
[glassfish@test-ap-150 ~]$ java -version
-bash: java: command not found
[glassfish@test-ap-150 ~]$ export PATH=${PATH}:${JAVA_HOME}/bin
[glassfish@test-ap-150 ~]$ java -version
openjdk version "17.0.17" 2025-10-21
OpenJDK Runtime Environment Temurin-17.0.17+10 (build 17.0.17+10)
OpenJDK 64-Bit Server VM Temurin-17.0.17+10 (build 17.0.17+10, mixed mode, sharing)
[glassfish@test-ap-150 ~]$ /opt/glassfish7/bin/asadmin start-domain
Waiting until start of domain domain1 completes................ ... finished after 15399 ms.

Successfully started the domain domain1.
  Location: /opt/glassfish7/glassfish/domains/domain1
  Log File: /opt/glassfish7/glassfish/domains/domain1/logs/server.log
  The pid file /opt/glassfish7/glassfish/domains/domain1/config/pid contains pid 1860.
  Process with pid 1860 is alive
  Admin Endpoints:
    http://localhost:4848 is reachable.

Command start-domain executed successfully.
[glassfish@test-ap-150 ~]$ /opt/glassfish7/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.
[glassfish@test-ap-150 ~]$ /opt/glassfish7/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.
[glassfish@test-ap-150 ~]$ /opt/glassfish7/bin/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.
[glassfish@test-ap-150 ~]$ /opt/glassfish7/bin/asadmin restart-domain
Stopping local domain on admin endpoint localhost:4848
Waiting for process with pid 1860 to stop. ... finished after 868 ms.
Waiting for the new PID................... ... finished after 18980 ms.
Waiting until start of domain domain1 completes. ... finished after 19 ms.

Successfully started the domain domain1.
  Location: /opt/glassfish7/glassfish/domains/domain1
  The pid file /opt/glassfish7/glassfish/domains/domain1/config/pid contains pid 2255.
  Process with pid 2255 is alive
  Admin Endpoints:
    http://localhost:4848 is reachable.

Command restart-domain executed successfully.
[glassfish@test-ap-150 ~]$ 
  • /etc/systemd/system/glassfish.service
[Unit]
Description=GlassFish Server v7
After=syslog.target network.target

[Service]
User=glassfish
Group=glassfish
Type=forking
Environment=JAVA_HOME=/usr/local/lib/jvm/jdk-17-lasted
ExecStart=/opt/glassfish7/bin/asadmin start-domain
ExecStop=/opt/glassfish7/bin/asadmin stop-domain
ExecReload=/opt/glassfish7/bin/asadmin restart-domain
Restart=on-failure

[Install]
WantedBy=multi-user.target