linux_基础调优
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_基础调优的更多相关文章
- linux_系统调优
linux如何调优? 1. 关闭SELLinux功能,美国国家安全局对于强制访问控制实现,生产场景也是关闭 cat /etc/selinux/config | grep '^SELINUX=' # 查 ...
- Mysql基础调优
mysql基础的优化方式 1.利用索引加快查询速度 2.利用查询缓存或者旁挂式缓存,提高访问速度 缓存:k/v key:查询语句的hash值 value:查询语句的执行结果 哪些查询可能不会被缓存? ...
- Kafka实战分析(一)- 设计、部署规划及其调优
1. Kafka概要设计 kafka在设计之初就需要考虑以下4个方面的问题: 吞吐量/延时 消息持久化 负载均衡和故障转移 伸缩性 1.1 吞吐量/延时 对于任何一个消息引擎而言,吞吐量都是至关重要的 ...
- 《Apache Kafka实战》读书笔记-调优Kafka集群
<Apache Kafka实战>读书笔记-调优Kafka集群 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.确定调优目标 1>.常见的非功能性要求 一.性能( ...
- tomcat配置调优与安全总结
http://vekergu.blog.51cto.com/9966832/1672931 tomcat配置调优与安全总结 作为运维,避免不了与tomcat打交道,然而作者发现网络上关于tomcat配 ...
- (转)Tomcat配置调优与安全总结
tomcat配置调优与安全总结 作为运维,避免不了与tomcat打交道,然而作者发现网络上关于tomcat配置和调优安全的文章非常散,通过参考各位大神的相关技术文档,根据作者对tomcat的运维经验, ...
- MySQL 调优基础(一) CPU与进程
一般而言,MySQL 的调优可以分为两个层面,一个是在MySQL层面上进行的调优,比如SQL改写,索引的添加,MySQL各种参数的配置:另一个层面是从操作系统的层面和硬件的层面来进行调优.操作系统的层 ...
- SQL Server调优系列基础篇
前言 关于SQL Server调优系列是一个庞大的内容体系,非一言两语能够分析清楚,本篇先就在SQL 调优中所最常用的查询计划进行解析,力图做好基础的掌握,夯实基本功!而后再谈谈整体的语句调优. 通过 ...
- SQL Server调优系列基础篇(常用运算符总结——三种物理连接方式剖析)
前言 上一篇我们介绍了如何查看查询计划,本篇将介绍在我们查看的查询计划时的分析技巧,以及几种我们常用的运算符优化技巧,同样侧重基础知识的掌握. 通过本篇可以了解我们平常所写的T-SQL语句,在SQL ...
随机推荐
- express-session中的saveUninitialized和resave
app.use(session({ name: config.session.name, secret: config.session.secret, resave: true, saveUninit ...
- win10下MinGW的安装与配置(详细步骤)
一.安装mingw软件 1.进入官网 www.mingw.org 2.点击下载downloads 3.点击下载图标 4.点击install z 5.先选择安装的地址,再点击continue 6.等待相 ...
- DevExpress的WidgetView的使用介绍
很多程序可能都会有一个首页综合展示系统的相关信息,如汇总信息,图表统计.待办业务.提醒信息等内容,在Web上可能叫做Dashboard仪表板,或者首页页面,不管哪种叫法,都是综合展示一些信息,提供一些 ...
- 使用kind快速创建本地集群
简 介 kind是另一个Kubernetes SIG项目,但它与minikube有很大区别.它可以将集群迁移到Docker容器中,这与生成虚拟机相比,启动速度大大加快.简而言之,kind是一个使用Do ...
- 跨平台C# UI库
https://github.com/AvaloniaUI/Avalonia https://www.cnblogs.com/leolion/p/7144896.html https://github ...
- C# OWC11
public void OcwChart(int[] Data,string[] DataName,string Yname,string Xname,string ChartName,string ...
- 重要bug记录
导唱功能:需求点分析:本地已下载歌曲播放,判断是否有音频原唱伴奏版权,无版权按钮显示“导唱”,有版权显示“播原唱”.程序实现逻辑: 1.下载歌曲时调用一个歌曲信息接口,返回歌曲的一些属性信息,其中包括 ...
- html中实现倒计时功能(setInterval,clearInterval)
倒计时主要用到的知识点:1.设置时间间隔的setInterval可以被clearInterval取消 2.毫秒转换为时分格式 这个是效果图 下面是js中的函数 var shijian=3600; va ...
- 「面向 offer 学算法」笔面试大杀器 -- 单调栈
目录 前言 单调栈 初入茅庐 小试牛刀 打怪升级 出师试炼 前言 单调栈是一种比较简单的数据结构.虽然简单,但在某些题目中能发挥很好的作用. 最近很多大厂的笔试.面试中都出现了单调栈的题目,而还有不少 ...
- 20190917-01VI/VIM编辑器 000 002
VI是Unix 操作系统和类Unix操作系统中最通用的文本编辑器. VIM编辑器是从VI发展出来的一个性能更强大的文本编辑器.可以主动的以字体颜色便被语法的正确性,方便程序设计.VIM与VI编辑器完全 ...