Apache System troubleshooting solutions and related operations knowledge
1. Check the Apache service on which port is listening, there are several Apache in the service, its initial PID is how much
Netstat-alop |grep LISTEN |grep httpd
2. View the location of the current Apache PID file from the configuration file
Vi/usr/local/apache/conf/httpd.conf
#
# pidfile:the file in which the server should record its process
# identification number when it starts.
#
<ifmodule!mpm_netware.c>
Pidfile Logs/httpd.pid
</IfModule>
3. View the values of the PID
Cat Httpd.pid
4. Show process category display
Pstree
Pstree-p
-P Show PIDs. PIDs is shown as decimal numbers in parentheses after each process name
If there are other httpd, it proves that there is a dead process and kills the corresponding process.
Kill-9 PID
Killall
5. Sometimes, the log file under logs may be very large, it should be recommended to add the log rotation
Errorlog "|/usr/local/cronolog/src/cronolog/usr/local/szapache/logs/%y/%m/%d/error_log"
Customlog "|/usr/local/cronolog/src/cronolog/usr/local/szapache/logs/%y/%m/%d/access.log" common
Usage of 6.netstat
Netstat-alop
-A,--all Show both listening and non-listening sockets
-L,--listening Show only listening sockets. (these is omitted by default.)
-O,--timers Include information related to networking timers.
-P,--program Show the PID and name of the program to which each socket belongs.
(Do not understand what the timer this column means, did not read off KeepAlive timewait)
Show what port is listening
[Email protected] root]# NETSTAT-TUNL
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address state
TCP 0 0 0.0.0.0:139 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:23 0.0.0.0:* LISTEN
UDP 0 0 192.168.10.224:137 0.0.0.0:*
UDP 0 0 0.0.0.0:137 0.0.0.0:*
UDP 0 0 192.168.10.224:138 0.0.0.0:*
UDP 0 0 0.0.0.0:138 0.0.0.0:*
UDP 0 0 0.0.0.0:928 0.0.0.0:*
/PROC/NET/TCP--TCP socket information
[Email protected] root]# cat/proc/net/tcp
/PROC/NET/UDP--UDP socket information
[Email protected] root]# CAT/PROC/NET/UDP
[[email protected] etc]# Vi/etc/protocols agreement name detailed explanation Protocol-numbers
[[email protected] etc]# vi/etc/services service and port number of the corresponding relationship Port-numbers
7. About AJP12, ajp13
Configure Workers.properties, which specifies the tomcat-defined worker for handling jsp,servlet, with the default definition of two, AJP12 and Ajp13, as follows: WORKER.LIST=AJP12, ajp13. Each worker defines the machine on which it is located, runs the port number, the owning class, and so on.
Configure Uriworkermap.properties File: This file is the context processing for setting up Tomcat environment, the choice of workers, here can set those context with AJP12, and some are handled by AJP13. Such as:
# Mount The servlet context to the AJP12 worker
/servlet/*=ajp12
Indicates that all requests under http://yourserver:8080/servlet/** are handled by the worker Ajp12.
# Mount The examples context to the AJP13 worker
/examples/*=ajp13
Indicates that all requests under http://yourserver:8080/examples/** are handled by the worker ajp13.
################ What is AJP12 #######################
Some people's answers:
It's a port protocol.
Apache forwards requests for Servlets and JSPs to the Java EE server
He's an agreement, and there's a concrete implementation in Jserv.
Apache has a module mod_ ....
He seems to be forwarding requests through this AJP12.
This is his internal realization.
############################ the error message appears ##########################################
[17/01/2007 09:02:48:533] (ERROR) Ajp12:servlet Error:ClassNotFoundException:null
[17/01/2007 09:11:08:470] (ERROR) Ajp12:servlet Error:ClassNotFoundException:null
[17/01/2007 09:14:41:503] (EMERGENCY) Ajp12:can not connect to host 127.0.0.1:11004
[17/01/2007 09:14:41:503] (EMERGENCY) Ajp12:connection fail
[17/01/2007 09:14:41:503] (error) An error returned handling request via protocol "AJPV12"
[17/01/2007 09:14:41:556] (EMERGENCY) Ajp12:can not connect to host 127.0.0.1:11004
##########################################################################################
8. Each tomcat worker is a tomcat instance that serves the Web server and waits for the servlet to execute. For example, we often use Web server such as Apache to forward Sevlet requests to a tomcat process that is behind it (that is, the worker above)
The way to define workers is to write a workers.properties file in Apache's conf directory to make it work as an Apache plugin.
The AJP12 type of worker works by using the TCP/IP socket-based AJPV12 protocol to forward requests to the "out-of-process" Tomcat worker.
Note: In the AJPV12 protocol, a connection is established, used, and closed for each request. Its default listening port is 8007.
The ajp13 type of worker works by using the TCP/IP socket-based AJPV13 protocol to forward requests to the "out-of-process" Tomcat worker.
* Ajpv13 has a richer binary protocol, which compresses the requested data in a way that encodes frequently used strings into small integers.
* Ajpv13 reuse open sockets and retain these open sockets to handle future requests. This is necessary in a network environment with firewalls between Apache and Tomcat.
* Ajpv13 has the ability to handle SSL information so that the container can implement SSL-related methods (such as issecure ()).
Note: AJP13 is currently available only for Tomcat 4.0.x, 4.1.x and 5 that support the out-of-process protocol.
9. Monitor the packets flowing in the Ethernet
[Email protected] etc]# tcpdump-i eth0-nex-s 128
10. View file location by port number
[Email protected] root]# pstree-p
|-oracle (9826)
|-PROFTPD (22884)
|-SSHD (23627)---bash (23640)
Then, go to/proc/22884, view the CmdLine file or want the relevant output to see maps
[email protected] 22884]# cat maps
08048000-08092000 R-xp 00000000 08:06 147482/usr/local/proftp/sbin/proftpd
08092000-0809d000 rw-p 00049000 08:06 147482/usr/local/proftp/sbin/proftpd
0809d000-080d0000 Rwxp 00000000 00:00 0
40000000-40016000 R-xp 00000000 08:02 63889/lib/ld-2.2.4.so
#####################################################
# # #echo "Your-new-kernel-value" >/proc/your/file####
#####################################################
11. How to increase the amount of memory used by the operating system
/proc/sys/kernel/msgmax
This file specifies the maximum length of messages sent from one process to another. Inter-process messaging is done in the kernel's memory and is not swapped to disk, so increasing the value increases the amount of memory used by the operating system.
Default setting: 8192
12. The kernel has a critical condition setting
/proc/sys/kernel/panic
This file indicates the time (in seconds) that the kernel waits before rebooting if "kernel Critical error (Kernel panic)" occurs. 0 (0) seconds The reboot is disabled when a kernel critical error occurs.
Default setting: 0
13. Network interface
/proc/sys/net/core/netdev_max_backlog
This file specifies the maximum number of packets that are allowed to be sent to the queue when the rate at which the interface receives packets is faster than the rate at which the kernel processes these packets.
Default setting: 300
14. Documentation for the Linux proc file system is located at:/usr/src/linux/documentation/filesystems/proc.txt
All parameters of IPv4 and IPv6 are recorded in the kernel source code document. See File/usr/src/linux/documentation/networking/ip-sysctl.txt
15. Note that Apache Customlog and errorlog files increase the log rotation, to ensure that the original is commented out, apachectl configtest detection will not error, but Apache will produce two logs!!
16.jserv of Jserv.log in the wrong
[27/02/2007 15:44:01:749 CST] Timeout for servlet sheall.sh_housesrc_search expired. Probable deadlock. skipping destroy ().
This thing is defined in the source file.
/usr/local/app/apachejserv-1.1.2/src/java/org/apache/jserv/jservservletmanager.java
Servertokens directive
Description: Configure the server HTTP response header
Syntax: Servertokens major| minor| minimal| productonly| os| Full
Default value: Servertokens full
Context: Server Configuration
Status: Core
Module: Core
This directive controls whether the response header field that the server sends back to the client contains information about the server OS type and the module description that was compiled.
Servertokens Prod[uctonly]
The server will send (for example): Server:apache
Servertokens Major
The server will send (for example): SERVER:APACHE/2
Servertokens Minor
The server will send (for example): server:apache/2.0
Servertokens Min[imal]
The server will send (for example): server:apache/2.0.41
Servertokens OS
The server will send (for example): server:apache/2.0.41 (Unix)
Servertokens full (or not specified)
The server sends (for example): server:apache/2.0.41 (Unix) php/4.2.2 mymod/1.2
This setting is applied to the entire server and cannot be enabled or disabled at the management level of the virtual host.
18 Unable to allocate memory
[[email protected] 6]# grep memory Error_log
[Sat 19 18:06:24 2007] [Alert] (12) Cannot allocate memory:apr_thread_create:unable to create worker thread
. Out of Memory
Solaris
# Path=/usr/local/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/ccs/bin
# Export PATH
./configure--prefix=/usr/local/apache2--enable-shared=max
Apache System troubleshooting solutions and related operations knowledge