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哈哈 ...
随机推荐
- centos7:ftp上传文件
ftp> lcd /var/www/sss 上传文件的地址还一种上传方式ftp> passivePassive mode off.ftp> passivePassive mode ...
- 《贝贝GO》技术支持
贝贝GO是一个采用R2M模式的电子商务平台,通过零售商到制造商的两点直线连接,去除中间所有分销代理环节,结合互联网打造全新的线下新零售,旨在为用户提供高品质.高性价比商品的同事带动零售业的新发展.提升 ...
- 在Linux服务器上使用Vbox安装虚拟机
先去官网(www.virtualbox.org)上下载对应Linux系统的Vbox版本. 我这边用的是Oracle Linux 7系统(KDE安装) 使用rpm安装virtualbox 发现报错,按照 ...
- Open Daylight integration with OpenStack: a tutorial
Open Daylight integration with OpenStack: a tutorial How to deploy OpenDaylight and integrate it wit ...
- vue添加页面键盘事件
我司开发项目,用的是vue+elementUI,做登陆页面的时候,点击enter键的时候要实现和点击登陆按钮一样的功能,所以就百度了一下,于是一通百度之后,就在点击按钮上面直接添加了@keyup.en ...
- 关于第一次在IDEA上使用lombok时注解完全不起作用
当你第一次在IDEA上使用lombok这个工具包时,如果你没有在setting--->Plugins-->Marketplace-->安装Lombok plugin 同时设置 Set ...
- ES6箭头函数Arrow Function
果然,隔了很长时间都没有来博客园上逛了...... 前一段时间一直在忙我们参加的一个比赛,转眼已经好久没有来逛过博客园了,果然还是很难坚持的...... 今天总算还是想起来要过来冒个泡,强行刷一波存在 ...
- django 模型操作
# 添加 Fruit.objects.create(name='Apple') # 更新 UserProfile.objects.filter(user=admin).update(**{'onlin ...
- 2018-软工机试-C-和你在一起
C. 和你在一起 单点时限: 1.0 sec 内存限制: 256 MB 我想和你在一起 直到我不爱你 宝贝 人和人 一场游戏 我愿意为你死去 如果我还爱你 宝贝 反正活着 也没意义 宝贝 我也只能 这 ...
- MAC--NPAPI学习(一)简要介绍NPAPI的函数
NPAPI是浏览器与插件交互的接口,下面先简要介绍一下NPAPI的函数: Mach-o entry points NPError NP_Initialize(NPNetscapeFuncs* brow ...