centos6系统优化脚本
CentOS 6 系统优化 Shell 脚本
CentOS 已经发布了6.2版了,现在已经可以用在生产环境了,新版本的内核也能更好的利用硬件。写了一个脚本,用来初始化系统环境,现在分享出来,你可以根据自己的需要,对脚本进行相应的修改。
脚本的内容如下:
#!/bin/bash #author suzezhi #this script is only for CentOS 6 #check the OSplatform=`uname -i` if [ $platform != "x86_64" ];then echo "this script is only for 64bit Operating System !"exit 1 fi echo "the platform is ok" version=`lsb_release -r |awk '{print substr($2,1,1)}'` if [ $version != 6 ];then echo "this script is only for CentOS 6 !" exit 1 ficat << EOF +---------------------------------------+ | your system is CentOS 6 x86_64 | | start optimizing....... | +--------------------------------------- EOF#make the 163.com as the default yum repomv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS-Base.repo#add the third-party repo #add the epelrpm -Uvh http://download.Fedora.RedHat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6#add the rpmforge rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag#update the system and set the ntp yum clean all yum -y update glibc\* yum -y update yum\* rpm\* python\* yum -y update yum -y install ntp echo "* 4 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/rootservice crond restart#set the file limit echo "ulimit -SHn 102400" >> /etc/rc.local cat >> /etc/security/limits.conf << EOF * soft nofile 65535 * hard nofile 65535 EOF#set the control-alt-delete to guard against the miSUSEsed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf#disable selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config#set sshsed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config service sshd restart#tune kernel parametres cat >> /etc/sysctl.conf << EOF net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 EOF /sbin/sysctl -p#define the backspace button can erase the last character typed echo 'stty erase ^H' >> /etc/profile echo "syntax on" >> /root/.vimrc#stop some crontabmkdir /etc/cron.daily.bak mv /etc/cron.daily/makewhatis.cron /etc/cron.daily.bak mv /etc/cron.daily/mlocate.cron /etc/cron.daily.bakchkconfig bluetooth off chkconfig cups off chkconfig ip6tables off #disable the ipv6 cat > /etc/modprobe.d/ipv6.conf << EOFIalias net-pf-10 off options ipv6 disable=1 EOFI echo "NETWORKING_IPV6=off" >> /etc/sysconfig/network cat << EOF +-------------------------------------------------+ | optimizer is done | | it's recommond to restart this server ! | +-------------------------------------------------+ EOF
对脚本的内容做一下说明:
先对系统进行判断,如果是Cent OS 64位,就继续运行。
先将系统的安装源设置为网易的(网易的安装源算是国内比较稳定的)
安装epel的源和rpmforge的源,利用第三方的源来让yum安装起来更方便
更新软件
设置为每天凌晨四点进行时间同步(跟国家授时中心的服务器进行时间同步)
将系统同时打开的文件个数增大
将ctrl alt delete键进行屏蔽,防止误操作的时候服务器重启
关闭selinux
禁用GSSAPI来认证,也禁用DNS反向解析,加快SSH登陆速度
优化一些内核参数
调整删除字符的按键为backspace(某些系统默认是delete)
打开vim的语法高亮
取消生成whatis数据库和locate数据库
关闭没用的服务
关闭IPv6
转载于:https://blog.51cto.com/jiarh/1721671
centos6系统优化脚本相关推荐
- centos6——初始化脚本
服务器centos6初始化脚本,包含几个方面: 修改主机名 添加用户秘钥 ssh 端口修改 ulimit值修改 防火墙修改 添加追踪日志 时间同步 安装一些基础软件包 nagios客户端安装 zabb ...
- Linux系统优化脚本
-------------------------------------------------------------------- 注:如果你对python感兴趣,我这有个学习Python基地, ...
- linux系统优化脚本,linux系统优化脚本详解
#!/bin/bash ###----1.强制限制密码长度,保证密码强壮----### vi /etc/login.defs 修改以下字段,强制限制最少的密码长度 PASS_MIN_LEN 12 ...
- centos6.6 脚本
软件存放于~/soft下面,安装常用软件java.tomcat.svn.maven mkdir /appcd ~/soft #!/bin/bash#staticcd /etc/sysconfig/ne ...
- linux系统优化项目,Linux之系统优化
查看系统版本 [root@luffy- /]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@luffy- /]# uname -m ...
- Shell脚本完全说明
1 什么是shell shell是一个命令解释器,位于操作系统的最外层,它负责和用户直接对话,不用户输入的内容解释给操作系统,操作系统处理完毕后,输出结果,输出到屏幕上.分为交互式的和非交互式的.输入 ...
- @Linux Centos系统优化与内核参数优化详解
文章目录 一.更改yum源 二.常用工具安装 三.关闭Selinux 四.关闭防火墙---清空iptables [iptables防火墙脚本] 五.设置中文字符 六.系统的时间校准 [操作系统时间定时 ...
- Linux实战教学笔记12:linux三剑客之sed命令精讲
第十二节 linux三剑客之sed命令精讲 标签(空格分隔): Linux实战教学笔记-陈思齐 ---更多资料点我查看 1,前言 我们都知道,在Linux中一切皆文件,比如配置文件,日志文件,启动文件 ...
- shell 编程 入门到实战详解
一. shell变量.循环 概述 Shell是一种具备特殊功能的程序,它提供了用户与内核进行交互操作的一种接口.它接收用户输入的命令,并把它送入内核去执行.内核是Linux系统的心脏,从开机自检就驻留 ...
最新文章
- 大数据高效复制的处理案例分析总结
- ASA用ASDM管理时报unable to launch device manager xxx.xxx.xxx.xxx
- 010_学生管理系统一
- JavaScript系列文章:谈谈let和const
- android软件中加入广告实现方法
- JavaFX技巧来节省内存! 属性和可观察物的阴影场
- 商业初创公司网站单页模板
- Centos7 下定义MariaDB源Yum安装最新版本的MariaDB
- python输出文本内容_python如何输出文件内容
- C++数据结构与算法(八) 队列及队列的应用
- 如何在vue中使用less
- 用PowerShell收集服务器日检报告,并发邮件给管理员
- 长路漫漫,唯剑作伴--基础
- excel表格如何设置双面打印的方法
- 计算机化分析原理波涛,证券期货投资计算机化技术分析原理(波涛).pdf.pdf
- 第五届阿里天池中间件比赛经历分享-决赛
- 大学计算机基础知识判断题,大学计算机基础知识考试试题及答案
- 《嵌入式 - ARM》第5章 ARM PWM
- 2017年第四八届C/C++ B组蓝桥杯省赛真题
- 中国的孩子早已变了,老师和家长却还痴迷不悟
热门文章
- Cytology: Diagnostic Principles and Clinical Correlates 细胞学: 诊断原则与临床相关性 PDF
- tuxedo连接mysql_TUXEDO与INFORMIX数据库的互连
- reverse()反转字符串的正确使用方式
- SQLite学习手册(锁和并发控制)
- servlet post 返回值是一个对象_Servlet第二天
- php 拖动多个文件上传,dropzone拖拽文件上传一次上传多个文件的方法
- python3精要(2)-python运行过程,模块,内置对象
- wxWidgets随笔(9)-utf8~wxString存储二进制数据(4)
- mxnet基础到提高(35)-ndarray
- 2021CVPR冠军图像分割算法全解密