centos7系统优化定制
#!/bin/bash
#author junxi by
#this script is only for CentOS 7.x
#check the OS
platform=`uname -i`
if [ $platform != "x86_64" ];then
echo "this script is only for 64bit Operating System !"
exit 1
fi
echo "the platform is ok"
cat << EOF
+---------------------------------------+
| your system is CentOS 7 x86_64 |
| start optimizing....... |
+---------------------------------------
EOF
#添加公网DNS地址
cat >> /etc/resolv.conf << EOF
nameserver 114.114.114.114
EOF
#Yum源更换为国内阿里源
yum install wget telnet -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#添加阿里的epel源
#add the epel
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# rpm -ivh http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
#yum重新建立缓存
yum clean all
yum makecache
#同步时间
yum -y install ntp
/usr/sbin/ntpdate cn.pool.ntp.org
echo "* 4 * * * /usr/sbin/ntpdate cn.pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root
systemctl restart crond.service
#安装vim
yum -y install vim
#设置最大打开文件描述符数
echo "ulimit -SHn 102400" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
* soft nofile 655350
* hard nofile 655350
EOF
#禁用selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
#关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
#set ssh
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
systemctl restart sshd.service
#内核参数优化
cat >> /etc/sysctl.conf << EOF
vm.overcommit_memory = 1
net.ipv4.ip_local_port_range = 1024 65536
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_tw_recycle = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_abort_on_overflow = 0
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
net.ipv4.netfilter.ip_conntrack_max = 2097152
net.nf_conntrack_max = 655360
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
EOF
/sbin/sysctl -p
#vim定义退格键可删除最后一个字符类型
echo 'alias vi=vim' >> /etc/profile
echo 'stty erase ^H' >> /etc/profile
cat >> /root/.vimrc << EOF
set tabstop=4
set shiftwidth=4
set expandtab
syntax on
"set number
EOF
#update soft
yum -y update
cat << EOF
+-------------------------------------------------+
| optimizer is done |
| it's recommond to restart this server ! |
+-------------------------------------------------+
EOF
centos7系统优化定制的更多相关文章
- centos7 系统优化脚本
脚本一: #!/usr/bin/env bash #设置环境变量 export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb ...
- centos7 系统优化
#!/usr/bin/env bash #设置环境变量 export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/u ...
- centos7系统优化
优化说明: 一.关闭selinux 二.更改为阿里yum源 三.提权dm用户可以使用sudo 四.优化ssh远程登录配置 五.设置中文字符集 六.设置时间同步 七.历史记录数及登录超时环境变量设置 八 ...
- centos7系统优化-转载
禁用SELINUX # grep -i ^selinux /etc/selinux/config SELINUX=enforcing SELINUXTYPE=targeted 注释掉上面2行,并增加 ...
- Docker - 定制镜像
Dockerfile Docker Hub拥有大量高质的官方镜像:可直接使用的服务类镜像.语言应用镜像.基础操作系统镜像等,满足绝大部分需求. 此外,可以通过定制镜像的方式来满足实际使用中的特定需求. ...
- CentOS7版本基础使用
第1章 CentOS7的使用 1.1 为什么要使用CentOS7版本 CentOS7是在CentOS6基础上发布的新版本,与之前的版本相比,主要的更新包括: 1.内核更新到3.10.0 2.支持Lin ...
- Joker的自动化之路
系统篇 颜色 黄绿+金色 使用mac系统常用工具(包含svn,vim,crt,redis,php5,网络性能命令) 计算机硬件 linux发展史 cent ...
- 自定制Centos7.3系统镜像(ISO)
本文主要介绍如何根据官方的Centos镜像文件,在保留原有默认安装的RPM包的基础下,添加自己所需要的RPM包的,最终生成一个自定制版的ISO,节省了宝贵的时间并确保了安装的定制性.对于其他没有介绍的 ...
- Centos7.5的定制化安装
一.前言 关于定制化centos7.5的镜像真的是历经波折,前前后后.来来回回尝试了不少于20次,上网找了各种关于定制7系统的方法,都没有成功... 但最终功夫不负有心人终于解决了,O(∩_∩)O哈哈 ...
随机推荐
- vue-resource 和 axios的区别
vue-resource Vue.js是数据驱动的,这使得我们并不需要直接操作DOM,如果我们不需要使用jQuery的DOM选择器,就没有必要引入jQuery.vue-resource是Vue.js的 ...
- css 清楚浮动的几种方式
方法一: 使用clear属性的空元素 <div style="clear:both;"></div> 方法二:使用overflow属性 给浮动的元素容器添加 ...
- node.js 之 N-blog
N-blog 使用 Express + MongoDB 搭建多人博客 原文地址: https://github.com/nswbmw/N-blog 建议初学者,研究下整个项目. 这里节选了一些内容为 ...
- MongoDB知识点拾遗梳理
MongoDB数据库安装: >apt-get install mongodb 0.MongoDB状态查看.启动.停止 >/etc/init.d/mongodb status或s ...
- failed to start process with commandline '%LAUNCHER_PATH% %LAUNCHER_ARGS%', ErrorCode = '0x80070002
在dotnet core进行开发的时候,需要开发目录直接iis进行部署,然而启动的时候,报异常,我们查看windows下的应用日志发现有个这样的错误信息 Application 'MACHINE/WE ...
- 作为程序员你不知道中国互联网300强你就OUT了!
很多程序员们工作一段时间之后,都想跳槽到综合实力更强的公司以获取高薪资或者接触到前沿的技术,但是哪些行业值得我们投入大量的时间,哪些公司属于我们行业中的佼佼者呢, 那么小编给您分析下2018年中国互联 ...
- There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 异常
今天在使用mybatis时,出现了一个问题:There is no getter for property named 'user' in 'class com.jyr.wh.domain.User, ...
- Javascript 严格模式(strict mode)详解
Javascript 严格模式详解 一.概述 除了正常运行模式,ECMAscript 5添加了第二种运行模式:"严格模式"(strict mode).顾名思义,这种模式使得Ja ...
- yii2.0 curd操作
$customer=new Customer();//插入操作 $customer->name='小熊'; $customer->save(); //修改操作 $model=Custome ...
- 学习笔记:spark Streaming的入门
spark Streaming的入门 1.概述 spark streaming 是spark core api的一个扩展,可实现实时数据的可扩展,高吞吐量,容错流处理. 从上图可以看出,数据可以有很多 ...