网络配置
a、增加网卡b、网卡配置 vim /etc/sysconfig/network-scripts/ifcfg-eth0c、确认网络是否畅通
系统优化
- hosts文件优化配置
1、备份原hosts文件 \cp /etc/hosts{,.bak} 2、数据重定向到文件_主机名和IP地址映射 cat > /etc/hosts<<EOF 127.0.0.1 web01 127.0.0.2 web02 127.0.0.3 web03 EOF
- 优化yum源
阿里巴巴镜像站:https://opsx.alibaba.mirror1、备份原来的yum源 mv /etc/yum.repos.d/CentOS-Base.repo/ /etc/yum.repos.d/CentOS-Base.repo.back && \curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo #根底yum源mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backupmv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backupwget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #扩大yum源
- 优化SElinux
1、敞开SElinux 长久化批改: sed -i.bak 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config grep SELINUX=disabled /etc/selinux/config 长期批改: setenforce 0 getenforce
- 优化防火墙——iptables
systemctl stop firewalldsystemctl disabled firewalldsystemctl status firewalld
- 用户优化_创立一般优化(可选——普通用户领有root的一些权限)
useradd testuserecho 123456|pwsswd --stdin testuser\cp /etc/sudoers /etc/sudoers.oriecho "testuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoerstail -1 /etc/sudoersvisudo -c
- 字符集优化
localectl set-locale LANG="en_US.UTF-8"
- 工夫同步
yum install -y ntpdateecho '#time sync by lidao at 2017-03-08' >>/var/spool/cron/rootecho '*/5 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1' >> /var/spool/cron/rootcrontab -l #查看定时工作
- 命令行平安优化(可选)
echo 'export TMOUT=300' >> /etc/profileecho 'export HISTSIZE=5' >> /etc/profileecho 'export HISTFILESIZE=5' >> /etc/profiletail -3 /etc/profile. /etc/profile
加大文件描述符
- 一个过程对应一个文件
crond定时工作-----systemctl start crond
/var/spool/cron/root ---关上配置文件
/var/log/cron ----关上日志文件
- 一个过程对应一个文件
ulimit -a #查看零碎最大反对关上的文件数isof -i:22 #统计过程关上的文件数yum install -y isofecho '* - nofile 65535' >> /etc/security/limits.confsource /etc/security/limits.conftail -1 /etc/security/limits.conf
- 内核优化
cat >> /etc/sysctl.conf<<EOF net.ipv4.tcp_fin_timeout=2 net.ipv4.tcp_tw_reuse=1 net.ipv4.tcp_tw_recycle=2 net.ipv4.tcp_syncookies=2 net.ipv4.tcp_keepalive_time=600 net.ipv4.tcp_max_tw_buckets=36000 net.ipv4.tcp_max_syn_backlog=16384 net.ipv4.ip_local_port_range=4000 net.ipv4.route_gc_timeout=100 net.ipv4.tcp_syn_retries=1 net.core.somaxconn=16384 net.core.netdev_max_backlog=16384 #已下是对防火墙的优化,防火墙不散会提醒,能够疏忽 net.nf_conntrack_max=2500000 net.netfilter.nf_conntrack_max=2500000 net.netfilter.nf_conntrack_tcp_timeout_entablished=180 net.netfilter.nf_conntrack_tcp_timeout_time_wait=120 net.netfilter.nf_conntrack_tcp_timeout_close_wait=60 net.netfilter.nf_conntrack_tcp_timeout_fin_wait=120
- 软件装置优化
yum install lrzsz nmap tree dos2unix nc telnet sl wget ntpdate bash-completion-extra bash-completion -y
- ssh近程优化
sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/ssd.confsystemctl ssd restart
克隆
*一台一台启动
1、设置快照2、进行虚拟主机克隆 a、链接克隆——节俭物理机资源、效率高;模板主机删除,链接主机生效,相似软连贯——学习应用 b、残缺克隆——模板机删除,不影响克隆主机;克隆效率慢,耗费物理资源——企业应用
- 批改主机地址
sed -i 's#200#41#g' /etc/sysconfig/network-scripts/ifcfg-eth[01]sed -i '/UUID/d' /etc/sysconfig/network-scripts/ifcfg-eth[01]
- 批改主机名称
hostnamectl set-hostname backup