linux基础优化

安装全新的Centos7系统,配置网卡为eth0及eth1命名模式

  1.第一块网卡为NAT模式[ 公网环境 ] ,配置的网段为10.0.0.0网段

  2.第二块网卡为LAN模式[ 私网模式 ] , 配置的网段为172.16.1.0网段

  3.优化安装好的Centos虚拟机,安装常用软件,关闭防火墙等等

优化步骤

阿里云镜像

[root@kvm ~]# mkdir /etc/yum.repos.d_bak

[root@kvm ~]# mv  /etc/yum.repos.d/* /etc/yum.repos.d_bak

#centos 7镜像源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

#centos 6镜像源

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

安装基础软件包

yum install -y tree   vim wget  bash-completion  bash-completion-extras  lrzsz  net-tools sysstat  iotop iftop htop unzip nc nmap telnet bc  psmisc httpd-tools  bind-utils nethogs

关闭防火墙 firewalld

systemctl disable  firewalld

systemctl stop   firewalld

关闭selinux

sed -i  ' /^SELINUX=/c SELINUX=disabled ' /etc/selinux/config   

或者命令:               setenforce 0    

查看selinux状态 :   getenforce 

# 方式一

sed -ri 's#(^SELINUX=).*#1disabled#g' /etc/selinux/config

# 方式二

sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config

调整单个进程最大能打开文件的数量

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

时间服务器同步

# crontab -e

*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com &> /dev/null 

基于优化后的虚拟机进行克隆

  1. 连接克隆(需要依赖母体)

  2. 完整克隆(完完全全的复制一份,占用磁盘空间)

对新克隆后的主机进行如下操作:

  1.修改主机名 hostnamectl   set-hostname backup 

  2.修改IP地址 sed -i  ' s#200#41#g '   /etc/sysconfig/network-scripts/ifcfg-eth[01] 

  3.重启服务器

ssh连接慢优化

 sed -i 's@#UseDNS yes@UseDNS no@g' /etc/ssh/sshd_config

 sed -i 's@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config

 systemctl restart sshd 

提示符颜色

 export PS1='[[e[31;1m]u[e[0m]@[e[33;1m]H [e[32;1m]w[e[0m]]$ '

xshell 连接

原文地址:https://www.cnblogs.com/Mercury-linux/p/11451192.html