安装数据库经常做一些os的设置,简单总结一下,随时补充
rc.local
# vi /etc/rc.local
############################################
#disable transparent hugepage
############################################
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
############################################
#set read block size
############################################
blockdev --setra 16384 /dev/sda
############################################
#set io scheduler to deadline for every disk
############################################
echo deadline > /sys/block/sda/queue/scheduler
############################################
#set write type
# 0:write through
# 1:write back
# hdparm -I /dev/sda |grep "Write cache"
# hdparm -W 0 /dev/sda
# hdparm -W 1 /dev/sda
############################################
hdparm -W 0 /dev/sda
grant exec
# chmod u+x /etc/rc.d/rc.local
sysctl.conf
# vi /etc/sysctl.conf
kernel.shmall = 18446744073692774399
kernel.shmmax = 18446744073692774399
kernel.shmmni = 819200
kernel.sem = 4096 2147483647 2147483646 512000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 4194304
net.ipv4.tcp_rmem=8192 87380 16777216
net.ipv4.tcp_wmem=8192 65536 16777216
net.ipv4.tcp_keepalive_intvl=20
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_keepalive_time=60
net.ipv4.tcp_mem=8388608 12582912 16777216
net.ipv4.ip_local_port_range=10000 65535
vm.dirty_background_bytes = xxxx000000
vm.dirty_expire_centisecs = 6000
vm.dirty_ratio = 80
vm.dirty_writeback_centisecs = 50
vm.overcommit_memory = 2
vm.overcommit_ratio = 90
vm.swappiness = 1
vm.nr_hugepages = xxxx
fs.nr_open=20480000
fs.file-max=7672460
fs.aio-max-nr=1048576
生效
# sysctl -p
# sysctl -a
resource limit
# vi /etc/security/limits.conf
root soft nofile 655360 # The maximum number of open file descriptors
root hard nofile 655360
root soft nproc 655360 # The maximum number of processes available to a single user
root hard nproc 655360
* soft memlock unlimited # The maximum size that may be locked into memory
* hard memlock unlimited
* soft core unlimited # The maximum size of core files created
* hard core unlimited
* soft stack unlimited
* hard stack unlimited
disable selinux
# vi /etc/selinux/config
SELINUX=DISABLED
disable firewalld
# systemctl stop firewalld.service
# systemctl disable firewalld.service
disable ipv6
# vi /etc/default/grub
ipv6.disable=1
disable numa
# vi /etc/default/grub
numa=off
disable transparent hugepage
# vi /etc/default/grub
transparent_hugepage=never
set all disk ioscheduler
# vi /etc/default/grub
elevator=deadline
new grub
# grub2-mkconfig -o /boot/grub2/grub.cfg
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/1783.html