⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asg11.htm

📁 apache技术手册
💻 HTM
📖 第 1 页 / 共 4 页
字号:

<BR>

<A NAME="E68E140"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Upgrading the Server</B></FONT></CENTER></H3>

<BR>

<P>Upgrades are always a cause for concern in production environments. The overall strategy should be to install any new versions of the server in a test environment prior to putting the server into production. Always read the distribution documentation to see if some behavior has changed from previous versions.

<BR>

<BR>

<A NAME="E69E131"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Keeping the Old Server Around</B></FONT></CENTER></H4>

<BR>

<P>To be on the safe side, you should keep an old version of the server on hand just in case the new one causes some problems. An easy way to do this is to install the new server after you rename the old one to httpd.old, and restart the server. If you discover any problems, you can quickly put the old server back online by renaming httpd.old to httpd and restarting the server again.

<BR>

<BR>

<A NAME="E68E141"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Making Sure It Is All Running</B></FONT></CENTER></H3>

<BR>

<P>One of the biggest concerns you'll have is making sure that your machines are working correctly. Automated periodic testing of your site can help you ensure that it is accessible. A good setup has internal and external testing systems.

<BR>

<P>The best type of testing is actually the type that you don't have to do. For a small fee, some companies monitor your site every few minutes. If there's a problem, they call your beeper and inform you that something is afoot. They even go so far as making sure that your Web page is accessible. One such service can be found at <A HREF="javascript:if(confirm('http://www.redalert.com/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.redalert.com/'" tppabs="http://www.redalert.com/"> http://www.redalert.com</A>.

<BR>

<P>Having an external source test the accessibility of your Web site is a great idea because it confirms to your customers that users are able to access your site. You will know within a reasonable amount of time if your network becomes unreachable because of a problem with your provider.

<BR>

<BR>

<A NAME="E69E132"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Monitoring Your Hosts and Network Interfaces</B></FONT></CENTER></H4>

<BR>

<P>The easiest way for you to test whether your server is reachable is to use the ping command. The ping command will send an ECHO_REQUEST datagram to a host or network interface. On reception, the packet is returned with an ECHO_RESPONSE datagram. While this test does not verify that your server is operating correctly, it does verify that the networking portion of it is reachable.

<BR>

<P>The format of the command is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">/etc/ping <I>ipaddress</I> <I>packetsize</I> <I>pingcount</I></FONT></PRE>

<P>Typically, you will want to use the ping command to send a datagram to the host to verify that your network interface is running. Once this is verified, you can start test from other hosts and gateways farther away.

<BR>

<BR>

<A NAME="E69E133"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Monitoring H TTP: </B><B>httpd_Monitor</B><B> </B><B>and the Status Module</B></FONT></CENTER></H4>

<BR>

<P>When you monitor HTTP, you ensure that the server is running and you assess its current load. Apache has implemented a series of child processes that are semipersistent. Unlike some servers, which fork a new server process with each request and then kill off the new process as the request is satisfied, Apache implements a system that tracks all idle and busy server processes. If more server processes are needed, it creates more to handle the load (up to a limit). If the count of idle server processes exceeds a certain amount, the extra httpd processes are killed. This avoids a condition in which too many server processes compete for resources and effectively kill the machine. If the machine starts swapping, it becomes unusable and it is brought to its knees.

<BR>

<P>Apache's server implementation makes it harder to ascertain the current status of the server. To circumvent this problem, Apache has implemented a scoreboard status file. The scoreboard file allows all the various server processes to write status information on a designated portion of a file. A special program, httpd_monitor, located in the support subdirectory of the Apache distribution, is able to read the scoreboard file and display information regarding the server:

<BR>

<PRE>

<FONT COLOR="#000080">Usage: httpd_monitor [<I>-d config-dir</I>] [<I>-s sleep-time</I>]

Defaults: config-dir: /usr/local/etc/httpd/

 sleep-time: 2 seconds</FONT></PRE>

<P>Here's a sample run on a quiet server:

<BR>

<PRE>

<FONT COLOR="#000080">% httpd_monitor

sssss (0/5)</FONT></PRE>

<P>httpd_monitor displays the status of all child processes and whether they are sleeping (s), starting (t), active (R) or dead (_). In the preceding example, there are five processes, all of them sleeping.

<BR>

<P><A NAME="I19"></A><A NAME="I20"></A><A NAME="I21"></A><A NAME="I22"></A><A NAME="I23"></A><A NAME="I24"></A>If you are running version 1.1 or better, there's a easier way of obtaining server status information. The status_module shipped with Apache can display a nice HTML report that you can access with a browser.

<BR>

<P>To enable this module, just uncomment the following line from your src/Configuration file:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">Module status_module mod_status.o</FONT></PRE>

<P>For more descriptive status reports, also add the -DSTATUS flag to the CFLAGS section near the start of the file. Build and install the new version of Apache by issuing the following commands:

<BR>

<PRE>

<FONT COLOR="#000080">cd /usr/local/etc/httpd/src

./Configure

make

strip httpd

mv httpd ../</FONT></PRE>

<P>In addition to building the new program, you'll have to edit your conf/access.conf file and add an entry like this one:

<BR>

<PRE>

<FONT COLOR="#000080">&lt;Location /status&gt;

SetHandler server-status

order deny,allow

deny from all

allow from <I>yourdomain</I>

&lt;/Location&gt;</FONT></PRE>

<P>Change <I>yourdomain</I> to your Internet domain. As you should be able to tell from this configuration, the server will only supply status information to requests that originate within your domain name. Once the server is restarted, a request for the for /status on your server (http://www/status) will return a nicely formatted report.

<P>
<a href="javascript:if(confirm('http://docs.rinet.ru:8080/Apachu/11asg01.gif  \n\nThis file was not retrieved by Teleport Pro, because it was redirected to an invalid location.  You should report this problem to the site\'s webmaster.  \n\nDo you want to open it from the server?'))window.location='http://docs.rinet.ru:8080/Apachu/11asg01.gif'" tppabs="http://docs.rinet.ru:8080/Apachu/11asg01.gif"><B>Fig. 11.1 <I>A server status report generated by the</I> staus_module.</B></A>

<P>You can have the status information (produced by the status_module) updated every few seconds by calling typing 

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">http://your.server.name/status/?refresh=<I>N</I></FONT></PRE>

<P>Replace <I>N</I> with the number of seconds between updates.

<BR>

<P>In addition, you can access a machine-readable ASCII version of the report by requesting:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">http://your.server.name/status/?auto</FONT></PRE>

<BR>

<A NAME="E69E134"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Monitoring</B><B> Your Name Server</B></FONT></CENTER></H4>

<BR>

<P>The Berkeley Internet Name Domain (BIND) system includes a utility called name daemon control (ndc) interface, which allows you to easily send various signals to the name server. It also allows you to start, restart, or stop the name server. Even better, it allows you to display many status settings, as well as display cache and query log information. For extensive information on what a name server does, see <A HREF="asgxe.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asgxe.htm">Appendix E</A>, &quot;DNS and BIND Primer.&quot;

<BR>

<P>To check if your name server is running, just enter the following commands on a shell:

<BR>

<PRE>

<FONT COLOR="#000080">% ndc status

3170 ? SW 0:00 named</FONT></PRE>

<P>This displays a short line with process-status information.

<BR>

<P>From this line I know that my process is running, sleeping, and swapped out of memory. For more information on what this output means, check out the man page for ps.

<BR>

<P>If your server was not running, it would display a line such as this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">named (no pid file) not running</FONT></PRE>

<P>or this:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">named (pid 3262?) not running</FONT></PRE>

<P>A better way to monitor the name server is to look at the logfiles. named uses the syslog facility to log problems. To see where syslog logs named messages, run this command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">grep daemon /etc/syslog.conf</FONT></PRE>

<P>Check the lines that contain named. An easy way to do this is to do a grep on named. It should be obvious when the problem is due to an incorrectly defined dbfile because named should echo a descriptive message to this effect. It is important to look for these errors because some of them may lead to your server stopping. An unreachable message can result in a secondary name server declaring that the data is stale and refusing to serve it. malformed type errors usually mean that some server provided a malformed response.

<BR>

<BR>

<A NAME="E70E135"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Dealing with DNS Outages</B></FONT></CENTER></H5>

<BR>

<P>The worst thing that could happen (besides your processor catching fire) is that your domain name server stops running. If the DNS goes, your network grinds to a halt. External users will be unable to reach it, and internal users will be unable contact external resources.

<BR>

<P>There are several solutions to this problem:

<BR>

<UL>

<LI>Make sure that you have at least two DNS servers running. If your preferred DNS machine fails, each new request to your site will time-out for 4 seconds. After 4 seconds, DNS servers that you listed as alternatives for your site will be queried for the information. However, this will only work for a certain amount of time. After a while, if the only server running is not a primary server, the information will be declared stale, and the secondary server will refuse to serving it.

<BR>

<BR>

<LI>One way to ensure that your DNS is always running is to have several servers. Some of the servers should be in your local network; others should be in a completely different network.

<BR>

<BR>

<LI>DNS servers should also be located in stable and protected environments; do not trust prerelease software unless you know it is stable for both named and your operating system. Protect your server against power outages and other similar problems.

<BR>

<BR>

</UL>

<BR>

<A NAME="E68E142"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>

<BR>

<P>This chapter covers some basic system administration points as they relate to the management of your Web site. Preventive action in terms of backups and the monitoring of processes and resources signal issues before they become a problem. The tools covered in this chapter are universally available to most unices. Commercial products are also available that address network monitoring. However, these tools are costly; some of the most popular tools cost thousands of dollars.

<BR>

<P>An inexpensive, efficient way to automate the generation of the server and network status information is by having a Web page that summarizes the information from the commands described in this chapter. When used under cron, you can ensure systematic testing of the various systems.<A NAME="I25"></A>

<BR>

<P ALIGN=LEFT>

<A HREF="asgpt4.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asgpt4.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>

<A HREF="index.htm" tppabs="http://docs.rinet.ru:8080/Apachu/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="asg12.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asg12.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


</BODY></HTML>





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -