Monday, January 10, 2011

Installing DSpace 1.7 on Ubuntu 10.10

Installing DSpace 1.7 on Ubuntu 10.10



published by admin on Sat, 12/11/2010 - 18:43



When
we using Solr and Tomcat 6, sometimes we got a lot of request that make
Tomcat get crash because overloaded. If we look at server each seconds,
we will know when to restart tomcat 6 services. But, we don't. So, we
need software to check our server load and performance, especially for
tomcat 6. Monit (go there) is good
solution for this case. Monit can detect performance, load server,
service status also can do response for what we monitoring.


So, let install monit and configure it to detect and autorestart tomcat 6 when overload it comes!

1. Installing monit
sudo apt-get install monit


2. Configure monit for tomcat 6

Edit /etc/monit/monitrc and uncomment line like this:


## Start Monit in the background (run as a daemon):

#

set daemon 120 # check services at 2-minute intervals

# with start delay 240 # optional: delay the first check by 4-minutes (by


## By default Monit will drop alert events if no mail servers are available.

## If you want to keep the alerts for later delivery retry, you can use the

## EVENTQUEUE statement. The base directory where undelivered alerts will be

## stored is specified by the BASEDIR option. You can limit the maximal queue

## size using the SLOTS option (if omitted, the queue is limited by space

## available in the back end filesystem).

#

set eventqueue

basedir /var/monit # set the base directory where events will be stored

slots 100 # optionally limit the queue size




## Monit has an embedded web server which can be used to view status of

## services monitored and manage services from a web interface. See the

## Monit Wiki if you want to enable SSL for the web server.

#

set httpd port 2812 and

#use address localhost # only accept connection from localhost

allow 0.0.0.0/0.0.0.0 # allow localhost to connect to the server and

allow admin:monit # require user 'admin' with password 'monit'


This script for enable monit by default.


3. Add tomcat auto restart script detection


check process solr with pidfile /var/run/tomcat6.pid

start program = "/etc/init.d/tomcat6 start"

stop program = "/etc/init.d/tomcat6 stop"

if failed host your-domain-is-here.com port 8080 protocol http

and request "/solr" then restart

if totalmem is greater than 7268 MB for 10 cycles then restart


Remember, change your-domain-is-here.com with your domain name.

You can modify this script depend on SOLR port, RAM server and tomcat6.pid location


4. Enabling Monit by editing /etc/default/monit and change value for startup into 1


# You must set this variable to for monit to start

startup=1


5. Checking Monit
sudo service monit start
sudo monit status


The Monit daemon 5.1.1 uptime: 0m

Process 'solr'

status running

monitoring status monitored

pid 3550

parent pid 1

uptime 3m

children 0

memory kilobytes 224516

memory kilobytes total 224516

memory percent 2.9%

memory percent total 2.9%

cpu percent 0.0%

cpu percent total 0.0%

port response time 0.002s to yourdomainhere.com/8080/drupal [HTTP via TCP]

data collected Sat Dec 11 12:03:16 2010


System 'ip-yourIP'

status running

monitoring status monitored

load average [0.42] [0.61] [0.64]

cpu -1.0%us -1.0%sy -1.0%wa

memory usage 3298752 kB [43.1%]

data collected Sat Dec 11 12:03:16 2010


6. Enable port 2812 in security groups in Amazon EC2 to access Monit from browser.

Chek your allow address if you want to access from everywhere.


That's it! Now, you can sleep well and don't worry tomcat be naughty :D