Linuxシステムカーネルパフォーマンスのチューニング
5254 ワード
https://blog.csdn.net/hexieshangwang/article/details/47253241
ulimit -n 655350
ulimit -n
Linuxプラットフォームの性能テストをした子供靴は、通常、1、TCPポート番号が足りないため、同時接続ができない(サーバ側との新しい接続に失敗した)2、TIME_WAIT状態の接続が多すぎると、アプリケーションサーバ(Nginx、Haproxy、Redis、Tomcatなど)の性能低下や仮死など、システムカーネルパラメータを最適化することで、Linuxプラットフォーム1、添付ファイル1のsysctlを最適化することができる.confファイルはシステム内の/etc/sysctlを置換または変更する.conf意味:(1)システム最大オープンファイル記述子数制限(システムレベル)(2)システムネットワーク負荷の向上2、コマンド「sysctl-p/etc/sysctl.conf」を使用してステップ1修正有効備考:error:「net.bridge.bridge-nf-call-ip 6 tables」is an unknown key解決方法 1 2
3、修正/etc/security/limits.conf、次の内容を追加します. 1 2
意味:プロセス最大オープンファイル記述子数制限(ユーザーレベル)4、サーバに再ログインして、ステップ3で有効なコメントを変更します:(1)変更中に注意してください.a.すべてのプロセスで開いているファイル記述子の数は/proc/sys/fs/file-maxを超えてはいけません.単一のプロセスで開いているファイル記述子の数はuser limitのnofileのsoft limit c.nofileのsoft limitを超えてはいけません.hard limit d.nofileのhard limitを超えてはいけません./proc/sys/fs/nr_を超えてはいけません.open (2)/etc/security/limits.confの中でファイルの記述子の数を修正して、アカウントを持っていくことを提案して、*号はすべてのアカウントを代表しました!1)kdxfが運行する口座を新設する(一般的にroot口座を使用しない;ネットの安全のために一般的にroot口座の直接登録権限を無効にし、一般口座から登録してからrootに切り替える必要がある)2)LinuxシステムSELINUXとファイアウォールを閉鎖する(オペレーティングシステムを再起動する必要があり、SELINUXセキュリティシステムの制御が厳しすぎて、プロセスアクセスオペレーティングシステムの一部の資源に影響する可能性がある)修正/etc/selinux/configファイルのSELINUX=""disabledのファイアウォールを閉じるコマンド: 1 2
3)システム文字セット符号化構成(システムデフォルトutf-8、必要に応じてシステム文字セットを変更でき、OSを再起動する必要がある)修正/etc/sysconfig/i 18 nプロファイルのLANG 1
/etc/profileを変更し、2行追加します. 1 2
4)coreファイル構成(アプリケーションがクラッシュしたときにクラッシュcoreファイルを自動的に生成し、クラッシュの原因を開発するのに役立つ構成)を生成/etc/profileを変更し、行を追加します. 1
変更/etc/sysctl.confファイル、設定 1
次のコマンドを実行して構成を有効にします. 1
5)ユーザー最大プロセス数構成Centos 5環境修正/etc/security/limits.confファイルCentos 6環境修正/etc/security/limits.d/90-nproc.confファイル 1 2
注意:kdxfはアプリケーションを実行する一般的なシステムアカウントを表しています.実際に記入してください.添付ファイル1:sysctl.conf
Windowsプラットフォーム1、添付ファイル2の内容によってtcpを新規作成する.regレジストリファイルの実行意義:システム接続数制限2を修正し、システムを再起動し、ステップ1発効添付ファイル2:tcpを修正する.reg 1 2 3 4 5 6 7 8 9 10 11
ulimit -n 655350
ulimit -n
Linuxプラットフォームの性能テストをした子供靴は、通常、1、TCPポート番号が足りないため、同時接続ができない(サーバ側との新しい接続に失敗した)2、TIME_WAIT状態の接続が多すぎると、アプリケーションサーバ(Nginx、Haproxy、Redis、Tomcatなど)の性能低下や仮死など、システムカーネルパラメータを最適化することで、Linuxプラットフォーム1、添付ファイル1のsysctlを最適化することができる.confファイルはシステム内の/etc/sysctlを置換または変更する.conf意味:(1)システム最大オープンファイル記述子数制限(システムレベル)(2)システムネットワーク負荷の向上2、コマンド「sysctl-p/etc/sysctl.conf」を使用してステップ1修正有効備考:error:「net.bridge.bridge-nf-call-ip 6 tables」is an unknown key解決方法
modprobe bridge
lsmod|grep bridge
3、修正/etc/security/limits.conf、次の内容を追加します.
* hard nofile 1024000
* soft nofile 1024000
意味:プロセス最大オープンファイル記述子数制限(ユーザーレベル)4、サーバに再ログインして、ステップ3で有効なコメントを変更します:(1)変更中に注意してください.a.すべてのプロセスで開いているファイル記述子の数は/proc/sys/fs/file-maxを超えてはいけません.単一のプロセスで開いているファイル記述子の数はuser limitのnofileのsoft limit c.nofileのsoft limitを超えてはいけません.hard limit d.nofileのhard limitを超えてはいけません./proc/sys/fs/nr_を超えてはいけません.open (2)/etc/security/limits.confの中でファイルの記述子の数を修正して、アカウントを持っていくことを提案して、*号はすべてのアカウントを代表しました!1)kdxfが運行する口座を新設する(一般的にroot口座を使用しない;ネットの安全のために一般的にroot口座の直接登録権限を無効にし、一般口座から登録してからrootに切り替える必要がある)2)LinuxシステムSELINUXとファイアウォールを閉鎖する(オペレーティングシステムを再起動する必要があり、SELINUXセキュリティシステムの制御が厳しすぎて、プロセスアクセスオペレーティングシステムの一部の資源に影響する可能性がある)修正/etc/selinux/configファイルのSELINUX=""disabledのファイアウォールを閉じるコマンド:
chkconfig iptables off
chkconfig ip6tables off
3)システム文字セット符号化構成(システムデフォルトutf-8、必要に応じてシステム文字セットを変更でき、OSを再起動する必要がある)修正/etc/sysconfig/i 18 nプロファイルのLANG
LANG="zh_CN.GB18030"
/etc/profileを変更し、2行追加します.
export LANG=zh_CN.GB18030
export LC_ALL=zh_CN.GB18030
4)coreファイル構成(アプリケーションがクラッシュしたときにクラッシュcoreファイルを自動的に生成し、クラッシュの原因を開発するのに役立つ構成)を生成/etc/profileを変更し、行を追加します.
ulimit -c unlimited
変更/etc/sysctl.confファイル、設定
fs.suid_dumpable = 1
次のコマンドを実行して構成を有効にします.
sysctl -p
5)ユーザー最大プロセス数構成Centos 5環境修正/etc/security/limits.confファイルCentos 6環境修正/etc/security/limits.d/90-nproc.confファイル
kdxf hard nproc unlimited
kdxf soft nproc unlimited
注意:kdxfはアプリケーションを実行する一般的なシステムアカウントを表しています.実際に記入してください.添付ファイル1:sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 12
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 8192
# Disable netfilter on bridges.
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
# Determines how often to check for stale neighbor entries.
net.ipv4.neigh.default.gc_stale_time=120
# Using arp_announce/arp_ignore to solve the ARP Problem
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.all.arp_announce=2
vm.swappiness = 0
net.ipv4.tcp_max_tw_buckets = 50000
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.conf.lo.arp_announce=2
# Controls the application is able to bind to not belong to the local network address
net.ipv4.ip_nonlocal_bind=1
fs.file-max = 1700000
Windowsプラットフォーム1、添付ファイル2の内容によってtcpを新規作成する.regレジストリファイルの実行意義:システム接続数制限2を修正し、システムを再起動し、ステップ1発効添付ファイル2:tcpを修正する.reg
Windows Registry Editor Version 5.00
; TCP
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"TcpNumConnections"=dword:00fffffe
;
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"PoolUsageMaxium"=dword:00000032
;
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer]
"MaxFreeConnections"=dword:00001000
"MinFreeConnections"=dword:00000100