Replacing OpenGeo Suites on Windows with GeoServer on Linux

After our initial installation of OpenGeo Suites for WMS service on Windows, we encountered some stability issues that could not be resolved. We could have hired some high priced consultants to debug the issue but we opted for a lighter weight infrastructure.

Our initial system specs:

  • Windows Server 2008
  • 4GB ram
  • Quad core
  • Open Geo Suites running as Windows application

Our slim and fast system specs:

  • Ubuntu 10.04
  • 512MB ram
  • Quad core
  • GeoServer running as java process

So far so good. All layers are loading super fast. We will see how the stability issue is resolved. At least we are using a lot few resources now which makes scaling out to a cluster of GeoServers much more affordable.

Scaling down from MS to open source

We just moved a service that was running on the Microsoft stack (Windows Server 2008, .NET, MSSql Server, IIS) to an open source stack (Ubuntu Server, php, Codeigniter framework, apache2, postgres).

We now run the service on a cloud server with dual cpu and 256MB ram (Yes, that’s megabytes).

The old server ran on dual core with 2GB of ram.

A four letter word can ruin your day

halt + Amazon EC2 + Instance Store = A bad day

I did a stupid thing while on vacation. Decided to clone an EC2 server and executed halt from commandline without checking to see if the server was using Instance Store. Whoops, Amazon showed the server as terminating…terminated… ahhhhh.

After having to rebuild the server while on vacation, I have learned a valuable lesson.

Fail2ban does not start after reboot

This problem was identified with the following configuration:
Ubuntu 8.04
fail2ban

Problem: After fail2ban install, everything works fine, but after reboot fail2ban does not start. Manual /etc/init.d/fail2ban restart fails also.

Cause: Fail2ban looks for fail2ban.sock in
/var/run/fail2ban/
During reboot, that directory is removed. Fail2ban assumes it is there and fails on restart.

Solution: Make sure the directory exists during start of fail2ban. Edit the init.d for fail2ban to fix this.
sudo vi /etc/init.d/fail2ban
Find the do_start option.

do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_status && return 1

if [ -e "$SOCKFILE" ]; then
log_failure_msg "Socket file $SOCKFILE is present"
[ "$1" = "force-start" ] \
&& log_success_msg "Starting anyway as requested" \
|| return 2
DAEMON_ARGS="$DAEMON_ARGS -x"
fi

start-stop-daemon --start --quiet --chuid root --exec $DAEMON -- \
$DAEMON_ARGS start > /dev/null\
|| return 2

return 0
}

Add the following after the if statement.

# Assure that /var/run/fail2ban exists
[ -d /var/run/fail2ban ] || mkdir -p /var/run/fail2ban


Finally, it should look like this

do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_status && return 1

if [ -e "$SOCKFILE" ]; then
log_failure_msg "Socket file $SOCKFILE is present"
[ "$1" = "force-start" ] \
&& log_success_msg "Starting anyway as requested" \
|| return 2
DAEMON_ARGS="$DAEMON_ARGS -x"
fi

# Assure that /var/run/fail2ban exists
[ -d /var/run/fail2ban ] || mkdir -p /var/run/fail2ban

start-stop-daemon --start --quiet --chuid root --exec $DAEMON -- \
$DAEMON_ARGS start > /dev/null\
|| return 2

return 0
}

Now restart and it should work.

sudo /etc/init.d/fail2ban restart

Just for kicks, see how /var/run has the newly created fail2ban directory.

sudo ls /var/run

Changing Mysql data directory require change to AppArmor

After a bit of googling and hair-pulling, I realized that if I just changed the datadir directive in my.cnf will cause mysql start to fail on Ubuntu. The other thing is to add permissions to apparmor for mysql to access the new data directories.

Steps
1. sudo vi /etc/apparmor.d/usr.sbin.mysqld
2. Add
/newdir/ r,
/newdir/** rwk,
3. sudo /etc/init.d/apparmor restart
4. sudo /etc/init.d/mysql restart

If that still does not work, check the nix permissions to be sure mysql is owner and group for the new directory recursively.
chown -R mysql:mysql “new datadir path”

Ubuntu apache2 virtualhost setup problems

If you are getting error messages when starting apache2 like

“Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName”
or
“[warn] _default_ VirtualHost overlap on port 80, the first has precedence”

you need to make sure a couple of lines are in your /etc/apache2/httpd.conf  file.

ServerName localhost

Mysql on Windows vs Linux

I was working on optimizing a Mysql database today and accidentally stumbled upon a benchmarking exercise. The original Mysql database is hosted on a Windows Server 2003. I develop on a Mysql database server running on Ubuntu Linux. The Linux server ran the same query twice as fast as the Windows server without using caching or anything. I know that Linux does I/O caching on its own as well so I even tried running the query after a fresh reboot to rule out that factor. Then I got help from a colleague and started tweaking with the my.cnf/my.ini to make sure they were the same and each time, the results came back about the same. Mysql on Windows was consistently slower than Mysql on Linux.

Then we decided to load the database onto other servers for more data points on this Mysql performance test. We ran the same query returning 429 rows of data with 13 table joins and a couple of sub-queries. All queries were run on the command line client on the servers themselves to avoid network lag.  All servers are running Mysql 5.0.x.

Results

1. Ubuntu Linux: 0.70 seconds
2. CentOS: 0.78 seconds
3. Windows 2003 Server: 1.40 seconds
4. Windows 2003 Server: 1.42 seconds

Server hardware

1. Ubuntu Linux
AMD ATHLON 64 X2 4200+
2GB DDR400
200GB 7200RPM SATA/150

2. CentOS
Dual Opteron 240
2GB DDR ECC
120GB 7200RPM SATA/300

3. Windows 2003 Server
Dual Xeon
2GB DDR ECC
7200RPM PATA

4. Windows 2003 Server
2 Dual Xeon (4 CPUs)
8GB DDR ECC
3 73GB 10,000RPM SCSI in RAID 5

A followup to the benchmark that clarifies the cause of the differences

In House Hosting vs ISP

Clients are always trying to determine if they should host their own site in house or using an ISP. While in the past I would definitely suggest using an ISP, it is not so cut and dry as the cost of servers and bandwidth have decreased dramatically. These days, I can build a server that is super fast for around $1,000. Getting a DSL line with static IP addresses cost around $75 per month. It allows for ease of system upgrade and for more advanced integration into business systems through programming. While there is the down side of power backup issues and hardware failures to contend with, it is still a viable option if the website is not a mission critical application.