David Ghedini

Linux, Java, Oracle, and PostgreSQL


David Ghedini

Friday Mar 18, 2011

Installing Apache Geronimo on CentOS or RHEL

This post will cover installing Geronimo 2 on CentOS, RHEL, or Fedora.

In this post, we'll install the required JDK, Geronimo 2.2.1, create a Geromino start/stop script, and configure Geronimo to run as a service.

Geronimo is available with choice of Tomcat or Jetty. Except for the file names, the installation procedure is identical.

For this installation, we'll use Geronimo 2.2.1, the current, stable release.

To start, we'll install the Java Development Kit (JDK) 1.6

Geronimo 2.2.1 is certified only on Java EE 5 so you can substitute for below, but I have not had any issues with 6.

If you do have the JDK installed, you can skip to: Step 2: Download and Unpack Geronimo 2.2.1:

Step 1: Install JDK 1.6


You can download the JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

We'll install the latest JDK, which is JDK 6 Update 24. The JDK is specific to 32 and 64 bit versions.

My CentOS box is 64 bit, so I'll need: jdk-6u24-linux-x64.bin.

If you are on 32 bit, you'll need: jdk-6u24-linux-i586.bin

Download the appropriate JDK and save it to a directory. I'm saving it to /root.

Move (mv) or copy (cp) the file to the /opt directory:

[root@srv6 ~]# mv jdk-6u24-linux-x64.bin /opt/jdk-6u24-linux-x64.bin  


Create a new directory /usr/java.

[root@srv6 ~]# mkdir /usr/java  


Change to the /usr/java directory we created and install the JDK using 'sh /opt/jdk-6u24-linux-x64.bin'

[root@srv6 ~]# cd /usr/java
[root@srv6 java]# sh /opt/jdk-6u24-linux-x64.bin


Set the JAVA_HOME path. This is where we installed our JDK above.

To set it for your current session, you can issue the following from the CLI:

[root@srv6 java]# JAVA_HOME=/usr/java/jdk1.6.0_24
[root@srv6 java]# export JAVA_HOME
[root@srv6 java]# PATH=$JAVA_HOME/bin:$PATH
[root@srv6 java]# export PATH


To set the JAVA_HOME permanently, we add below to either the ~/.bashrc or ~/.bash_profile of the user (in this case, root).

We can also add it /etc/profile and then source it to give to all users.

JAVA_HOME=/usr/java/jdk1.6.0_24
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
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.

[root@srv6 ~]#  echo $JAVA_HOME
/usr/java/jdk1.6.0_24


Step 2: Download and Unpack Geronimo 2.2.1


Download geronimo-tomcat6-javaee5-2.2.1 here

If you want to use the embedded Jetty version, download geronimo-jetty7-javaee5-2.2.1 from the same page as above.

Again, the only difference in installation is the file names, so just adjust accordingly.

Save the file to a directory. I'm saving it to /root/geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz

Before proceeding, you should verify the MD5 Checksum for your Geronimo download.

Since we saved the Geronimo download to /root/geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz, we'll go to the /root directory and use the md5sum command.

[root@srv6 ~]# md5sum geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz
0bb2985421398eb2b4af35ce4eaff974  geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz


Compare the output above to the MD5 Checksum provided by the Geronimo Tomcat MD5 page and insure that they match exactly.

Now, move (mv) or copy (cp) the file to the /usr/share directory:

[root@srv6 ~]# mv geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz /usr/share/geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz


Change to the /usr/share directory and unpack the file using tar -xzf:

[root@srv6 ~]# cd /usr/share
[root@sv2 srv6 ]# tar -xzf geronimo-tomcat6-javaee5-2.2.1-bin.tar.gz  


This will create the directory /usr/share/geronimo-tomcat6-javaee5-2.2.1

Step 3: Configure Geronimo to Run as a Service.


We will now create a simple Start/Stop/Restart script and configure Geronimo to run as a service.

Naviagte to the /etc/init.d directory and create a script called 'geronimo' as shown below.

[root@srv6 share]# cd /etc/init.d
[root@srv6 init.d]# vi geronimo


The script:

#!/bin/bash
# description: Geronimo Start Stop Restart
# processname: geronimo
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.6.0_24
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GERONIMO_HOME=/usr/share/geronimo-tomcat6-javaee5-2.2.1

case $1 in
start)
sh $GERONIMO_HOME/bin/startup.sh
;; 
stop)   
sh $GERONIMO_HOME/bin/shutdown.sh
;; 
restart)
sh $GERONIMO_HOME/bin/shutdown.sh
sh $GERONIMO_HOME/bin/startup.sh
;; 
esac    
exit 0


As you can see, we are simply calling the startup.sh and shutdown.sh scripts located in the Geronimo bin directory (/usr/share/geronimo-tomcat6-javaee5-2.2.1/bin).

GERONIMO_HOME is the Geronimo home directory where we unpacked at (/usr/share/geronimo-tomcat6-javaee5-2.2.1)

Now, make the geronimo script executable:

[root@srv6 init.d]# chmod 755 geronimo


Add Geronimo to chkconfig and set to start at boot.

[root@srv6 init.d]# chkconfig --add geronimo
[root@srv6 init.d]# chkconfig --level 234 geronimo on


Verify it:

[root@srv6 init.d]# chkconfig --list geronimo
tomcat          0:off   1:off   2:on    3:on    4:on    5:off   6:off


Now, we can start Geronimo using 'service geronimo start':

Start Geronimo:
[root@srv6 ~]# service geronimo start
Using GERONIMO_HOME:   /usr/share/geronimo-tomcat6-javaee5-2.2.1
Using GERONIMO_TMPDIR: var/temp
Using JRE_HOME:        /usr/java/jdk1.6.0_24/jre
Using GERONIMO_OUT:    /usr/share/geronimo-tomcat6-javaee5-2.2.1/var/log/geronimo.out

Geronimo started in background. PID: 5179


You should now be able to navigate to http://yourdomain.com:8080 or http://yourIPaddress:8080 and we should see the Geronimo home page.



Step 4: Access Geronimo Admin Console and Change Password.


To access the Geronimo Admin Console, click the 'Console' link under Administration on the home page or simply navigate to http://yourdomain.com:8080/console or http://yourIPaddress:8080/console.

The default user name and password is system/manager.



Logged in as system:



To change the default password, in the Console Navigation menu, expand the Security node and then click on 'Users and Groups'



Click the Edit link for the user System and update the password.



Step 5 (optional): Modify Script to Pass the System Password Value.


Stopping Geronimo.

Using our script above, when stopping Geronimo using 'service geronimo stop', we will be prompted for the system password:

[root@srv6 init.d]# service geronimo stop
Using GERONIMO_HOME:   /usr/share/geronimo-tomcat6-javaee5-2.2.1
Using GERONIMO_TMPDIR: var/temp
Using JRE_HOME:        /usr/java/jdk1.6.0_24/jre
Username: system
Password: *******
Locating server on localhost:1099... Server found.
Server shutdown started
Server shutdown completed


We can modify our script, however, to pass the password to the shell by adding '--user system --password manager' to the shutdown command:

#!/bin/bash
# description: Geronimo Start Stop Restart
# processname: geronimo
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.6.0_24
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
GERONIMO_HOME=/usr/share/geronimo-tomcat6-javaee5-2.2.1

case $1 in
start)
sh $GERONIMO_HOME/bin/startup.sh
;; 
stop)   
sh $GERONIMO_HOME/bin/shutdown.sh --user system --password manager
;; 
restart)
sh $GERONIMO_HOME/bin/shutdown.sh --user system --password manager
sh $GERONIMO_HOME/bin/startup.sh
;; 
esac    
exit 0


**In the script above, I am using the default system/manager password above, but don't forget to use the new password you created for the system user in the console in Step 4 above.
You can also create a new role and user if you wish to.

Now, when we stop Geronimo using 'service geronimo stop' we are no longer prompted for the password:

Stop Geronimo:
[root@srv6 init.d]# service geronimo stop
Using GERONIMO_HOME:   /usr/share/geronimo-tomcat6-javaee5-2.2.1
Using GERONIMO_TMPDIR: var/temp
Using JRE_HOME:        /usr/java/jdk1.6.0_24/jre
Locating server on localhost:1099... Server found.
Server shutdown started
Server shutdown completed


Learn More About Apache Geronimo

Apache Geronimo
Geronimo Documentation Wiki

Bookmark and Share



Wednesday Mar 02, 2011

How to Enable or Disable Root login via SSH

This post will cover how to enable (or disbale) Root login via SSH.

It's always best practice that any machine on the internet not allow direct Root login via SSH.

To allow Root to log in, we need to update our sshd_config file located at /etc/ssh/sshd_config.

To update this file, we need to switch over to Root:

[admin@blanche ~]$ su root
Password:
[root@blanche ~]#


Go to the /ect/ssh directory:

[root@blanche ~]# cd /etc/ssh
[root@blanche ssh]#


Now, let's edit our sshd_config file using vi:

[root@blanche ssh]# vi sshd_config


Look for the following section (about 1/3 of the way down):

#LoginGraceTime 2m
PermitRootLogin no


Hit "i" to insert and then change the value for PermitRootLogin from no to yes.

Hit Escape and then :wq! to save changes and close the file.

Finally, still as Root, we need to restart SSHD using /etc/init.d/sshd restart.

[root@blanche ssh]# /etc/init.d/sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]


Exit your session, open a new terminal and confirm you are now able to login as Root:

login as: root
root@blanche's password:
Last login: Mon Jun 28 16:21:53 2010
[root@blanche ~]#


To prevent Root log in, simply set to (or change to) PermitRootLogin no in your sshd_config

Bookmark and Share



How to Set Hostname on CentOS

This post will cover how to set the server hostname on CentOS.

Well, I could have sworn when I ordered this VPS that I entered the hostname I wanted in the order form. I guess I must have been hallucinating....

Begin by checking the existing hostname using the hostname command.

login as: root
root@vps12's password:
Last login: Mon Jun 28 16:21:53 2010
[root@vps12 ~]# hostname
vps12


We can also check via sysctl kernel.hostname

[root@vps12 ~]# sysctl kernel.hostname
kernel.hostname = vps12


The actual hostname I need to set for this server is blanche.mydomain.net

I can set the hostname initially using the hostname command followed by the desired hostname.

[root@vps12 ~]# hostname blanche.mydomain.net


This will set the hostname:

[root@vps12 ~]# hostname
blanche.mydomain.net


However, once the server is rebooted, the hostname will revert to it's previous setting (vps12).

To permanently change the hostname, I need to edit the network file at /etc/sysconfig/network.

So,

[root@vps12 ~]# cd /etc/sysconfig
[root@vps12 sysconfig]# vi network


The Network file will look as so.

NETWORKING=yes
HOSTNAME=vps12
GATEWAYDEV=eth0
GATEWAY=192.168.0.1


Hit 'i' to insert and change the HOSTNAME value to your FQDN, in my case, blanche.mydomain.net

Hit Escape, then :wq to save and exit.

Check that the hostname is properly set:

[root@vps12 sysconfig]# hostname
blanche.mydomain.net
[root@vps12 sysconfig]# sysctl kernel.hostname
kernel.hostname = blanche.mydomain.net


Finally, if we log out, and log back in using a new session, we see I am now root@blanche:

login as: root
root@blanche's password:
Last login: Mon Jun 28 16:21:53 2010
[root@blanche ~]#  


To properly check, you may wish to reboot the server.

Bookmark and Share




Main Menu

Built With

Pages

LinkedIn

Tag Cloud

Hosted by:

Navigation

Visitors

Sponsors

petiole Cloud

Feeds