2021-11-08 day30 期中架构环境准备

期中架构

期中架构创建模板机

修改eth0网卡地址

```

cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << 'EOF'

TYPE=Ethernet

BOOTPROTO=none

NAME=eth0

DEVICE=eth0

ONBOOT=yes

IPADDR=10.0.0.100

PREFIX=24

GATEWAY=10.0.0.254

DNS1=10.0.0.254

EOF

```

修改eth1网卡地址

```

cat > /etc/sysconfig/network-scripts/ifcfg-eth1 << 'EOF'

TYPE=Ethernet

BOOTPROTO=static

IPADDR=172.16.1.100

PREFIX=24

NAME=eth1

DEVICE=eth1

ONBOOT=yes

EOF

```

重启网卡

```

systemctl restart network

```

关闭防火墙

```

systemctl stop  firewalld  NetworkManager 

systemctl disable  firewalld  NetworkManager

systemctl is-active  firewalld  NetworkManager 

systemctl is-enabled  firewalld  NetworkManager 

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

setenforce 0

getenforce

```

优化ssh连接速度慢

```

sed -i '/#UseDNS yes/c UseDNS no' /etc/ssh/sshd_config

sed -i '/GSSAPIAuthentication/c GSSAPIAuthentication no' /etc/ssh/sshd_config

egrep -n '^(GSSAPIA|UseDNS)' /etc/ssh/sshd_config

systemctl restart sshd

```

优化命令行显示

```

sed -i '/#UseDNS yes/c UseDNS no' /etc/ssh/sshd_config

sed -i '/GSSAPIAuthentication/c GSSAPIAuthentication no' /etc/ssh/sshd_config

egrep -n '^(GSSAPIA|UseDNS)' /etc/ssh/sshd_config

systemctl restart sshd

```

优化命令行显示

```

export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "

```

查看修改情况

```

vim /etc/profile

tail -1 /etc/profile

```

修改yum源

```

mv /etc/yum.repos.d/* /tmp/

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

sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo

yum makecache fast

```

安装系统常用软件

```

yum install -y tree vim wget bash-completion  bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip telnet ntpdate

```

关闭邮件提醒并查看状态

```

echo 'unset mailcheck' >> /etc/profile

source /etc/profile

```

添加定时任务更新系统时间

```

*/5 * * * * /usr/sbin/ntpdate time1.aliyun.com > /dev/null 2>&1

```

修改系统hosts配置

```

cat > /etc/hosts << 'EOF'

10.0.0.5 172.16.1.5 lb-5

10.0.0.6 172.16.1.6 lb-6

10.0.0.7 172.16.1.7 web-7

10.0.0.8 172.16.1.8 web-8

10.0.0.9 172.16.1.9 web-9

10.0.0.31 172.16.1.31 nfs-31

10.0.0.41 172.16.1.41 backup-41

10.0.0.51 172.16.1.51 db-51

10.0.0.61 172.16.1.61 m-61

EOF

```

查看防火墙状态

```

iptables -nL

getenforce

```

修改完成后备注模板机

```

1.精简网卡信息

2.关闭防火墙/selinux/firewalld/NetworkManager

3.优化SSH连接速度慢

4.优化命令行显示

5.配置yum源

6.安装常用软件

7.关闭邮件警告

8.定时任务配置时间同步

9.配置hosts解析

```

添加配置脚本-修改主机名,IP地址

```

[root@centos7-100 ~]# cat set_init.sh

#!/bin/bash

read -p "请输入IP地址最后一位:" ip

read -p "请输入主机名:" host_name

sed -i "/IPADDR/c IPADDR=10.0.0.${ip}" /etc/sysconfig/network-scripts/ifcfg-eth0

sed -i "/IPADDR/c IPADDR=172.16.1.${ip}" /etc/sysconfig/network-scripts/ifcfg-eth1

hostnamectl set-hostname ${host_name}

```

克隆虚拟机

从期中架构模板机-100克隆,模板机必须在关机的状态下

管理--克隆


下一步

选择快照克隆

创建链接克隆


更改新虚拟机名称


虚拟机拍摄快照


你可能感兴趣的:(2021-11-08 day30 期中架构环境准备)