- 編輯/etc/sysctl.conf:
sudo nano /etc/sysctl.conf
- 加入以下核心參數設定:
#
# for kernel
#
kernel.sem = 250 32000 100 128
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
fs.file-max = 65535
vm.swappiness = 1
vm.vfs_cache_pressure = 50
vm.dirty_writeback_centisecs=1500
#
# For net connections
#
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1
# recommended to increase this for 1000 BT or higher
net.core.netdev_max_backlog = 2500
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_no_pmtu_disc = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_ecn = 0
net.ipv4.route.flush = 1 - 重新讀取設定即ok:
sudo sysctl -p
- 加上block device讀取參數的修改,來改善讀取的效能:
修改/etc/rc.localsudo nano /etc/rc.local
在最後的exit 0之前加上echo 1024 >
其中,sda是指欲調整的磁碟代號,如果有多個磁碟想調整,則重複以上設定,但是將磁碟代號修改完欲調整的。/sys/block/sda/queue/read_ahead_kb
echo 1024 > /sys/block/sda/queue/nr_requests
以上的修改只是針對透過修改核心參數來達到提升效能的方式,事實上,還有很多其他部份可以調整。個人使用的感覺是還不錯,有蠻顯著的效果