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

📄 configtuning-rcng.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Using rc under FreeBSD 5.X</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Configuration and Tuning" href="config-tuning.html" /><link rel="PREVIOUS" title="Configuring the cron Utility"href="configtuning-cron.html" /><link rel="NEXT" title="Setting Up Network Interface Cards"href="config-network-setup.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="configtuning-cron.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 11 Configuration and Tuning</td><td width="10%" align="right" valign="bottom"><a href="config-network-setup.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="CONFIGTUNING-RCNG" name="CONFIGTUNING-RCNG">11.7 Using rc underFreeBSD 5.X</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Tom Rhodes.</i> <p>FreeBSD has recently integrated the NetBSD <tt class="FILENAME">rc.d</tt> system forsystem initialization. Users should notice the files listed in the <ttclass="FILENAME">/etc/rc.d</tt> directory. Many of these files are for basic serviceswhich can be controlled with the <var class="OPTION">start</var>, <varclass="OPTION">stop</var>, and <var class="OPTION">restart</var> options. For instance,<ahref="http://www.FreeBSD.org/cgi/man.cgi?query=sshd&sektion=8&manpath=OpenBSD+3.4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">sshd</span>(8)</span></a> can berestarted with the following command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">/etc/rc.d/sshd restart</kbd></pre><p>This procedure is similar for other services. Of course, services are usually startedautomatically as specified in <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=rc.conf&sektion=5"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">rc.conf</span>(5)</span></a>. Forexample, enabling the Network Address Translation daemon at startup is as simple asadding the following line to <tt class="FILENAME">/etc/rc.conf</tt>:</p><pre class="PROGRAMLISTING">natd_enable="YES"</pre><p>If a <var class="OPTION">natd_enable="NO"</var> line is already present, then simplychange the <var class="OPTION">NO</var> to <var class="OPTION">YES</var>. The rc scriptswill automatically load any other dependent services during the next reboot, as describedbelow.</p><p>Since the <tt class="FILENAME">rc.d</tt> system is primarily intended to start/stopservices at system startup/shutdown time, the standard <var class="OPTION">start</var>,<var class="OPTION">stop</var> and <var class="OPTION">restart</var> options will onlyperform their action if the appropriate <tt class="FILENAME">/etc/rc.conf</tt> variablesare set. For instance the above <tt class="COMMAND">sshd restart</tt> command will onlywork if <var class="VARNAME">sshd_enable</var> is set to <var class="OPTION">YES</var> in<tt class="FILENAME">/etc/rc.conf</tt>. To <var class="OPTION">start</var>, <varclass="OPTION">stop</var> or <var class="OPTION">restart</var> a service regardless ofthe settings in <tt class="FILENAME">/etc/rc.conf</tt>, the commands should be prefixedwith ``force''. For instance to restart <tt class="COMMAND">sshd</tt> regardless of thecurrent <tt class="FILENAME">/etc/rc.conf</tt> setting, execute the followingcommand:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">/etc/rc.d/sshd forcerestart</kbd></pre><p>It is easy to check if a service is enabled in <tt class="FILENAME">/etc/rc.conf</tt>by running the appropriate <tt class="FILENAME">rc.d</tt> script with the option <varclass="OPTION">rcvar</var>. Thus, an administrator can check that <ttclass="COMMAND">sshd</tt> is in fact enabled in <tt class="FILENAME">/etc/rc.conf</tt> byrunning:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">/etc/rc.d/sshd rcvar</kbd># sshd$sshd_enable=YES</pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> The second line (<var class="LITERAL"># sshd</var>) is the output fromthe <tt class="COMMAND">sshd</tt> command, not a <tt class="USERNAME">root</tt>console.</p></blockquote></div><p>To determine if a service is running, a <var class="OPTION">status</var> option isavailable. For instance to verify that <tt class="COMMAND">sshd</tt> is actuallystarted:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">/etc/rc.d/sshd status</kbd>sshd is running as pid 433.</pre><p>It is also possible to <var class="OPTION">reload</var> a service. This will attemptto send a signal to an individual service, forcing the service to reload itsconfiguration files. In most cases this means sending the service a <varclass="LITERAL">SIGHUP</var> signal.</p><p>The <b class="APPLICATION">rcNG</b> structure is not only used for network services,it also contributes to most of the system initialization. For instance, consider the <ttclass="FILENAME">bgfsck</tt> file. When this script is executed, it will print out thefollowing message:</p><pre class="SCREEN">Starting background file system checks in 60 seconds.</pre><p>Therefore this file is used for background file system checks, which are done onlyduring system initialization.</p><p>Many system services depend on other services to function properly. For example, NISand other RPC-based services may fail to start until after the <ttclass="COMMAND">rpcbind</tt> (portmapper) service has started. To resolve this issue,information about dependencies and other meta-data is included in the comments at the topof each startup script. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=rcorder&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">rcorder</span>(8)</span></a> program isthen used to parse these comments during system initialization to determine the order inwhich system services should be invoked to satisfy the dependencies. The following wordsmay be included at the top of each startup file:</p><ul><li><p><var class="LITERAL">PROVIDE</var>: Specifies the services this file provides.</p></li><li><p><var class="LITERAL">REQUIRE</var>: Lists services which are required for thisservice. This file will run <span class="emphasis"><i class="EMPHASIS">after</i></span>the specified services.</p></li><li><p><var class="LITERAL">BEFORE</var>: Lists services which depend on this service. Thisfile will run <span class="emphasis"><i class="EMPHASIS">before</i></span> the specifiedservices.</p></li><li><p>KEYWORD: FreeBSD or NetBSD. This is used for *BSD dependent features.</p></li></ul><p>By using this method, an administrator can easily control system services without thehassle of ``runlevels'' like some other <span class="TRADEMARK">UNIX</span>&reg;operating systems.</p><p>Additional information about the FreeBSD 5.X <tt class="FILENAME">rc.d</tt> system canbe found in the <a href="http://www.FreeBSD.org/cgi/man.cgi?query=rc&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">rc</span>(8)</span></a> and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=rc.subr&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">rc.subr</span>(8)</span></a> manualpages.</p></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="configtuning-cron.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="config-network-setup.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Configuring the <tt class="COMMAND">cron</tt>Utility</td><td width="34%" align="center" valign="top"><a href="config-tuning.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Setting Up Network Interface Cards</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting &#60;<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>&#62;.<br />For questions about this documentation, e-mail &#60;<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>&#62;.</small></p></body></html>

⌨️ 快捷键说明

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