<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LinuxByte &#187; Sysctl</title>
	<atom:link href="http://www.linuxbyte.org/tag/sysctl/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxbyte.org</link>
	<description>一个Linux Blog</description>
	<lastBuildDate>Thu, 26 Jan 2012 08:13:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>用Sysctl 调整Linux操作系统的性能</title>
		<link>http://www.linuxbyte.org/sysctl-minihowto.html</link>
		<comments>http://www.linuxbyte.org/sysctl-minihowto.html#comments</comments>
		<pubDate>Tue, 19 Aug 2008 08:52:30 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[精品文档]]></category>
		<category><![CDATA[系统管理]]></category>
		<category><![CDATA[Sysctl]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=222</guid>
		<description><![CDATA[Sysctl是一个允许您改变正在运行中的Linux系统的接口。它包含一些 TCP/IP 堆栈和虚拟内存系统的高级选项，这可以让有经验的管理员提高引人注目的系统性能。用sysctl可以读取设置超过五百个系... ]]></description>
			<content:encoded><![CDATA[<p>Sysctl是一个允许您改变正在运行中的Linux系统的接口。它包含一些 TCP/IP  堆栈和虚拟内存系统的高级选项，这可以让有经验的管理员提高引人注目的系统性能。用sysctl可以读取设置超过五百个系统变量。基于这点，sysctl(8)  提供两个功能：读取和修改系统设置。<br />
<span id="more-222"></span><br />
查看所有可读变量：</p>
<p>% sysctl -a</p>
<p>读一个指定的变量，例如  kern.maxproc：</p>
<p>% sysctl kern.maxproc kern.maxproc:  1044</p>
<p>要设置一个指定的变量，直接用 variable=value 这样的语法：</p>
<p># sysctl  kern.maxfiles=5000</p>
<p>kern.maxfiles: 2088 -&gt;  5000</p>
<p>您可以使用sysctl修改系统变量，也可以通过编辑sysctl.conf文件来修改系统变量。sysctl.conf 看起来很像  rc.conf。它用 variable=value  的形式来设定值。指定的值在系统进入多用户模式之后被设定。并不是所有的变量都可以在这个模式下设定。</p>
<p>sysctl  变量的设置通常是字符串、数字或者布尔型。 (布尔型用 1 来表示&#8217;yes&#8217;，用 0 来表示&#8217;no&#8217;)。</p>
<p>sysctl -w  kernel.sysrq=0</p>
<p>sysctl -w kernel.core_uses_pid=1</p>
<p>sysctl -w  net.ipv4.conf.default.accept_redirects=0</p>
<p>sysctl -w  net.ipv4.conf.default.accept_source_route=0</p>
<p>sysctl -w  net.ipv4.conf.default.rp_filter=1</p>
<p>sysctl -w  net.ipv4.tcp_syncookies=1</p>
<p>sysctl -w  net.ipv4.tcp_max_syn_backlog=2048</p>
<p>sysctl -w  net.ipv4.tcp_fin_timeout=30</p>
<p>sysctl -w  net.ipv4.tcp_synack_retries=2</p>
<p>sysctl -w  net.ipv4.tcp_keepalive_time=3600</p>
<p>sysctl -w  net.ipv4.tcp_window_scaling=1</p>
<p>sysctl -w  net.ipv4.tcp_sack=1</p>
<p>配置sysctl</p>
<p>编辑此文件：</p>
<p>vi  /etc/sysctl.conf</p>
<p>如果该文件为空，则输入以下内容，否则请根据情况自己做调整：</p>
<p># Controls source  route verification</p>
<p># Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.rp_filter = 1</p>
<p>#  net.ipv4.conf.all.rp_filter = 1</p>
<p># net.ipv4.conf.lo.rp_filter = 1</p>
<p>#  net.ipv4.conf.eth0.rp_filter = 1</p>
<p># Disables IP source routing</p>
<p>#  Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.accept_source_route = 0</p>
<p>#  net.ipv4.conf.all.accept_source_route = 0</p>
<p>#  net.ipv4.conf.lo.accept_source_route = 0</p>
<p>#  net.ipv4.conf.eth0.accept_source_route = 0</p>
<p># Controls the System Request  debugging functionality of the kernel</p>
<p>kernel.sysrq = 0</p>
<p># Controls  whether core dumps will append the PID to the core filename.</p>
<p># Useful for  debugging multi-threaded applications.</p>
<p>kernel.core_uses_pid = 1</p>
<p>#  Increase maximum amount of memory allocated to shm</p>
<p># Only uncomment if  needed!</p>
<p># kernel.shmmax = 67108864</p>
<p># Disable ICMP Redirect  Acceptance</p>
<p># Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.accept_redirects = 0</p>
<p>#  net.ipv4.conf.all.accept_redirects = 0</p>
<p>#  net.ipv4.conf.lo.accept_redirects = 0</p>
<p>#  net.ipv4.conf.eth0.accept_redirects = 0</p>
<p># Enable Log Spoofed Packets,  Source Routed Packets, Redirect Packets</p>
<p># Default should work for all  interfaces</p>
<p>net.ipv4.conf.default.log_martians = 1</p>
<p>#  net.ipv4.conf.all.log_martians = 1</p>
<p># net.ipv4.conf.lo.log_martians =  1</p>
<p># net.ipv4.conf.eth0.log_martians = 1</p>
<p># Decrease the time  default value for tcp_fin_timeout connection</p>
<p>net.ipv4.tcp_fin_timeout =  25</p>
<p># Decrease the time default value for tcp_keepalive_time  connection</p>
<p>net.ipv4.tcp_keepalive_time = 1200</p>
<p># Turn on the  tcp_window_scaling</p>
<p>net.ipv4.tcp_window_scaling = 1</p>
<p># Turn on the  tcp_sack</p>
<p>net.ipv4.tcp_sack = 1</p>
<p># tcp_fack should be on because of  sack</p>
<p>net.ipv4.tcp_fack = 1</p>
<p># Turn on the  tcp_timestamps</p>
<p>net.ipv4.tcp_timestamps = 1</p>
<p># Enable TCP SYN Cookie  Protection</p>
<p>net.ipv4.tcp_syncookies = 1</p>
<p># Enable ignoring  broadcasts request</p>
<p>net.ipv4.icmp_echo_ignore_broadcasts = 1</p>
<p>#  Enable bad error message  Protection</p>
<p>net.ipv4.icmp_ignore_bogus_error_responses = 1</p>
<p># Make  more local ports available</p>
<p># net.ipv4.ip_local_port_range = 1024  65000</p>
<p># Set TCP Re-Ordering value in kernel to  ‘5′</p>
<p>net.ipv4.tcp_reordering = 5</p>
<p># Lower syn retry  rates</p>
<p>net.ipv4.tcp_synack_retries = 2</p>
<p>net.ipv4.tcp_syn_retries =  3</p>
<p># Set Max SYN Backlog to ‘2048′</p>
<p>net.ipv4.tcp_max_syn_backlog =  2048</p>
<p># Various Settings</p>
<p>net.core.netdev_max_backlog =  1024</p>
<p># Increase the maximum number of skb-heads to be  cached</p>
<p>net.core.hot_list_length = 256</p>
<p># Increase the tcp-time-wait  buckets pool size</p>
<p>net.ipv4.tcp_max_tw_buckets = 360000</p>
<p># This will  increase the amount of memory available for socket input/output  queues</p>
<p>net.core.rmem_default = 65535</p>
<p>net.core.rmem_max =  8388608</p>
<p>net.ipv4.tcp_rmem = 4096 87380  8388608</p>
<p>net.core.wmem_default = 65535</p>
<p>net.core.wmem_max =  8388608</p>
<p>net.ipv4.tcp_wmem = 4096 65535 8388608</p>
<p>net.ipv4.tcp_mem =  8388608 8388608 8388608</p>
<p>net.core.optmem_max = 40960</p>
<p>如果希望屏蔽别人 ping  你的主机，则加入以下代码：</p>
<p># Disable ping  requests</p>
<p>net.ipv4.icmp_echo_ignore_all =  1</p>
<p>编辑完成后，请执行以下命令使变动立即生效：</p>
<p>/sbin/sysctl -p</p>
<p>/sbin/sysctl -w  net.ipv4.route.flush=1</p>
<h2  class="related_post_title">其他大家爱看的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/tui-jian-liang-ge-neng-zai-linux-xia-kan-de-ying-shi-wang-zhan.html" title="推荐几个能在linux 下看的影视网站">推荐几个能在linux 下看的影视网站</a></li><li><a href="http://www.linuxbyte.org/my-firefox-addons.html" title="我的firefox 插件">我的firefox 插件</a></li><li><a href="http://www.linuxbyte.org/magiclinux-21-rc1.html" title="magiclinux 2.1 rc1 发布">magiclinux 2.1 rc1 发布</a></li><li><a href="http://www.linuxbyte.org/config-apache-mod_limitipconn.html" title="apache 下限制单个IP 的并发连接数">apache 下限制单个IP 的并发连接数</a></li><li><a href="http://www.linuxbyte.org/window-decoration-dekorato-malizie.html" title="推荐一个KDE 主题">推荐一个KDE 主题</a></li><li><a href="http://www.linuxbyte.org/centos-xia-an-zhuang-pei-zhi-powerdns.html" title="Centos 下安装配置 PowerDNS ">Centos 下安装配置 PowerDNS </a></li><li><a href="http://www.linuxbyte.org/firegpg-fei-chang-hao-yong-de-gpg-gong-ju.html" title="FireGPG-非常好用的GPG工具">FireGPG-非常好用的GPG工具</a></li><li><a href="http://www.linuxbyte.org/opensuse-111-alpha-1.html" title="openSUSE 11.1 Alpha 1">openSUSE 11.1 Alpha 1</a></li><li><a href="http://www.linuxbyte.org/ffmpeg-pi-liang-zhuan-huan-jiao-ben.html" title="ffmpeg 批量转换脚本">ffmpeg 批量转换脚本</a></li><li><a href="http://www.linuxbyte.org/apache-license-version-2.html" title="Apache License Version 2.0">Apache License Version 2.0</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2008<br />
Source: <a href="http://www.linuxbyte.org/sysctl-minihowto.html">用Sysctl 调整Linux操作系统的性能</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/sysctl" rel="tag">Sysctl</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/sysctl" title="Sysctl" rel="tag">Sysctl</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/sysctl-minihowto.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

