常用Linux系统优化脚本
来源:互联网 发布:程序员闯关攻略 编辑:程序博客网 时间:2024/06/06 14:23
该脚本是我常用的系统安装后执行脚本,包括开机启动服务、内核、SSH优化。
#!/bin/sh# 服务优化,(sshd、network、crond、syslog、rsyslog)服务保持默认开机启动ServiceList=$(chkconfig --list | grep '0' | awk '{print $1}' | grep -Ev 'sshd|network|crond|syslog')for Service in $ServiceListdo /etc/init.d/$Service stop chkconfig --level 0123456 $Service offdone# 内核参数调优grep -q "vm.swappiness" /etc/sysctl.conf || cat >> /etc/sysctl.conf << EOF########################################vm.swappiness = 0net.core.rmem_default = 262144net.core.rmem_max = 16777216net.core.wmem_default = 262144net.core.wmem_max = 16777216net.core.somaxconn = 262144net.core.netdev_max_backlog = 262144net.ipv4.tcp_max_orphans = 262144net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_max_tw_buckets = 10000net.ipv4.ip_local_port_range = 1024 65500net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_syncookies = 1net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_keepalive_time = 1200net.ipv4.tcp_mem = 786432 1048576 1572864fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.sem = 250 32000 100 128fs.inotify.max_user_watches = 1048576EOFsysctl -pgrep -q "* - nofile" /etc/security/limits.conf || cat >> /etc/security/limits.conf << EOF########################################* - nofile 1048576* - nproc 65536* - stack 1024EOFgrep -q "ulimit -n" /etc/profile || cat >> /etc/profile << EOF########################################ulimit -n 1048576ulimit -u 65536ulimit -s 1024alias grep='grep --color=auto'export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "EOF# 禁用并关闭selinuxsed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/configsetenforce 0# 优化SSHsed -i 's/.*UseDNS yes/UseDNS no/' /etc/ssh/sshd_configsed -i 's/.*GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config/etc/init.d/sshd restart# 脚本目录加入PATH环境变量grep -q "/App/script" $HOME/.bash_profile || cat >> $HOME/.bash_profile << EOF########################################export PATH=/App/script:\$PATHEOFmkdir -p /App/script /App/src# 挂载tmpfs文件系统mount --bind /dev/shm /tmpgrep -q "/dev/shm" /etc/rc.local || echo "/bin/mount --bind /dev/shm /tmp" >> /etc/rc.local
本文出自 “松松” 博客,请务必保留此出处http://dongsong.blog.51cto.com/916653/1631167
0 0
- 常用Linux系统优化脚本
- Linux系统初始化优化Shell脚本
- Linux常用的系统监控shell脚本
- Linux常用的系统监控shell脚本
- SQLERVER优化常用脚本
- 几个常用的Linux系统性能监控shell脚本
- sqlserver2008数据库优化常用脚本
- Linux常用脚本
- linux 常用脚本分析
- linux 常用备份脚本
- linux 常用脚本分析
- linux常用shell脚本
- Linux shell常用脚本
- Linux Shell 常用脚本
- Linux常用Shell脚本
- linux常用脚本
- Linux常用脚本
- linux常用脚本
- MariaDB(MySQL)修改表结构报表空间满
- Web服务器Nginx多方位优化策略
- Nginx运维管理脚本
- Linux内核调优部分参数说明
- 吐槽:webkit里WebKit.dll的编译
- 常用Linux系统优化脚本
- vb.net如何编写高效率的SQLHelper(一)基础篇
- PHP源码编译安装管理常用脚本
- 如何编译QT3
- 如何查看Android的Keystore文件的SHA1值
- Docker-组件分析
- 黑马程序员——java基础知识之面向对象(三)
- 《第七周RFID作业》物联112118 林家辉
- 【转】WINDOWS命令和批处理