Monday, 23 June 2014

Find inside a file or directory

Problem: Find a word inside a file or directory

Solution: grep command can be used to find a word inside a file.

[root@iravath search]# grep -rnw '.' -e "Apple"
The above command search for word "Apple" inside a file. The word "Apple" was found in names.txt at line number 3.

Friday, 8 November 2013

Wednesday, 6 November 2013

Unicast liferay cluster on amazon EC2

Setting up liferay cluster on Aamzon EC2:

Amazon EC2 environment doesn’t allow multicasting that’s the reason. The steps mentioned at wiki doesn’t work out of the box.

·         Liferay 6.0.6 CE
·         Java version 1.7.0_45
·         Red Hat Enterprise Linux Server release 6.4
There are two entities that needs to be taken care while clustering
1.       Tomcat  HTTP Session replication
2.       Liferay cache replication
The scope of document is to cover “Liferay Cache Replication”. If you need information related to tomcat session replication please follow wiki

Extract :
·         tcp.xml from “/liferay/tomcat/webapps/ROOT/WEB-INF/lib/jgroups.jar” and copy to /liferay/tomcat/webapps/ROOT/WEB-INF/classes
·         hibernate-clustered.xml from “/liferay/tomcat/webapps/ROOT/WEB-INF/lib/portal-impl.jar ” and copy to /liferay/tomcat/webapps/ROOT/WEB-INF/classes
·         liferay-multi-vm-clustered.xml from “/liferay/tomcat/webapps/ROOT/WEB-INF/lib/portal-impl.jar ” and copy to /liferay/tomcat/webapps/ROOT/WEB-INF/classes

Edit tcp.xml  and set <TCP  singleton_name="liferay_jgroups_tcp" bind_port="7800"

Edit and set below attributes
#Setup hibernate
#Setup distributed ehcache
#In order to make use of jgroups

In my env I have two node cluster. The above changes needs to be performed on both the nodes.

Start tomcat on node1:
export JAVA_HOME=/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export JAVA_OPTS="-Djgroups.bind_addr=node1 -Djgroups.tcpping.initial_hosts=node2[7800],node1[7800] -Xms256m -Xmx1024m -XX:MaxPermSize=512m"

Start tomcat on node2:

export JAVA_HOME=/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export JAVA_OPTS="-Djgroups.bind_addr=node2 -Djgroups.tcpping.initial_hosts=node2[7800],node1[7800] -Xms256m -Xmx1024m -XX:MaxPermSize=512m"

If everything goes well. You should see following channels gets created .  Verify liferay log.

GMS: address=node1-17685, cluster=EH_CACHE, physical address=
GMS: address=node1-36406, cluster=EH_CACHE, physical address=
GMS: address=node1-10244, cluster=LIFERAY-CONTROL-CHANNEL, physical address=

GMS: address=node1-22557, cluster=LIFERAY-TRANSPORT-CHANNEL-0, physical address=
Test cases:
1.       Create a user in node1 and  search for the same user in node2. You should see user in node2
2.       Add a asset publisher portlet on page1  and access the same page on the other sever. The asset publisher portlet should be seen.

BTW..  ehcache.statistics.enabled=true and “” are used for debugging purpose of the cache.

Wednesday, 30 October 2013

Deleting ipv6 address

Problem: Deleting ipv6 address in Linux

ifconfig eth0 inet6 del fd00:7a06:a248:1:250:56ff:fe86:32cb/64

Tuesday, 29 October 2013

Counting number of files in a directory -Linux

Problem:  I want to find number of files in a directory

[root@dragon bin]# ls -l | wc -l
[root@dragon bin]#

Friday, 25 October 2013

Downloading JDK7 using wget on linux

Problem: I have to download Oracle JDK7 on linux using wget.

Solution: Please use below command and replace jdk url with appropriate version. Here I am downloading JDK7  update 45 on x64 linux

wget --no-check-certificate --no-cookies --header "Cookie:" "" 

Thursday, 24 October 2013

504 Gateway Timeout Error

Problem: My load balancer machine is giving me 504 Gateway Timeout Error.

HTTP request flow :

Browser <-> nginx(load balaencer on port 80) <-> Apache ( reverse proxy on port 85) <-> haproxy (load balaencer on 7070) <-> Tomcat ( Servlet Enginge 8080)

When I am accessing resource I receive 504 Gateway Timeout Error gateway time out. I am clue less which server is sending this error. I verified the logs of ngnix,apache,haproxy,tomcat none of them revel evident root cause.

Approach Taken to solve the Problem:

Let’s access the resource from bottom to top

http://tomcat-ip:8080 /helloworld/hello.jsp  (Resource is served in  5min. No time out)
http://Apache-ip:8585 /helloworld/hello.jsp (Received 504 Gateway time out)
http://nginx:80 /helloworld/hello.jsp (Received 504 Gateway time out)

We identified the root cause for this problem is haproxy and we need to increase the load_balancer time out of it.


  • Stop haproxy .  ( I  greped for process id and killed the process)
  • Edit  /etc/haproxy/haproxy.cfg
  • Increase the value of
  •        clitimeout              9930000
  •         contimeout              9930000
  •         srvtimeout              9930000
  • Start haproxy  (./haproxy-1.4.24 -f /etc/haproxy/haproxy.cfg)