Friday, May 17, 2013

CentOS 6.2 Minimal Setup - Part 1 - Enable Networking

I am going to describe the steps I go through to setup my clean CentOS 6.2 Minimal install so that it can run my app on tomcat using mysql as the database.

The first thing I need to do is enabled the networking, which by default is disabled.

So first I need to decide if I am going to use DHCP or Static configuration for the IP address. If this was my production machine it would be fixed. If it was my development or test server that is running on my local machine as a Virtual Machine it would be DHCP.

DHCP
Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file.

Make the following changes:
NM_CONTROLLER="no"
ONBOOT="yes"
BOOTPROTO="dhcp"

So it should look something like the following except the HWADDR will be different.


Then restart the network service using service network restart.

STATIC
Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file.

Make the following changes:
NM_CONTROLLER="no"
ONBOOT="yes"
BOOTPROTO="static"
IPADDR=xxx.xxx.xxx.xxx
NETMASK=xxx.xxx.xxx.xxx

The IPADDR and NETMASK will have been provided by your hosting company.

Edit the /etc/sysconfig/network file.
Make the following changes:
HOSTNAME=server1
GATEWAY=xxx.xxx.xxx.xxx

The GATEWAY will have been provided by your hosting company.

Edit the /etc/resolv.conf file.

Make the following changes:
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx

The 2 nameservers will have been provided by your hosting company.

Edit the /etc/hosts file.

Make the following change:
xxx.xxx.xxx.xxx server1.mydomain.com server1

The IP Address will be the same one entered for the IPADDR in /etc/sysconfig/network-scripts/ifcfg-eth0.

Test with hostname and hostname -f to make sure configured correctly. So for hostname you should see server1. And for hostname -f you should see server1.mydomain.com.

Then restart the network service using service network restart.

Friday, May 10, 2013

Install CentOS 6.2 Minimal on VMware Player 4.0.2

I needed to create a virtual machine running CentOS 6.2 Minimal on VMware Player (4.0.2). The version I wanted to install was only using 512 MB of RAM so it used the text installer. However I kept getting the error "./run_upgrader.sh: line 21: file: command not found" when the machine rebooted.


After much googling and hair pulling I discovered the following entry in the release notes for CentOS 6.2 Minimal () under the section 5. Known Issues.


So I created the virtual machine without specifying the ISO I wanted to install. I just specified the disk space, RAM, etc.


Then once the machine was created, before restarting it again, I wen to the machine settings and modified the CD/DVD (IDE) settings. Here I specified the ISO of CentOS 6.2 Minimal.



After this I started the machine and ran through the install wizard. After the installation the virtual machine reboots without any problems.


Thursday, May 2, 2013

Convert ColdFusion application to Java

A little while back I was given the task of converting and old legacy ColdFusion application to a shiny, new Java one. I was also given very little time to do this. This application has now been at least 1 year live and only run into one issue that was due to the conversion. I thought I would just jot down a few points about the conversion process.

The first issue that came up was about what technology / frameworks to use in the new application. At the time GWT was a favoured web framework by one team and being pushed as the right choice. I ended up using Struts2, JSP and jQuery which ended up working really well because it was a request driven solution. A component driven framework, like GWT, would have required me to rewrite huge parts of the ColdFusion request driven logic. This would have no doubt introduced lots of bugs and extra time into the project. This was also something I wanted to avoid as well because there was little documentation or knowledge about the logic of the original ColdFusion application. In the end I believe it was absolutely the right choice given the time constraints and wishes just to "convert it to Java".

In addition I used Spring and Hibernate because I had used them lots before and having them running on Tomcat was nothing new.

Converting the ColdFusion code was pretty straightforward.
  • I would take a .cfm file and convert that to a .jsp.
  • Any of the scripting I would move out into a Struts2 action which would set attributes in the request that could be used by the JSP.
  • The logic from the action I would further remove and put into beans that were controlled by Spring.
  • I replaced any CFQUERY calls with a DAO layer using Hibernate that was configured using JPA annotations.
  • Most of the Spring beans had JUnit tests run against them to ensure they worked as expected.
In the end it was not really that difficult because I stayed within the bounds of request driven logic. The hardest part was finding out why things where done in a certain way with none of the original developers around and very little documentation.