Step out from LINUX issue

Total Pageviews

Wednesday, 21 May 2014

What is dmesg command and how to use it in Linux/Unix?

What is dmesg command and how to use it in Linux/Unix?

Example 1: Display all the devices drivers loaded in to kernel.
dmesg
The above command will give as all the hardware drivers loaded in to kernel, their status success or failed and even error message why they are failed.
Example2: Display hardware information related to Ethernet port eth0
dmesg | grep -i eth0
Clipped Output:
[ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.5.0-25-generic (buildd@komainu) (gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) ) #39-Ubuntu SMP Mon Feb 25 18:26:58 UTC 2013 (Ubuntu 3.5.0-25.39-generic 3.5.7.4)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.5.0-25-generic root=UUID=9b1dca12-2bf6-47d3-ab45-929f85bec913 ro quiet splash vt.handoff=7
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] e820: BIOS-provided physical RAM map:

Posted by Unknown at 09:38 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Tuesday, 20 May 2014

How to run multiple Tomcat instances on single Linux server?

If you are a developer then you will find yourself in a situation where you have to run multiple instances of Tomcat server on a single machine. The information available on the internet may not be precise and hence I have listed down the step-by-step guide to achieve it.
The configuration used for the illustration is Linux CentOS-6.X server.

  • /bin : This directory contains the startup and shutdown scripts for both Windows and Linux.
  • /conf : This directory contains the main configuration files for Tomcat. The two most important are the server.xml and the global web.xml .
  • /server : This directory contains the Tomcat Java Archive files.
  • /lib : This directory contains Java Archive files that Tomcat is dependent upon.
  • /logs : This directory contains Tomcat’s log files.
  • /src : This directory contains the source code used by the Tomcat server. Once Tomcat is released, it will probably contain interfaces and abstract classes only.
  • /webapps : All web applications are deployed in this directory; it contains the WAR file.
  • /work : This is the directory in which Tomcat will place all servlets that are generated from JSPs. If you want to see exactly how a particular JSP is interpreted, look in this directory.

Tomcat server ports

Having a good understanding of tomcat ports is essential to manage the multiple instances of the same server installation. These ports are used by tomcat for start-up, deployment and shut-down operations. The detail of each port is as:
  • Connector Port : This is the port where Apache Tomcat listen for the HTTP requests.
  • Shutdown Port : This port is used when we try to shutdown the Apache Tomcat Server.
  • AJP (Apache JServ Protocol) Connector Port : The Apache JServ Protocol (AJP) is a binary protocol that can conduct inbound requests from a web server through to an application server that sits behind the web server.
  • Redirect Port : Any redirection happening inside Apache Tomcat will happen through this port. In Apache TOMCAT there are two instance where redirectPort is mentioned. First one is for the Apache TOMCAT server and other one is for the AJP port.
  • Step 1:
    Download Tomcat from http://tomcat.apache.org/download-60.cgi
  • Step 2:
    Extract it into two different folders, let’s say /opt/tomcat1 and /opt/tomcat2
  • Step 3:
    Keep tomcat1 instance as is and change following things in tomcat2 instance
    Edit /opt/tomcat2/conf/server.xml and change port number
    <server port="8105" shutdown="SHUTDOWN">
    .....
    <Connector port="8181" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" />
    .....
    <Connector port="8109" protocol="AJP/1.3" redirectPort="8443" />
  • Step 4:
    Create following two scripts to run Tomcat as a service
    1. Create /etc/init.d/tomcat1 with following instructions

      #!/bin/bash
      # description: Tomcat Start Stop Restart
      # processname: tomcat
      # chkconfig: 234 20 80
      JAVA_HOME=/usr/lib/jvm/jre-openjdk
      export JAVA_HOME
      PATH=$JAVA_HOME/bin:$PATH
      export PATH
      CATALINA_HOME=/opt/tomcat1
      case $1 in
      start)
      sh $CATALINA_HOME/bin/startup.sh
      ;;
      stop)
      sh $CATALINA_HOME/bin/shutdown.sh
      ;;
      restart)
      sh $CATALINA_HOME/bin/shutdown.sh
      sh $CATALINA_HOME/bin/startup.sh
      ;;
      esac
      exit 0
    2. Create /etc/init.d/tomcat2 with following instructions

      #!/bin/bash
      # description: Tomcat Start Stop Restart
      # processname: tomcat
      # chkconfig: 234 20 80
      JAVA_HOME=/usr/lib/jvm/jre-openjdk
      export JAVA_HOME
      PATH=$JAVA_HOME/bin:$PATH
      export PATH
      CATALINA_HOME=/opt/tomcat2
      case $1 in
      start)
      sh $CATALINA_HOME/bin/startup.sh
      ;;
      stop)
      sh $CATALINA_HOME/bin/shutdown.sh
      ;;
      restart)
      sh $CATALINA_HOME/bin/shutdown.sh
      sh $CATALINA_HOME/bin/startup.sh
      ;;
      esac
      exit 0
  • Step 5:
    Start/Stop Tomcat service
    Service tomcat1 start/stop/restart
    Service tomcat2 start/stop/restart
  • Step 6:
    Add Tomcat service in startup
    chkconfig tomcat1 on
    chkconfig tomcat2 on
This will enable you to use two instances of Tomcat on a single machine.
Posted by Unknown at 08:25 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

Monday, 19 May 2014

To Emulate network traffic we will be using this command

To Emulate network traffic we will be using this command
tc qdisc change dev eth0 root netem loss 0%
if above command output will show
RTNETLINK answers: No such file or directory
Then we have to use this command to add the same .
tc qdisc add dev eth0 root netem loss 0%.

Examples:


[root@revplus2 ~]# tc qdisc change dev eth0 root netem loss 0%
[root@revplus2 ~]# ping 172.19.1.1
PING 172.19.1.1 (172.19.1.1) 56(84) bytes of data.
64 bytes from 172.19.1.1: icmp_seq=1 ttl=255 time=2.81 ms
64 bytes from 172.19.1.1: icmp_seq=2 ttl=255 time=0.586 ms
64 bytes from 172.19.1.1: icmp_seq=3 ttl=255 time=1.35 ms
^C
--- 172.19.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2990ms
rtt min/avg/max/mdev = 0.586/1.583/2.810/0.922 ms
[root@revplus2 ~]#



Posted by Unknown at 22:18 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

How to implement ip forwarding in Linux

How to implement ip forwarding in Linux
IP forwarding is a concept to make Linux machine to send data from one network to other, this is same as a router(A router is a device to send packets from one point to other point depending on the packet destination/rules etc). 
Why we need IP forwarding on a Linux machine?
Ans : We need IP forwarding on a Linux machine because to make it as a router or proxy server to share one internet connection to many client machines.
Let me explain how this will work with small example.
You have 2 machines which are in different network(PC1 in 10.0.0.0/255.0.0.0network and PC2 in 192.168.0.0/255.255.255.0 network) and connected with a Linux machine(which is having two network interfaces). The IP address is as follows..
PC1: 192.168.0.1/255.255.255.0 default gateway:192.168.0.2
PC2: 10.0.0.1/255.0.0.0 default gateway:10.0.0.2
Linuxbox eth0 : 192.168.0.2/255.255.255.0
eth1 : 10.0.0.2/255.0.0.0
and Linuxbox is having two LAN cards which are connected to both the machines as shown below


So do you think PC1 is capable of communicating with PC2?
Ans : The answer to this question is No.
How to make PC1 to communicate with PC2?
Ans : The answer is enable ip forwarding on Linux machine. Some times this is known as bridging two networks.
To make IP forwarding we have to edit /etc/sysctl.conf as shown below. Opensysctl.conf and change the value of “net.ipv4.ip_forward” from 0 to 1 and save the file
#vi /etc/sysctl.conf
net.ipv4.ip_forward = 0
to
net.ipv4.ip_forward = 1
Once its done still you are not able to ping from PC1 to PC2. We have to restart the linuxbox to take this update to kernel. 
Why to restart if it's a production machine try below command to make your linuxbox aware of IP forwarding without a restart.
echo 1 > /proc/sys/net/ipv4/ip_forward
Now try to ping from PC1 to PC2 which will ping successfully.


Posted by Unknown at 20:38 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Followers

Blog Archive

  • ►  2018 (3)
    • ►  November (2)
    • ►  July (1)
  • ►  2017 (3)
    • ►  April (3)
  • ►  2015 (3)
    • ►  July (3)
  • ▼  2014 (39)
    • ►  August (2)
    • ►  July (3)
    • ►  June (11)
    • ▼  May (4)
      • What is dmesg command and how to use it in Linux/U...
      • How to run multiple Tomcat instances on single Lin...
      • To Emulate network traffic we will be using this c...
      • How to implement ip forwarding in Linux
    • ►  April (4)
    • ►  February (12)
    • ►  January (3)
  • ►  2012 (2)
    • ►  July (2)

About Me

Unknown
View my complete profile

Wikipedia

Search results

Simple theme. Powered by Blogger.

Contact Form

Name

Email *

Message *