Friday 7 December 2012

What to do when you get a new server?


First of all have a big smile mmmmmmmmmmmmmm :)

It's always been a lovely experience to play with a new server, it's like you got a new power source and you start thinking of how to optimize the utilization of the resource, Shall i create distributed memory system or I shall deploy some other components on this machine because it is having higher computation power, woooow. It's fascinating.

Any ways, I am first writing this basic set of commands which will work on Debian systems (and yes Ubuntu is built on Debian architecture), to set the basic things always required on a new machine.

First thing you must do is
$ apt-get update
$ apt-get upgrade

1. Using command apt-cache you can search the package 
apt-cache search jdk
2. Using command apt-get you can install the package
$ apt-get install openjdk-6-jdk
$ apt-get install mysql-server
$ apt-get install atop

If you want only mysql client - try this
$apt-get install mysql-client-5.5

3. Set the timezone on debian machine
$ dpkg-reconfigure tzdata
And choose Asia->Kolkata

4. Installing sar on ubuntu
$ sudo apt-get install sysstat
$ sudo vi /etc/default/sysstat
change ENABLED=”false” to ENABLED=”true”
$ sudo vi /etc/cron.d/sysstat
Change 5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
To */2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1

$ sudo service sysstat restart
$ sar -A
If you want to save the statistics for further analysis to a file use:
$ sudo sar -A > $(date +`hostname`-%d-%m-%y-%H%M.log)

5. apt-get install zip

6. You might want to change the file limits - find details at here
http://nishal-tech.blogspot.in/2013/07/how-to-set-ulimit-in-ubuntudebian-linux.html



Thursday 13 September 2012

ActiveMQ Detected missing/corrupt journal files

If you are getting an error while starting ActiveMQ something like this

2012-09-13 18:23:39,823 | ERROR | Failed to start ActiveMQ JMS Message Broker. Reason: java.io.IOException: Detected missing/corrupt journal files. 1 messages affected. | org.apache.activemq.broker.BrokerService | main
java.io.IOException: Detected missing/corrupt journal files. 1 messages affected.
at org.apache.activemq.store.kahadb.MessageDatabase.recoverIndex(MessageDatabase.java:626)
at org.apache.activemq.store.kahadb.MessageDatabase$6.execute(MessageDatabase.java:460)
at org.apache.kahadb.page.Transaction.execute(Transaction.java:728)
at org.apache.activemq.store.kahadb.MessageDatabase.recover(MessageDatabase.java:458)
at org.apache.activemq.store.kahadb.MessageDatabase.open(MessageDatabase.java:315)
at org.apache.activemq.store.kahadb.MessageDatabase.load(MessageDatabase.java:357)
at org.apache.activemq.store.kahadb.MessageDatabase.doStart(MessageDatabase.java:222)
at org.apache.activemq.store.kahadb.KahaDBStore.doStart(KahaDBStore.java:180)
at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:53)
at org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter.start(KahaDBPersistenceAdapter.java:186)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:485)
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)

---
solution is :
Sometime kahaDB which is used by activeMQ to persist the message, get either corrupted some message/journal gets corrupted or missing. I got few flag which can can configured in activemq.xml.

   <persistenceAdapter> 
            <kahaDB directory="${activemq.base}/data/kahadb" 
                    ignoreMissingJournalfiles="true" 
                    checkForCorruptJournalFiles="true" 
                    checksumJournalFiles="true" />
     </persistenceAdapter> 

http://activemq.apache.org/kahadb.html

After setting these flag, start the activemq and watch it print something like this :


2012-09-13 18:33:26,144 | INFO  | Recovering from the journal ... | org.apache.activemq.store.kahadb.MessageDatabase | main
2012-09-13 18:33:26,145 | INFO  | Recovery replayed 1 operations from the journal in 0.326 seconds. | org.apache.activemq.store.kahadb.MessageDatabase | main
2012-09-13 18:33:29,580 | INFO  | Some journal files are missing: [42658] | org.apache.activemq.store.kahadb.MessageDatabase | main
2012-09-13 18:33:29,774 | INFO  | Detected missing/corrupt journal files.  Dropped 1 messages from the index in 3.59 seconds. | org.apache.activemq.store.kahadb.MessageDatabase | main

Then you are done. If it still does not work. Remove the kahadb/db.data and restart, it will parse the journal to rebuild the index.

I am using 5.4.2 version of ActiveMQ, kahaDB version 3.

:)

Monday 23 April 2012

How to do context deployment in tomcat?


It pretty simple, Create a context file like this

<?xml version="1.0" encoding="utf-8"?> <Context path="" docBase="/home/username/applicationbase"> </Context>

and save it as example.xml and put it in $TOMCAT_HOME/conf/Catalina/localhost directory.

Knowledge points:
1. Meaning of the path attribute, if you want to access the application with www.domainname.com/example/*, then path name should be example, if you want to make it default appliction, path should be empty string
2. For me even if I kept the path name empty string, it was not acting as default application then I renamed the example.xml to ROOT.xml and it worked. I am using tomcat5.
3. Even if you keep a war file applicationbase.war in /home/username/ directory it works

You can configure the context better by reading this http://tomcat.apache.org/tomcat-5.5-doc/config/context.html.



Monday 5 March 2012

How to make use of /home directory on Mac Os

Actually The /home path is auto_mounted but not used for anything. Edit the file /etc/auto_master and comment out the /home path. Reboot and you can use /home as you wish.

This works with Mac OS X 10.6.8 (Snow Leopard). 
As noted on that forum post, you should also be aware that Time Machine automatically excludes the /home directory and does not back it up.

Answer is originally from this Apple thread : https://discussions.apple.com/thread/2073807?threadID=2073807&tstart=0