ÔõÑùÉèÖÃCentOSϵͳÒÔÏÞÖÆÀú³Ì×ÊԴʹÓõÄÇå¾²Õ½ÂÔ
ÔõÑùÉèÖÃcentosϵͳÒÔÏÞÖÆÀú³Ì×ÊԴʹÓõÄÇå¾²Õ½ÂÔ
СÐò:
ÔÚÒ»¸ö¶àÀú³ÌµÄϵͳÖУ¬ºÏÀíÉèÖúÍÏÞÖÆÀú³ÌµÄ×ÊԴʹÓÃÊǺÜÊÇÖ÷ÒªµÄ£¬Ëü¿ÉÒÔ°ü¹ÜϵͳµÄÎȹÌÐÔºÍÇå¾²ÐÔ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃCentOSϵͳÌṩµÄ¹¤¾ßºÍÉèÖÃÎļþ£¬À´ÏÞÖÆÀú³ÌµÄ×ÊԴʹÓ㬲¢ÌṩһЩÊÊÓõĴúÂëʾÀý¡£
µÚÒ»²¿·Ö£ºÉèÖÃÎļþ
CentOSϵͳÌṩÁËһЩÓÃÓÚÉèÖÃϵͳ×ÊÔ´ÏÞÖƵÄÎļþ£¬ËüÃÇ»®·ÖÊÇ£º/etc/security/limits.confºÍ/etc/sysctl.conf¡£
/etc/security/limits.confÎļþ:
limits.confÎļþÓÃÓÚÉèÖÃÓû§»òÓû§×éµÄ×ÊÔ´ÏÞÖÆ£¬ÎÒÃÇ¿ÉÒÔͨ¹ý±à¼Õâ¸öÎļþÀ´ÏÞÖÆÀú³ÌµÄ×ÊԴʹÓá£
·¿ª/etc/security/limits.confÎļþ£¬¿ÉÒÔ¿´µ½ÒÔÏÂʾÀýÄÚÈÝ£º
#<domain> <type> <item> <value> # * soft core 0 * hard rss 10000 * hard nofile 10000 * soft nofile 10000 * hard stack 10000 * soft stack 10000
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬ ¿ÉÒÔÊÇÓû§»òÓû§×éµÄÃû³Æ£¬Ò²¿ÉÒÔÊÇͨÅä·û*£» ÊÇ×ÊÔ´ÏÞÖƵÄÀàÐÍ£» ÊÇ×ÊÔ´µÄÃû³Æ£» ÊÇ×ÊÔ´µÄÏÞÖÆÖµ¡£
ÒÔÏÞÖÆÀú³ÌµÄ·¿ªÎļþÊýΪÀý£¬ÎÒÃÇ¿ÉÒÔÔÚÎļþĩβÌí¼ÓÈçÏÂÉèÖãº
* soft nofile 400 * hard nofile 600
µÇ¼ºó¸´ÖÆ
ÕâÑùÉèÖúó£¬ËùÓÐÓû§µÄÀú³Ì¶¼²»µÃÁè¼Ý400¸ö·¿ªÎļþ£¬²¢ÇÒÁè¼Ý600¸ö·¿ªÎļþµÄÇëÇ󽫱»¾Ü¾ø¡£
/etc/sysctl.confÎļþ:
sysctl.confÎļþÓÃÓÚÉèÖÃÄں˲ÎÊý£¬ÎÒÃÇ¿ÉÒÔͨ¹ý±à¼Õâ¸öÎļþÀ´µ÷½âϵͳµÄ×ÊÔ´ÏÞÖÆ¡£
·¿ª/etc/sysctl.confÎļþ£¬¿ÉÒÔ¿´µ½ÒÔÏÂʾÀýÄÚÈÝ£º
# Kernel sysctl configuration file for Red Hat Linux # Disable source routing and redirects net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.all.send_redirects = 0 # Disable ICMP redirects net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.all.secure_redirects = 0 # Disable IP forwarding net.ipv4.ip_forward = 0
µÇ¼ºó¸´ÖÆ
ÒÔµ÷½âϵͳµÄÄÚ´æÏÞÖÆΪÀý£¬ÎÒÃÇ¿ÉÒÔÔÚÎļþĩβÌí¼ÓÈçÏÂÉèÖãº
# Adjust memory allocation vm.overcommit_memory = 2 vm.swappiness = 10
µÇ¼ºó¸´ÖÆ
ÕâÑùÉèÖúó£¬ÏµÍ³½«Ô½·¢ºÏÀíµØ·ÖÅÉÄÚ´æ×ÊÔ´¡£
µÚ¶þ²¿·Ö£º¹¤¾ßºÍÏÂÁî
³ýÁËÉèÖÃÎļþÖ®Í⣬CentOSϵͳ»¹ÌṩÁËһЩ¹¤¾ßºÍÏÂÁÓÃÓÚ¶¯Ì¬µØÏÞÖÆÀú³ÌµÄ×ÊԴʹÓá£
ulimitÏÂÁî:
ulimitÏÂÁîÓÃÓÚÏÔʾºÍÉèÖÃÓû§Àú³ÌµÄ×ÊÔ´ÏÞÖÆ¡£
ʾÀý1: Éó²éÄ¿½ñÀú³ÌµÄ×ÊÔ´ÏÞÖÆ
ulimit -a
µÇ¼ºó¸´ÖÆ
ʾÀý2: ÉèÖÃÀú³ÌµÄ·¿ªÎļþÊýÏÞÖÆΪ1000
ulimit -n 1000
µÇ¼ºó¸´ÖÆ
sysctlÏÂÁî:
sysctlÏÂÁîÓÃÓÚÏÔʾºÍÉèÖÃÄں˲ÎÊý¡£
ʾÀý1: Éó²éÄ¿½ñÄں˲ÎÊý
sysctl -a
µÇ¼ºó¸´ÖÆ
ʾÀý2: ÉèÖÃÄں˲ÎÊývm.swappinessΪ10
sysctl -w vm.swappiness=10
µÇ¼ºó¸´ÖÆ
µÚÈý²¿·Ö£ºÊÊÓõĴúÂëʾÀý
ÒÔÏÂÊÇһЩÔÚCentOSϵͳÉÏÏÞÖÆÀú³Ì×ÊԴʹÓõÄÊÊÓôúÂëʾÀý¡£
ÏÞÖÆÀú³ÌµÄ·¿ªÎļþÊý
soft nofile 400
hard nofile 600
ÈôÒѾµÇ¼µÄÓû§ÐèÒªÁ¬Ã¦»ñµÃеÄÉèÖã¬ÇëÖ´ÐÐÒÔÏÂÏÂÁî
ulimit -n 400
ÏÞÖÆÀú³ÌµÄÄÚ´æʹÓÃ
# Ìí¼ÓÒÔÏÂÉèÖõ½/etc/sysctl.confÎļþĩβ # Adjust memory allocation vm.overcommit_memory = 2 vm.swappiness = 10 # ÈôÐèÒªÁ¬Ã¦ÉúЧ£¬ÇëÖ´ÐÐÒÔÏÂÏÂÁî sysctl -p
µÇ¼ºó¸´ÖÆ
½áÂÛ£º
ͨ¹ýÉèÖÃÎļþºÍÏÂÁîÀ´ÏÞÖÆCentOSϵͳÖÐÀú³ÌµÄ×ÊԴʹÓã¬ÓÐÖúÓÚÌá¸ßϵͳµÄÎȹÌÐÔºÍÇå¾²ÐÔ¡£Í¬Ê±£¬ÎÒÃÇ»¹ÌṩÁËһЩÊÊÓõĴúÂëʾÀý×÷Ϊ²Î¿¼¡£Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú£¬×£ÄúµÄϵͳÔËÐÐ˳Ëì¡£
ÒÔÉϾÍÊÇÔõÑùÉèÖÃCentOSϵͳÒÔÏÞÖÆÀú³Ì×ÊԴʹÓõÄÇå¾²Õ½ÂÔµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡