Professional Documents
Culture Documents
1 on CentOS or RHEL
This post will cover installing GlassFish 3.1 on CentOS or RHEL.
We'll also see how to run GlassFish as a service, how to access the Admin Console, and how to run GlassFish
under a minimally privileged user.
GlassFish 3.1 is the latest release and is available as GlassFish Server Open Source Edition 3.1 (free) and
Oracle GlassFish Server 3.1 (supported and requires paid subscription).
I installed both using the same process below.
The procedure is the same as with 3.0.1 with some minor changes.
If you do not already have the Java Development Kit (JDK) installed on your machine, you will need to download
and install the required JDK for your platform.
If you do have the JDK installed, you can skip to: Step 2: Download and Install the GlassFish 3.1 Server:
1.
1.
Change to the /usr/java directory we created and install the JDK using 'sh /opt/jdk-6u24-linux-x64.bin'
view plaincopy to clipboardprint?
1.
2.
Set the JAVA_HOME path. This is where we installed the JDK above.
To do this for your current session, you can issue the following:
1.
2.
3.
4.
To set the JAVA_HOME for users, we add this to the user ~/.bashrc or ~/.bash_profile of the user. We can also
add it /etc/profile and then source it to give to all users.
view plaincopy to clipboardprint?
1.
JAVA_HOME=/usr/java/jdk1.6.0_24
2.
export JAVA_HOME
3.
PATH=$JAVA_HOME/bin:$PATH
4.
export PATH
Once you have added the above to ~/.bash_profile or ~/.bashrc, you should log out, then log back in and check
that the JAVA_HOME is set correctly.
view plaincopy to clipboardprint?
1.
2.
/usr/java/jdk1.6.0_24
1.
1.
2.
1.
2.
1.
#!/bin/bash
2.
3.
# processname: glassfish
4.
# chkconfig: 234 20 80
5.
JAVA_HOME=/usr/java/jdk1.6.0_24
6.
export JAVA_HOME
7.
PATH=$JAVA_HOME/bin:$PATH
8.
export PATH
9.
GLASSFISH_HOME=/usr/share/glassfish3/glassfish
10.
11. case $1 in
12. start)
13. sh $GLASSFISH_HOME/bin/asadmin start-domain domain1
14. ;;
15. stop)
16. sh $GLASSFISH_HOME/bin/asadmin stop-domain domain1
17. ;;
18. restart)
19. sh $GLASSFISH_HOME/bin/asadmin stop-domain domain1
20. sh $GLASSFISH_HOME/bin/asadmin start-domain domain1
21. ;;
22. esac
23. exit 0
If you do not set the JAVA_HOME and PATH in the GlassFish script, when you attempt to start the GlassFish
server it will complain it cannot find Java with the following:
error: /usr/share/glassfish3/glassfish/bin/asadmin: line 19: exec: java: not found
Now, make the script executable and add it to our chkconfig so it starts at boot.
view plaincopy to clipboardprint?
1.
2.
3.
1.
2.
3.
4.
5.
6.
7.
Stop GlassFish:
view plaincopy to clipboardprint?
1.
2.
3.
If you do not see the home page, check the logs and insure that port 8080 is open and available.
On accessing the GlassFish Admin Console for the first time, you will find that no user name or password is
required.
Previous to 3.1, a default password 'adminadmin' was used.
You can set (or change) the admin password within the GlassFish Admin console.
1. Click "Domain" on the tree.
2. Click the Administrator Password tab.
3. Enter and confirm your password and click Save.
4. Note that the "Logout" button now appears at top right.
The first password save will create a file,.asadminpass, in the home directory of the user you are running the
service under.
Alternatively, you can set the admin password via the CLI using.
view plaincopy to clipboardprint?
1.
2.
3.
4.
5.
6.
7.
8.
[root@sv2 bin]#
1.
2.
1.
1.
#!/bin/bash
2.
3.
# processname: glassfish
4.
# chkconfig: 234 20 80
5.
JAVA_HOME=/usr/java/jdk1.6.0_24
6.
export JAVA_HOME
7.
PATH=$JAVA_HOME/bin:$PATH
8.
export PATH
9.
GLASSFISH_HOME=/usr/share/glassfish3/glassfish
10. GLASSFISH_USER=glassfish
11.
12. case $1 in
13. start)
14. su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
15. ;;
16. stop)
17. su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
18. ;;
19. restart)
20. su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
21. su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
22. ;;
23. esac
24. exit 0
1.
[root@sv2 ~]# iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
2.
[root@sv2 ~]# iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080
JRE_HOME=/usr/local/src/jdk1.6.0_25
PATH=$PATH:$JRE_HOME/bin
JAVA_HOME=/usr/local/src/jdk1.6.0_25
JAVA_PATH=$JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin