本文共 2219 字,大约阅读时间需要 7 分钟。
ServiceList=$(chkconfig --list |
grep
'0'
|
awk
'{print $1}'
|
grep
-Ev
'sshd|network|crond|syslog'
)
for
Service
in
$ServiceList
/etc/init
.d/$Service stop
chkconfig --level 0123456 $Service off
grep
-q
"vm.swappiness = 0"
/etc/sysctl
.conf ||
cat
>>
/etc/sysctl
.conf << EOF
net.core.rmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_default = 262144
net.core.wmem_max = 16777216
net.core.somaxconn = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.ip_local_port_range = 1024 65500
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_mem = 786432 1048576 1572864
kernel.sem = 250 32000 100 128
fs.inotify.max_user_watches = 1048576
grep
-q
"* - nofile 65536"
/etc/security/limits
.conf ||
cat
>>
/etc/security/limits
.conf << EOF
grep
-q
"ulimit -n 65536"
/etc/profile
||
cat
>>
/etc/profile
<< EOF
alias
grep
=
'grep --color=auto'
export
HISTTIMEFORMAT=
"%Y-%m-%d %H:%M:%S "
sed
-i
's/SELINUX=enforcing/SELINUX=disabled/'
/etc/selinux/config
sed
-i
's/.*UseDNS yes/UseDNS no/'
/etc/ssh/sshd_config
sed
-i
's/.*GSSAPIAuthentication yes/GSSAPIAuthentication no/'
/etc/ssh/sshd_config
/etc/init
.d
/sshd
restart
grep
-q
"/App/script"
$HOME/.bash_profile ||
cat
>> $HOME/.bash_profile << EOF
export
PATH=
/App/script
:\$PATH
mkdir
-p
/App/script
/App/src
mount
--bind
/dev/shm
/tmp
grep
-q
"/dev/shm"
/etc/rc
.
local
||
echo
"/bin/mount --bind /dev/shm /tmp"
>>
/etc/rc
.
local
转载于:https://blog.51cto.com/68686789/1717608