Posts

Showing posts from April 18, 2011

Linux Admin Q&A

Interview Questions And Answers Q: - How are devices represented in UNIX? All devices are represented by files called special files that are located in /dev directory. Q: - What is 'inode'? All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. Q: - What are the process states in Unix? As a process executes it changes state according to its circumstances. Unix processes have the following states: Running : The process is either running or it is ready to run . Waiting : The process is waiting for an event or for a resource. Stopped : The process has been stopped, usually by receiving a signal. Zombie : The process is dead but have not been removed from the process table. Q: - What command should you use to check the number of files and ...

Apache Interview QA

Interview Questions And Answers Q: - What is location of log files for Apache server ? /var/log/httpd Q: - What are the types of virtual hosts ? name-based and IP-based. Name-based virtual host means that multiple names are running on each IP address. IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address. Q: - How to restart Apache web server ? service httpd restart Q: - How to check the version of Apache server ? rpm -qa |grep httpd Q: - What is meaning of "Listen" in httpd.conf file ? Port number on which to listen for nonsecure (http) transfers. Q: - What is DocumentRoot ? it is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory. Q: - On which port Apache server works ? http - port 80 https - port 443 Q: - Tell me...

Redirect thread dump to another file?

On Jboss or Tomcat application server, we usually use kill -3 PID to get thread dump to default STDOUT which is catalina.out under $Tomcat_Home/logs folder. It might be nature to use command kill -3 PID > some.file 2>&1 to try to redirect the thread dump info to some.file than default one. However, it will not work. The reason is kill is just a command to send a signal to a process. You are redirecting the output of the kill command itself rather than the process (what the process does upon receipt of a signal is separate), so the redirect (supposed to kill command itself) has no effect on which file the process (PID) will write to. Given that, if we need redirect thread dump for that process to some other file, we need add redirects to that process when it starts. Another popular way is to use jstack -F PID to get the whole thread dump forcefully. "jstack" : A JVM troubleshooting tool that prints stack traces of all running threads of a given JVM proce...

Taking Thread Dump in Linux

Generating a Thread Dump on Linux, including Solaris and other Unixes 1.) Identify the java process that JIRA is running in: This can be achieved by running a command similar to: [root@server2~]#ps -ef | grep java root      8876  8854 12 10:54 pts/5    00:08:37 /usr/jdk1.6.0_16/bin/java -Dprogram.name=run.sh -server -Xms256m -Xmx1024m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/data2/jboss/lib/endorsed -classpath /data2/jboss/bin/run.jar:/usr/jdk1.6.0_16/lib/tools.jar org.jboss.Main -c all -b 192.168.2.102 -Djboss.messaging.ServerPeerID=1 root     10154  9577  0 12:02 pts/3    00:00:00 grep java   2.) Find the process ID of the JVM and use the ps command to get list of all processes:  kill -3 The thread dump will be printed to Confluence's stan...

Java Thread Dump

Understanding a Java thread dump 1. Introduction In my opinion, one of the greatest things about Java is the ability to get meaningful thread dumps on a running production environment without having to enable DEBUG mode. The thread dump is a snapshot of exactly what's executing at a moment in time. While the thread dump format and content may vary between the different Java vendors, at the bare minimum it provides you a list of the stack traces for all Java threads in the Java Virtual Machine. Using this information, you can either analyze the problem yourself, or work with those who wrote the running code to analyze the problem. 2. What is a stack trace? I mentioned earlier that the thread dump is just a list of all threads and the full stack trace of code running on each thread. If you are a J2EE Application Server administrator and you've never done development before, the concept of a stack trace may be foreign to you. A stack trace is a dump of the curre...