Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation


#Vagrant report

##Report Table

Issue How to find Time to find How to fix Time to fix
1 Tomcat is unavailable $cd /opt/apache/tomcat/7.0.62/conf
```$cat server.xml
grep port<br>$netstat -ntlp<br>$curl -IL 192.168.56.10:8080<br>$service tomcat status``` 10 mins $sed -i '/export/d' /home/tomcat/.bashrc
$chown -R tomcat:tomcat /opt/apache/tomcat/current/logs
$alternatives --set java /opt/oracle/java/x64/jdk1.7.0_79/bin/java
$service tomcat restart
2 Connecting to Tomcat failed 1. View httpd error_log
2. View mod_jk log
10 min 1.Edit worker.properties config tomcat.worker > tomcat-worker
2.Edit vhost.conf tomcat.worker>tomcat-worker
20 mins
3 Redirecting to mntlab 1. View httpd access log
2. Mntlab is not defined in vhost.conf
3. Mntlab is in redirect section of the wrong virtual host
10 mins 1.Edit vhost.conf mntlab:80>*:80
2.Edit httpd.conf - comment VirtualHost lines
15 mins
4 Tomcat autostart fail 1.Service tomcat enable
2.Restart server
3.$netstat -ntlp - no tomcat processes
10 mins $chkconfig - tomcat is in the list, but not configured for level 3 and 5
$chkconfig tomcat on --level 35
$reboot
$netstat -ntlp -ok
$curl -IL 192.168.56.10:8080 -200 ok
35 mins
5 $service iptables status- empty 1.Allow connections to 22 and 80 port
2.$iptables-save >>/etc/sysconfig/iptables -permission denied
3.$service iptables stop -ok
4.$iptables-save >>/etc/sysconfig/iptables -permission denied
20 mins 1.$lsattr /etc/sysconfig/iptables -returns iptables marked with "i"
2.chattr -i /etc/sysconfig/iptables
3.$service iptables restart
4.Edit iptables: add empty line before "COMMIT" - now can restore saved rules
30 mins
6 No Tomcat Logs in /var/logs is related to issue 1 5 min $ln -s /opt/apache/tomcat/7.0.62/logs /var/log/tomcat 2 mins

#Manual fix steps

  1. Since mntlab virtual machine imitates web-server - lets check availability of the virtual machine over the network:

$ping 192.168.56.10

  1. Ping is fine, lets check if the httpd is working:

$curl -IL 192.168.56.10

Output will return a HTTP/1.1 503 Service Temporary Unavailable

Having a 503 error usually means the proxied page/service is not available. Since we are using tomcat that means tomcat is either not responding to httpd (timeout?) or not even available (down? crashed?). Httpd seems working. Time to check tomcat.

  1. Tomcat availability

$vagrant ssh

$service httpd status -running

$service tomcat status -running

$netstat -ntlp - httpd is listening 80 port.

!NOTE that theres no listening on 8080(default tomcat port)!

Lets check tomcat server.xml $yum info tomcat - tomcat isnt installed using vim

$find / -name "server.xml"

$cd /opt/apache/tomcat

$ls - 2 folders. 7.0.62 and linked current.

$cd /opt/apache/tomcat/7.0.62/conf

$cat server.xml | grep port - output is saying that tomcat is working on default port 8080. So lets check if it is available $curl -IL 192.168.56.10:8080 - output says coudln't connect to host. So, i must fix Tomcat now.

Fixing Tomcat: $service tomcatstatus - running

 Java Check:
 	
 	$java -version - output bad ELF interpreter - show my DEFAULT java version, which program will use unless we tell them directly not to.

 Lets check catalina.sh file to find out if theres a defined java version for out tomcat. Move to tomcat/bin folder and run

 	$cat catalina.sh | grep JAVA_HOME

 	 java seems to be using default pathes.

 Tomcat could crash or stop working. I can try to restart it, but first - lets check tomcat logs:

 I didnt find any logs seemed to be related to tomcat in /var/log/
 Checking the default log path in catalina.sh

 	$cat catalina.sh | grep log 

 Output says that catalina out is in default location, which is /logs/catalina.out

 	$/opt/apache/tomcat/7.0.62/logs -empty!
    $find / -name catalina.out - no result
 	$cat /etc/init.d/tomcat | grep .sh 

 Returns startup.sh and shutdown.sh, both located in /opt/apache/tomcat//current/bin/. And !note - both of them run with su - tomcat. 

 	$su - tomcat -c env

 Finally. Tomcat env says that it uses 2 specific variables: JAVA_HOME=/tmp CATALINA_HOME=/tmp. If its not in catalina.sh - then it must be in basic tomcat files /home/tomcat
 	
 	$cat /home/tomcat/.bashrc

 Here it is. 2 strings: export CATALINA_HOME=/tmp and export JAVA_HOME=/tmp
 
 Folder /tmp contains no tomcat related files or logs.

 	$sed -i '/export/d' /home/tomcat/.bashrc

 So, deleting this 2 strings will bring us to tomcat startup.sh running well. Now we need to restart tomcat service to reapply new tomcat-user env rules.

 	$service tomcat restart
 
 Error occured: permission denied on /opt/apache/tomcat/current/logs/catalina.out
 
 	$ls -la /opt/apache/tomcat/7.0.62
 
 Shows that permissions for logs folder are control by root.Since tomcat is running by tomcat user, we do the following:
 
    $chown -R tomcat:tomcat /opt/apache/tomcat/current/logs
 
 Create a link in /var/log/
 
    $ln -s /opt/apache/tomcat/7.0.62/logs /var/log/tomcat
    
 Now we can restart tomcat service again
 
    $service tomcat restart
    
 Starting ok, but again error related to java. Lets run setclasspath.sh to check java 
    
    $./setclasspath.sh

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
 
At least one of these environment variable is needed to run this program

    $alternatives --display java
       
Shows that system is using i586 java for 32bit systems, but in according to:
    $uname -m
       
We are running x64bit system, so we need to switch java version:

	$alternatives--config java  
    
Choose x64

Now we can restart tomcat service again

    $service tomcat restart
OK

    $netstat -ntlp
Listening ok

    $curl -IL 192.168.56.10:8080
    
Perform well, now we have access to tomcat

	$curl -IL 192.168.56.10 - still 503, next step - check the httpd config:

4.HTTPd config:

Move to httpd log files dir and run:

	$tail -5 error_log
    
Nothing critital, exept warn: No JkShmFile defined in httpd.conf. Using default
Notice that mod_jk is configured. 
>>Set loglevel debug in httpd.conf
    
    $tail -5 mod_jk
    
Returs(tomcat.worker) connecting to tomcat failed

Lets check httpd configs

    $cat /etc/httpd/conf.d/workers.properties
    
Notice!  The name of the worker can contain only the alphanumeric characters [a-z][A-Z][0-9][_\-] and is case sensitive. Lets change worker name 
Also, worker ip address is incorrect. Since tomcat is running on the same host -change ip to 192.168.56.10
Changing tomcat.worker > tomcat-worker, check other conf files that might be related with previos worker name

    $cat /etc/httpd/conf.d/vhost.conf
    
Changing tomcat.worker > tomcat-worker and replacing mntlab:80 with *:80. To provide any request to be redirected to tomcat.

    $cat /etc/httpd/conf/httpd
    
We have a VirtualHost in httpd, that should be separeted in vhost.conf file, and an incorrect redirect to unexisting(as far as i know this server configuration host mntlab). So i will comment this block. 
   
    $service httpd restart
    $curl -IL 192.168.56.10
   
Returning Tomcat default page.

Set loglevel warn in httpd.conf.

    $service httpd restart
    
Check from host - working.

##Tomcat is now available through httpd.

5.Now, lets check iptables rules

$iptables -L - empty

Adding reqiered rules:

	$iptables -A INPUT -p tcp --dport 22 -j ACCEPT
	$iptables -A INPUT -p tcp --dport 80 -j ACCEPT
	$iptables-save
	$service iptables restart

	Error with Applying firewall rules: iptables-restore v1.4.7: no command specified Error occurred at line: 12
	
	$cat /etc/sysconfig/iptables

Missing line before COMMIT -try to change - fail. Readonly file.
	
    $ls -la /etc/sysconfig/iptables
	$lsattr /etc/sysconfig/iptables
    
Got "i" on iptables
	
    $chattr -i /etc/sysconfig/iptables

Add an empty line after config before COMMIT -save

    $vi /etc/sysconfig/iptables
	$iptables -A INPUT -p tcp --dport 22 -j ACCEPT
	$iptables -A INPUT -p tcp --dport 80 -j ACCEPT
	$iptables-save
	$service iptables restart - ok

##Tomcat is now available through httpd(80).

##Additional questions
1.What java version is installed? $java-version

java version "1.7.0_79"

2.How was it installed and configured?

$yum info java is empty. 

Java was installed manually. By default its configured in JAVA_HOME, if there is no env configs - stored in path set by alternatives path

3.Where are log files of tomcat and httpd?

Tomcat log files stored /opt/apache/tomcat/current/logs

Httpd log files stored /var/logs/httpd/

4.Where is JAVA_HOME and what is it?

Its a variable, it can be set manually by user, for the current session, by program, or specified through alternatives

5.Where is tomcat installed?

Tomcat is installed in /opt/apache/tomcat/7.0.62

6.What is CATALINA_HOME?

Its a location of my tomcat installation

7.What users run httpd and tomcat processes? How is it configured?

Httpd starts from root, tomcat is configured to run from user tomcat using tomcat script.

 -  su - tomcat -c "sh /opt/apache/tomcat//current/bin/startup.sh

8.What configuration files are used to make components work with each other?

Catalina.sh defines how tomcat will be configured. Httpd service is based on httpd.conf, which is widely configurable ,

for example enabling multiple virtual hosts, by including configuration files.

9.What does it mean: “load average: 1.18, 0.95, 0.83”?

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages