VMware

centos7制作模板机
1.vmware安装
2.虚拟网络的配置
3.网卡模块

1>修改网卡名称为eth0

PEERDNS=no
这个选项可令 /etc/resolv.conf 在系统重启后不会被重写。

mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0

cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.61
NETMASK=255.255.255.0
GATEWAY=10.0.0.254
DNS1=223.5.5.5
DNS2=223.6.6.6

添加LAN
在这里插入图片描述
添加内网
静态ip配置

vim /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.61
NETMASK=255.255.255.0
GATEWAY=10.0.0.254

2>修改grub配置,添加net.ifnames=0 biosdevname=0 字段

[root@linux-node1 ~]# vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet "net.ifnames=0 biosdevname=0""
GRUB_DISABLE_RECOVERY="true"

[root@youfeng ~]# grep "net.ifnames=0 biosdevname=0" /etc/sysconfig/grub 
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos_mysql/root rd.lvm.lv=centos_mysql/swap rd.lvm.lv=centos_mysql/usr net.ifnames=0 biosdevname=0 rhgb quiet"

3>生成grub启动菜单重启系统生效

   grub2-mkconfig -o /boot/grub2/grub.cfg
   reboot

4、防火墙、swap、swap,禁用开机启动项

systemctl stop firewalld && systemctl disable firewalld
setenforce 0 && sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
swapoff -a

注释fstab内swap挂载选项
cat /etc/fstab
#/dev/mapper/centos-swap swap                    swap    defaults        0 0

systemctl disable dbus-org.freedesktop.NetworkManager.service
systemctl disable dbus-org.freedesktop.nm-dispatcher.service
systemctl disable NetworkManager-dispatcher.service
systemctl disable NetworkManager
systemctl disable postfix.service

5、优化ssh

echo 'UseDNS no'>>/etc/ssh/sshd_config
echo 'PermitRootLogin yes'>>/etc/ssh/sshd_config
sed -i '/GSSAPIAuthentication/a\\GSSAPIAuthentication no' /etc/ssh/sshd_config 

6、修改默认dns

cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
#nameserver 192.168.121.2
nameserver 180.76.76.76

7、优化yum源、安装常用软件

mkdir -p /etc/yum.repos.d/oldboy-repo
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/oldboy-repo/
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum -y update
yum -y install epel-release git ntp ntpdate lrzsz lftp wget unzip zip bash-completion tree elinks nmap bind-utils net-tools tcptraceroute

yum clean all
配置yum源
查看yum源
yum repolist
CentOS 7系统默认的源更新
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
增加epel源
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

8、调整文件描述符大小

cat /etc/security/limits.conf

* soft nofile 1024000
* hard nofile 1024000

9、调整字符集,使其支持中文

cat /etc/locale.conf 

#LANG="en_US.UTF-8"
LANG="zh_CN.UTF-8"

10、内核参数调优

cp /etc/sysctl.conf /etc/sysctl.conf.bak
cat /etc/sysctl.conf
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_abort_on_overflow = 1
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096        87380  4194304
net.ipv4.tcp_wmem = 4096        66384  4194304
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.core.optmem_max = 81920
net.core.wmem_default = 8388608
net.core.wmem_max = 16777216
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.ipv4.tcp_max_syn_backlog = 1020000
net.core.netdev_max_backlog = 862144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 327680
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_time = 30
net.ipv4.ip_local_port_range = 1024    65535
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_max = 1048576
net.nf_conntrack_max = 1048576
fs.file-max = 655350

使内核参数生效

modprobe nf_conntrack
sysctl -p /etc/sysctl.conf
sysctl -w net.ipv4.route.flush=1

11、优化history

cat /etc/profile
export HISTTIMEFORMAT="%F %T `whoami` "
export HISTFILESIZE=5000
export HISTSIZE=5000

echo "source /etc/profile" >>~/.bashrc
source /etc/profile

12、设置时区、同步时间

timedatectl set-timezone Asia/Shanghai
cat /etc/rc.local
ntpdate -u ntp1.aliyun.com

chmod +x /etc/rc.d/rc.local
chmod a+x /etc/rc.local

13、垃圾清理

yum clean headers
yum clean packages
yum clean metadata

14、历史记录清理

echo > /var/log/wtmp
echo > /var/log/btmp
echo>/var/log/lastlog
echo > /var/log/secure
echo > /var/log/messages
echo>/var/log/syslog
echo>/var/log/yum.log
echo > ~/.bash_history
history -cw

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值