1. 配置授时服务,使用阿里云的授时服务

 echo -e "# update time\n*/5 * * * * /usr/sbin/ntpdate time1.aliyun.com &> /dev/null" >> /var/spool/cron/$(whoami)

2. 更改yum源和epell源为国内镜像

  # 使用阿里云镜像

  centos6

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.$(date +%F)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo &> /dev/null

  centos7

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.$(date +%F)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo &> /dev/null

  # 只有中间 6和7 的区别

3. vim个性优化

  # 编辑以.sh结尾的文件,将会自动添加一些版权信息,一个tab缩进4空格,自动缩进,当前哪个用户执行这个脚本就在哪个用户的家目录下配置

  # 这个是shell脚本

#!/bin/sh

# author: beimenchuixue
# email: 422083556@qq.com
# blog: http://www.cnblogs.com/2bjiujiu/` # 4 space == 1 tab, write or read files will display number of lines, vi = vim . /etc/init.d/functions
# 1 copy, 2 write setting, 3 source one_shif=4
_tabstop=4 personal_vim() {
[ -f /etc/vimrc ] && {
cd $HOME
/bin/cp /etc/vimrc .
/bin/mv vimrc .vimrc
echo -e "set nu\nset smartindent\nset tabstop=${_tabstop}\nset shiftwidth=${one_shif}\nset expandtab\nautocmd BufNewFile *.sh 0r /root/.vim/template/tmp.sh" >> .vimrc
sed -i "5i alias vi='vim'" .bashrc
[ -d .vim/template ] || {
mkdir .vim/template -p
}
echo "#!/bin/sh\n" >> .vim/template/tmp.sh
echo "# author: beimenchuixue" >> .vim/template/tmp.sh
echo "# email: 422083556@qq.com" >> .vim/template/tmp.sh
echo "# blog: http://www.cnblogs.com/2bjiujiu/" >> .vim/template/tmp.sh
action "$HOME person vim setting is " /bin/true
}
} personal_vim

4. 关闭selinux

  # 美国国家安全局对于强制访问控制实现,生产场景也是关闭

  # /etc/selinux/config

sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
setenforce 0

5. 关闭防火墙(连接外网的机器才需要防火墙)

/etc/init.d/iptables stop
chkconfig iptables off

6. 清空版本信息显示

> /etc/issue
> /etc/issue.net

7. 克隆虚拟机能上网配置(使用vmware虚拟机创建链接克隆时候使用 )

sed -i -r "/HWADDR|UUID/d" /etc/sysconfig/network-scripts/ifcfg-eth0
>/etc/udev/rules.d/70-persistent-net.rules
echo ">/etc/udev/rules.d/70-persistent-net.rules" >> /etc/rc.local

8. 精简开机启动服务

  # 总共5个服务 sshd sysstat crond network rsyslog

chkconfig --list|grep "3:on"|egrep -v 'sshd|sysstat|crond|network|rsyslog'|awk '{print "chkconfig",$1,"off"}'|bash

9. 增大文件描叙符

echo " *               -       nofile            65535 " >> /etc/security/limits.conf

一键实现以上优化

#!/bin/sh
# author: beimenchuixue
# blog: http://www.cnblogs.com/2bjiujiu/` # use cron + ntp update time
. /etc/init.d/functions
update_time() {
echo -e "# update time\n*/5 * * * * /usr/sbin/ntpdate time1.aliyun.com &> /dev/null" >> /var/spool/cron/$(whoami)
action "cron+ntp get time is" /bin/true
} # update_time # change yum and epel
aliyun_epel_yum() {
centos_version=$(awk -F '[. ]' '{print $3}' /etc/redhat-release)
[ -f /etc/yum.repos.d/CentOS-Base.repo ] && {
# intall yum_repo and backup old repo
/bin/mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.$(date +%F)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-${centos_version}.repo &> /dev/null
# install epel
[ $? -eq 0 ] && {
# if install
[ $(rpm -qa | grep epel |wc -l) -eq 1 ] && {
rpm -e $(rpm -qa | grep epel)
}
rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-${centos_version}.noarch.rpm &> /dev/null
action "yum epel aliyun is" /bin/true
} || {
/bin/mv /etc/yum.repos.d/CentOS-Base.repo.$(date +%F) /etc/yum.repos.d/CentOS-Base.repo
action "yum epel aliyun is" /bin/false
}
} }
# aliyun_epel_yum # stop selinux
stop_selinx() {
sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
setenforce 0
action "stop selinux is" /bin/true
}
# stop_selinx stop_iptable() {
/etc/init.d/iptables stop &> /dev/null
chkconfig iptables off
action "stop iptables is" /bin/true
}
# stop_iptable # hide os version
hide_version() {
> /etc/issue
> /etc/issue.net
action "hide version is" /bin/true
}
# hide_version # in order to let clone host connect internet
clone_connect_internet() {
sed -i -r "/HWADDR|UUID/d" /etc/sysconfig/network-scripts/ifcfg-eth0
[ -f /etc/sysconfig/network-scripts/ifcfg-eth1 ] && {
sed -i -r "/HWADDR|UUID/d" /etc/sysconfig/network-scripts/ifcfg-eth1
}
>/etc/udev/rules.d/70-persistent-net.rules
echo ">/etc/udev/rules.d/70-persistent-net.rules" >> /etc/rc.local
ifdown eth0 && ifup eth0 &> /dev/null
action "clone_vm connection internet setting is" /bin/true
}
# clone_connect_internet # only 5 server need onboot
start_need_server() {
chkconfig --list|grep "3:on"|egrep -v 'sshd|sysstat|crond|network|rsyslog'|awk '{print "chkconfig",$1,"off"}'|bash
action "(sshd sysstat crond network rsyslog) onboot is" /bin/true
}
# start_need_server # incrase file descriptior
increase_file_desc() {
echo " * - nofile 65535 " >> /etc/security/limits.conf
action "incrase file descriptior is" /bin/true
}
# increase_file_desc init_os_main() {
update_time
stop_iptable
stop_selinx
hide_version
clone_connect_internet
start_need_server
aliyun_epel_yum
increase_file_desc
}
init_os_main

  

linux_基础调优的更多相关文章

  1. linux_系统调优

    linux如何调优? 1. 关闭SELLinux功能,美国国家安全局对于强制访问控制实现,生产场景也是关闭 cat /etc/selinux/config | grep '^SELINUX=' # 查 ...

  2. Mysql基础调优

    mysql基础的优化方式 1.利用索引加快查询速度 2.利用查询缓存或者旁挂式缓存,提高访问速度 缓存:k/v key:查询语句的hash值 value:查询语句的执行结果 哪些查询可能不会被缓存? ...

  3. Kafka实战分析(一)- 设计、部署规划及其调优

    1. Kafka概要设计 kafka在设计之初就需要考虑以下4个方面的问题: 吞吐量/延时 消息持久化 负载均衡和故障转移 伸缩性 1.1 吞吐量/延时 对于任何一个消息引擎而言,吞吐量都是至关重要的 ...

  4. 《Apache Kafka实战》读书笔记-调优Kafka集群

    <Apache Kafka实战>读书笔记-调优Kafka集群 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.确定调优目标 1>.常见的非功能性要求 一.性能( ...

  5. tomcat配置调优与安全总结

    http://vekergu.blog.51cto.com/9966832/1672931 tomcat配置调优与安全总结 作为运维,避免不了与tomcat打交道,然而作者发现网络上关于tomcat配 ...

  6. (转)Tomcat配置调优与安全总结

    tomcat配置调优与安全总结 作为运维,避免不了与tomcat打交道,然而作者发现网络上关于tomcat配置和调优安全的文章非常散,通过参考各位大神的相关技术文档,根据作者对tomcat的运维经验, ...

  7. MySQL 调优基础(一) CPU与进程

    一般而言,MySQL 的调优可以分为两个层面,一个是在MySQL层面上进行的调优,比如SQL改写,索引的添加,MySQL各种参数的配置:另一个层面是从操作系统的层面和硬件的层面来进行调优.操作系统的层 ...

  8. SQL Server调优系列基础篇

    前言 关于SQL Server调优系列是一个庞大的内容体系,非一言两语能够分析清楚,本篇先就在SQL 调优中所最常用的查询计划进行解析,力图做好基础的掌握,夯实基本功!而后再谈谈整体的语句调优. 通过 ...

  9. SQL Server调优系列基础篇(常用运算符总结——三种物理连接方式剖析)

    前言 上一篇我们介绍了如何查看查询计划,本篇将介绍在我们查看的查询计划时的分析技巧,以及几种我们常用的运算符优化技巧,同样侧重基础知识的掌握. 通过本篇可以了解我们平常所写的T-SQL语句,在SQL ...

随机推荐

  1. 安装Apache所踩的的坑

    刚开始接触PHP等一些脚本语言,需要建立一个本地的服务器,变进行安装了Apache.在其中碰到了诸多问题,和大家一一分享一下. 一.刚解压完成后使用cmd面板进入解压完成的apache的bin目录下, ...

  2. MySQL锁这块石头似乎没有我想的那么重

    前言 前言为本人写这篇文章的牢骚,建议跳过不看.   之前好几次都想好好的学习MySQL中的锁,但是找了几篇文章,看了一些锁的类型有那么多种,一时间也没看懂是什么意思,于是跟自己说先放松下自己,便从书 ...

  3. Kubernetes K8S之通过yaml文件创建Pod与Pod常用字段详解

    YAML语法规范:在kubernetes k8s中如何通过yaml文件创建pod,以及pod常用字段详解 YAML 语法规范 K8S 里所有的资源或者配置都可以用 yaml 或 Json 定义.YAM ...

  4. Android开发之dp转像素,像素转换为dp工具类,详细代码,带有源文件下载地址。

    import android.content.Context; /** * @author 官网:http://blog.csdn.net/qq_21376985 * * David编写: 微博:ht ...

  5. Pandas | Dataframe的merge操作,像数据库一样尽情join

    今天是pandas数据处理第8篇文章,我们一起来聊聊dataframe的合并. 常见的数据合并操作主要有两种,第一种是我们新生成了新的特征,想要把它和旧的特征合并在一起.第二种是我们新获取了一份数据集 ...

  6. FZU - 2038 -E - Another Postman Problem (思维+递归+回溯)

    Chinese Postman Problem is a very famous hard problem in graph theory. The problem is to find a shor ...

  7. SSM框架之mybatis极速入门!

  8. SQL分词器1.10版

    处理SQL及分词效果: select * from ( select rownum as rn,tb1.stuid,tb1.summary from ( select stuid,sum(score) ...

  9. yum wget rpm

    wget 类似于迅雷,是一种下载工具          下载安装包 yum: 是redhat, centos 系统下的软件安装方式 下载安装包并自动安装 以及一些依赖关系 基于RPM包管理,能够从指定 ...

  10. Tcahce Stashing Unlink Attack

    今年校赛有点可惜,最后两道质量不错的pwn每做出来,总的来说还是我太菜了,希望下次校赛能AK pwn题.不过这次校赛也没有白打,还是有学到新的东西的.在这里感谢出题的学长. glibc-2.29以后u ...