以åãä¸åº¦ãã£ãã¯ããªã®ã§ããããã£ããå¿ãã¦ãã¾ã£ã¦ãã¦ãçµå±èª¿ã¹ããã¨ã«ãªã£ãã®ã§ãä»åã¯ããã«ä½æ¥ãã°ãæ®ãã¦ããã¾ãã
TIME_WAITã³ãã¯ã·ã§ã³ã®å¢æ®
ä¸è¬çã«ãããã¯ã¼ã¯ã¢ã¯ã»ã¹æ°ã極端ã«å¤ããµã¼ãã§ã¯ãTIME_WAITç¶æ
ã®ã³ãã¯ã·ã§ã³ãæ®çããã¡ã§ãã
TIME_WAITã®æ»çæéããLinuxããã©ã ã¨60ç§ã«ãªã£ã¦ãããããä¸è¨ã®ã¨ã³ããªã«ãæ¸ãã¾ãããã60ç§ã®éã«æ°åä¸ã¬ãã«ã®ãªã¯ã¨ã¹ããæ¥ãã¨ãã£ã¨ããéã«ã³ãã¯ã·ã§ã³ãã¼ãã«ãåã¾ã£ã¦ãã£ã¦ãã¾ãããã§ãã
ã§ãå¥ã«TIME_WAITã³ãã¯ã·ã§ã³ãå¤ããªã£ã¦ãã¾ããã¨èªä½ã¯ãå®å
¨ãªæªã¨ããããã§ããªãã "net.ipv4.tcp_max_tw_buckets" ãããã§ãã£ãããã§ãããããããªãã«å¶å¾¡ãã¦ä»ãåã£ã¦ããã°ããããã§ããããã¼ã«ã«ã®TCPãã¼ãã使ãåããããªã±ã¼ã¹ã ã¨ã使ãããã¼ã«ã«ãã¼ãã¬ã³ã¸ã¯éããã¦ããã®ã§å°ã£ãããããã¿ã¼ã³ãããã¾ãã
ããããã°æãâã®ã¨ã³ããªã®ãããªç¶æ³ã«åºãããã¦ããã®æã¯è«¸äºæ
ã§(NATãã¦ããæ§æã§ã¯ãªãã£ãã®ã§) "net.ipv4.tcp_tw_recycle" ãè¨å®ãããã¨ã§ãTIME_WAITã¨ãªã£ãTCPã³ãã¯ã·ã§ã³ãåå©ç¨ãããã¨ã§äºãªããå¾ãã®ã§ãããä»åã¯æ¤è¨¼ã®é½åä¸ãLinux Kernelããã«ããã¦ãTIME_WAITã®ã³ãã¯ã·ã§ã³ã解æ¾ãããæé(ããã©ã«ã: 60ç§)ãçããã¦ã¿ã¾ãã
OS(ä»åã®ç°å¢ä¾)
ä»å使ã£ãæ¤è¨¼ç°å¢ã§ã®ãµã¼ãã®OSã¯ãLinuxã®CentOS 6.4ã§ããã
# cat /proc/version Linux version 2.6.32-358.23.2.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Wed Oct 16 18:37:12 UTC 2013
ãããªæãã
ã«ã¼ãã«ã®ã½ã¼ã¹ããã±ã¼ã¸ãã²ãããã
ãã£ããCentOSã使ã£ã¦ãããã¨ããã£ã¦ãå ¬éããã¦ããã«ã¼ãã«ã®ã½ã¼ã¹ããã±ã¼ã¸ãåå¾ãã¾ãã
ä¸è¨ãµã¤ãããã該å½ãããã¼ã¸ã§ã³ã®ãªãªã¼ã¹ãã¼ããèªãã¨ãã½ã¼ã¹ããã±ã¼ã¸ã®è¨è¼å ´æãæ¸ãã¦ããã¾ãã®ã§ããããããã¦ã³ãã¼ããã¾ãããã
CentOS 6.4ã ã¨ã以ä¸ã®ãªãªã¼ã¹ãã¼ãç®æã«æ¸ãã¦ããã¾ãã
以ä¸ã®Updateãªãã¸ããªããããããèªåã®ã«ã¼ãã«ãã¼ã¸ã§ã³ã¨ä¸è´ãã¦ããã½ã¼ã¹ããã±ã¼ã¸ãå ¥æãã¾ãã
ä»åã®ä¾ã ã¨ãâã®éã "/proc/version" ã§Kernelã®ãã¼ã¸ã§ã³ã "2.6.32-358.23.2.el6.x86_64" ã¨ãããã¾ãã®ã§ã以ä¸ã³ãã³ãã¿ãããªæãã§ãã¦ã³ãã¼ããã¦å±éãã¾ãã
# wget http://vault.centos.org/6.4/updates/Source/SPackages/kernel-2.6.32-358.23.2.el6.src.rpm # rpm -ivh kernel-2.6.32-358.23.2.el6.src.rpm
Kernelã®ã½ã¼ã¹ã³ã¼ããã¡ããã£ã¨ä¿®æ£
æ¬æ¥ã§ããã°ããã¡ãã¨ããã(patch)ãä½æãã¹ããªã®ã§ãããä»åã¯æ¤è¨¼ãç®çã ã£ããã¨ããã£ã¦(é¢åãããã®ã§)ãtarballãå±éãã¦ç´æ¥å¤æ´ãå ãããã¨ã«ãã¾ãããã
# cd ~/rpmbuild/SOURCES/ # cp linux-2.6.32-358.23.2.el6.tar.bz2 /tmp
ã½ã¼ã¹ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããã¨ã"~/rpmbuild/SOURCES/"ã«tarãã¡ã¤ã«ãå±éãããã®ã§ãããã/tmpã«ã³ãã¼ãã¡ããã¾ãã
# cd /tmp # tar xjvf linux-2.6.32-358.23.2.el6.tar.bz2
/tmpã«ç§»åãã¦å±éã
mv linux-2.6.32-358.23.2.el6 linux-2.6.32-358.23.3.namibuild.el6
ãã£ã¬ã¯ããªãã¡ã¤ã«åãé©å½ã«å¤ãã¦ã¿ã¾ããã
(æ´æ°çªå·ãã¤ã³ã¯ãªã¡ã³ããã¦ãéè¯ãã«ãããã®ã§é©å½ã«æååããã£ã¤ãã¾ããã)
cd linux-2.6.32-358.23.3.namibuild.el6
ã«ã¬ã³ããã£ã¬ã¯ããªãå¤ãã¦ã以ä¸ã®ãããªæãã§ãã¡ã¤ã«ãä¿®æ£ã
# diff -c Makefile{.bak,} *** Makefile.bak 2013-11-19 16:56:31.272668572 +0900 --- Makefile 2013-11-19 16:57:03.889668546 +0900 *************** *** 1,7 **** VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 32 ! EXTRAVERSION = NAME = Man-Eating Seals of Antiquity RHEL_MAJOR = 6 RHEL_MINOR = 4 --- 1,7 ---- VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 32 ! EXTRAVERSION = -358.23.3.namibuild.el6.x86_64 NAME = Man-Eating Seals of Antiquity RHEL_MAJOR = 6 RHEL_MINOR = 4
# diff -c include/net/tcp.h{.bak,} *** include/net/tcp.h.bak 2013-11-19 16:59:19.386668435 +0900 --- include/net/tcp.h 2013-11-19 16:59:38.649668421 +0900 *************** *** 111,118 **** */ ! #define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT ! * state, about 60 seconds */ #define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN /* BSD style FIN_WAIT2 deadlock breaker. * It used to be 3min, new value is 60sec, --- 111,118 ---- */ ! #define TCP_TIMEWAIT_LEN (2*HZ) /* how long to wait to destroy TIME-WAIT ! * state, about 2 seconds */ #define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN /* BSD style FIN_WAIT2 deadlock breaker. * It used to be 3min, new value is 60sec,
ä¸è¨2ãã¡ã¤ã«ã§ããã"include/net/tcp.h"ã®"TCP_TIMEWAIT_LEN"ã®å¤æ°ããä»åå¤æ´ãå ããã該å½ç®æã«ãªãã¾ãã
è¨å®å¤ã¯ãã±ã¼ã¹ã«å¿ãã¦åå³ãã¹ãã§ãããä»åã¯âã®å¦ããæ¤è¨¼å
容çã«2ç§ã«ãã¾ããã(çãï½)
# cd .. # tar cjvf linux-2.6.32-358.23.3.namibuild.el6.tar.bz2 linux-2.6.32-358.23.3.namibuild.el6
ä¿®æ£å¾ãåºããªããã¦ããã
# cp linux-2.6.32-358.23.3.namibuild.el6.tar.bz2 ~/rpmbuild/SOURCES/
åºããtarãã¡ã¤ã«ã "~/rpmbuild/SOURCES/" ã«ã³ãã¼ãã¾ãã
# cd ~/rpmbuild/SPECS/ # diff -c kernel.spec{.bak,} *** kernel.spec.bak 2013-11-19 17:02:26.605668280 +0900 --- kernel.spec 2013-11-19 17:03:02.633668255 +0900 *************** *** 19,25 **** %define rhel 1 %if %{rhel} ! %define distro_build 358.23.2 %define signmodules 1 %else # fedora_build defines which build revision of this kernel version we're --- 19,25 ---- %define rhel 1 %if %{rhel} ! %define distro_build 358.23.3.namibuild %define signmodules 1 %else # fedora_build defines which build revision of this kernel version we're *************** *** 171,177 **** %endif # The kernel tarball/base version ! %define kversion 2.6.32-358.23.2.el6 %define make_target bzImage --- 171,177 ---- %endif # The kernel tarball/base version ! %define kversion 2.6.32-358.23.3.namibuild.el6 %define make_target bzImage *************** *** 562,568 **** %define strip_cmd strip %endif ! Source0: linux-2.6.32-358.23.2.el6.tar.bz2 Source1: Makefile.common --- 562,568 ---- %define strip_cmd strip %endif ! Source0: linux-2.6.32-358.23.3.namibuild.el6.tar.bz2 Source1: Makefile.common
æ´æ°çªå·ã¨ããå¤æ´ãã¦ããã®ã§ãä¸è¨ã®ãããªæãã§ãspecãã¡ã¤ã«ãä¿®æ£ã
ããã¾ã§ã§ãä¿®æ£ä½æ¥ã¯çµããã§ãã次ã¯ãã«ãã§ãããã¾ãã
ç¬èªã«ã¼ãã«ããã«ããã
ãã¦ããã«ããã¹ãrpmbuildã³ãã³ããå®è¡ããã¨ããã
# rpmbuild -ba kernel.spec ã¨ã©ã¼: ãã«ãä¾åæ§ã®å¤±æ: redhat-rpm-config 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã patchutils 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã xmlto 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã asciidoc 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã binutils-devel 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã newt-devel 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã python-devel 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã perl(ExtUtils::Embed) 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã bison 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã flex 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã hmaccalc 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã
ä¾åé¢ä¿ã§è«¸ã
足ããªãããã±ã¼ã¸ãææãããã®ã§ããã
yum -y install redhat-rpm-config patchutils xmlto asciidoc binutils-devel newt-devel python-devel perl-ExtUtils-Embed bison flex hmaccalc
yumã§ã¤ã³ã¹ãã¼ã«ã
# rpmbuild -ba kernel.spec
ã§ãåãã«ãã
å®è¡ãã·ã³ã«ãããã¾ãããã«ã¼ãã«ã®ãã«ãã¯çµæ§æéããããã¾ãã®ã§ãæ°é·ã«å¾
ã¡ã¾ãããã
gpg: keyring ...ã®ã¨ããããé²ã¾ãªã
ã²ãã£ã¨ãããã以ä¸ã®ç®æã§å¦çãå
¨ç¶ããã¾ãªããªãããããã¾ããã
### ### Now generating a PGP key pair to be used for signing modules. ### ### If this takes a long time, you might wish to run rngd in the background to ### keep the supply of entropy topped up. It needs to be run as root, and ### should use a hardware random number generator if one is available, eg: ### ### rngd -r /dev/hwrandom ### ### If one isn't available, the pseudo-random number generator can be used: ### ### rngd -r /dev/urandom ### + gpg --homedir . --batch --gen-key /root/rpmbuild/SOURCES/genkey gpg: WARNING: unsafe permissions on homedir `.' gpg: keyring `./secring.gpg' created gpg: keyring `./pubring.gpg' created
ãããªæã¯ã§ãããå¥ã·ã§ã«(ã¿ã¼ããã«)ãç«ã¡ä¸ãã¦ããã
# rngd -r /dev/urandom
ä¸è¨ã³ãã³ããå®è¡ãã¦entropyãä¾çµ¦ã
# rngd -r /dev/urandom -bash: rngd: ã³ãã³ããè¦ã¤ããã¾ãã
ãããã³ãã³ãããªããã£ã¦åºåãããã¨ãã¯ããã
# yum -y install rng-tools # rngd -r /dev/urandom
ã¤ã³ã¹ãã¼ã«ãã¦åå®è¡ãã¦ã¿ã¾ãããã
ãã«ããçµãã£ããã¤ã³ã¹ãã¼ã«ãããã ã
ãã«ããçµããã¨ã"~/rpmbuild/RPMS/x86_64/"ã«rpmä¸å¼ãåºæ¥ã¦ããã¯ãã§ãã
# cd ../RPMS/x86_64/ # rpm -Uvh kernel-2.6.32-358.23.3.namibuild.el6.x86_64.rpm kernel-devel-2.6.32-358.23.3.namibuild.el6.x86_64.rpm kernel-headers-2.6.32-358.23.3.namibuild.el6.x86_64.rpm ã¨ã©ã¼: ä¾åæ§ã®æ¬ å¦: kernel-firmware >= 2.6.32-358.23.3.namibuild.el6 㯠kernel-2.6.32-358.23.3.namibuild.el6.x86_64 ã«å¿ è¦ã¨ããã¦ãã¾ã
ãªã®ã§ããããªæãã§ã¤ã³ã¹ãã¼ã«ãããã¨ãããã"kernel-firmware"ããªããã¨(TT)
# cd ../../SPECS/ # rpmbuild -bb --with firmware kernel.spec
ã¨ããããã§ãåãã«ãããã°ãå¾
ã¤ã(è¦ããã«ãæåããâã®ã³ãã³ããå®è¡ããã¨è¯ãã§ãããã)
# cd ../RPMS/x86_64/ # rpm -Uvh kernel-2.6.32-358.23.3.namibuild.el6.x86_64.rpm kernel-devel-2.6.32-358.23.3.namibuild.el6.x86_64.rpm kernel-headers-2.6.32-358.23.3.namibuild.el6.x86_64.rpm kernel-firmware-2.6.32-358.23.3.namibuild.el6.x86_64.rpm æºåä¸... ########################################### [100%] 1:kernel-firmware ########################################### [ 25%] 2:kernel ########################################### [ 50%] 3:kernel-headers ########################################### [ 75%] 4:kernel-devel ########################################### [100%]
ãã¦ããã£ã¨ããç¬èªãã«ãããã«ã¼ãã«ãã¤ã³ã¹ãã¼ã«ã§ãã¾ããã
ã¨ããã¨ããã§ãOSãåèµ·åãã¾ãã
# cat /proc/version Linux version 2.6.32-358.23.3.namibuild.el6.x86_64 (root@haproxy-test01) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue Nov 19 17:35:29 JST 2013
åèµ·åå¾ãã¡ããã¨èµ·åãã¦ãã¦ãç¬èªã«ã¼ãã«ã«å¤ãã£ã¦ããã°OKã§ãã
åä½ç¢ºèª
ã¯ã©ã¤ã¢ã³ãããé©å½ã«æ¥ç¶è¦æ±ãã¾ãã£ã¦ãã©ããªã£ããã netstat ã§ç¢ºèªãã¦ã¿ã¾ãã
Before...
# netstat -anpto ã»ã»ã»ã»ã»çç¥ã»ã»ã»ã»ã» tcp 0 0 10.50.1.62:80 10.33.56.163:47769 TIME_WAIT - timewait (8.40/0/0) tcp 0 0 10.50.1.62:80 10.33.56.171:4649 TIME_WAIT - timewait (9.04/0/0) tcp 0 0 10.50.1.62:80 10.33.56.111:11322 TIME_WAIT - timewait (0.00/0/0) tcp 0 0 10.50.1.62:80 10.33.56.189:42672 TIME_WAIT - timewait (25.83/0/0) tcp 0 0 10.50.1.62:80 10.33.56.151:1175 TIME_WAIT - timewait (38.93/0/0) tcp 0 0 10.50.1.62:80 10.33.56.190:12461 TIME_WAIT - timewait (25.89/0/0) tcp 0 0 10.50.1.62:80 10.33.56.61:2089 TIME_WAIT - timewait (26.19/0/0) tcp 0 0 10.50.1.62:80 10.33.56.45:23837 TIME_WAIT - timewait (25.44/0/0) tcp 0 0 10.50.1.62:80 10.33.56.59:30782 TIME_WAIT - timewait (40.56/0/0) tcp 0 0 10.50.1.62:80 10.33.56.167:61432 TIME_WAIT - timewait (53.22/0/0) ã»ã»ã»ã»ã»çç¥ã»ã»ã»ã»ã»
After!!!
# netstat -anpto ã»ã»ã»ã»ã»çç¥ã»ã»ã»ã»ã» tcp 0 0 10.50.1.62:80 10.33.56.85:48327 TIME_WAIT - timewait (0.71/0/0) tcp 0 0 10.50.1.62:80 10.33.56.55:37193 TIME_WAIT - timewait (0.18/0/0) tcp 0 0 10.50.1.62:80 10.33.56.41:28099 TIME_WAIT - timewait (0.34/0/0) tcp 0 0 10.50.1.62:80 10.33.56.33:2009 TIME_WAIT - timewait (0.04/0/0) tcp 0 0 10.50.1.62:80 10.33.56.76:15310 TIME_WAIT - timewait (0.38/0/0) tcp 0 0 10.50.1.62:80 10.33.56.15:41482 TIME_WAIT - timewait (0.17/0/0) tcp 0 0 10.50.1.62:80 10.33.56.34:39958 TIME_WAIT - timewait (1.76/0/0) tcp 0 0 10.50.1.62:80 10.33.56.97:36784 TIME_WAIT - timewait (0.89/0/0) tcp 0 0 10.50.1.62:80 10.33.56.74:53628 TIME_WAIT - timewait (1.95/0/0) tcp 0 0 10.50.1.62:80 10.33.56.94:5927 TIME_WAIT - timewait (0.82/0/0) ã»ã»ã»ã»ã»çç¥ã»ã»ã»ã»ã»
ä¸è¨ã®éãã§ãããBeforeã§ã¯53ç§ã¨ãæ»çãã¦ããã³ãã¯ã·ã§ã³ãããã¾ããããAfterã§ã¯è¨å®ãã2ç§ä»¥å ã«ããã¾ã£ã¦ãã¾ãã
ã¨ãç°¡åã§ã¯ããã¾ããããããªæãã§TIME_WAITã³ãã¯ã·ã§ã³ã®æ°ãæ¸ãããã¨ãã§ãã¾ããã
ããã§ã¯ï¼=͟͟͞͞(๑•̀=͟͟͞͞(๑•̀д•́=͟͟͞͞(๑•̀д•́๑)=͟͟͞͞(๑•̀д•́
詳解 Linuxã«ã¼ã㫠第3ç
- ä½è : Daniel P. Bovet,Marco Cesati,é«æ©æµ©å,æç°ç±ç¾å,æ¸ æ°´æ£æ,é«ææç£,å¹³æ¾é å·³,å®äºéå®
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã»ã¸ã£ãã³
- çºå£²æ¥: 2007/02/26
- ã¡ãã£ã¢: 大åæ¬
- è³¼å ¥: 9人 ã¯ãªãã¯: 269å
- ãã®ååãå«ãããã° (73件) ãè¦ã