33-综合架构环境准备及优化

image.png

一、环境准备

1.1 创建一台全新的虚拟机

添加2个网卡
NAT----- 10.0.0.201 模拟公网
LAN区段---- 172.16.1.201 模拟内网

[root@oldboyedu /etc/sysconfig/network-scripts]# vim ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.201
PREFIX=24
GATEWAY=10.0.0.254
DNS1=10.0.0.254
[root@oldboyedu /etc/sysconfig/network-scripts]# vim ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.1.201
PREFIX=24
注:内网不需要配置DNS和网关

1.2 CentOS 6与CentOS 7的区别

https://www.jianshu.com/p/d6d9a49e95c9

二、 环境优化

2.1 优化ssh连接,解决ssh连接速度慢的问题

1>vim /etc/ssh/sshd_config
2>搜索UseDNS,将yes改为no ##远程连接的时候,关闭把ip地址转为域名
3>搜索GSSAPIAuthentication,将yes改为no
4>检查

[root@oldboyedu ~]# egrep -n '^(GSSAPIA|UseDNS)' /etc/ssh/sshd_config
79:GSSAPIAuthentication no
115:UseDNS no
[root@oldboyedu ~]#

5>重启对应的服务:systemctl restart sshd.service

2.2 如何检查服务的状态

1>如何检查服务是否正在运行

systemctl is-active firewalld NetworkManager crond
注:当状态显示active表示正在运行,否则就是没有运行

2>如何检查服务是否开机自启动

systemctl is-enabled firewalld NetworkManager crond
注:当状态显示enabled表示开机自启动, disabled表示没有开机自启动

2.3 配置yum源(为了提高速度,改为阿里云的yum源)

查看自己的yum源:yum repolist
1>下载网址:https://opsx.alibaba.com/mirror
2>Ctrl + f 网页搜索centos,点击操作列的“帮助”
3>先备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

4>选择最新的yum源

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

5>之后运行yum makecache生成缓存

2.4 配置epel源

1>下载网址:https://opsx.alibaba.com/mirror
2>Ctrl + f 网页搜索epel,点击操作列的“帮助”
3>备份(如有配置其他epel源)

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

4>下载新repo 到/etc/yum.repos.d/

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

注:配置epel源,需要先安装wget,yum install -y wget

2.5 常见工具安装

yum install -y tree vim wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc ntpdate cowsay sl sshpass pssh bind-utils axel(多线程下载,如:axel -n 10 要下载的地址)

2.6 关闭SELinux

1>操作前备份 操作后检查

cp /etc/selinux/config /etc/selinux/config.bak

2>临时关闭SELinux(重新登录系统失效)

getenforce 查看SELinux状态
setenforce 修改SELinux状态
setenforce 0 修改SELinux状态

3>永久关闭SELinux(会在服务器重启之后生效)

修改配置文件 /etc/selinux/config中SELINUX=disabled
enforcing:SELinux开启
permissive:SELinux关闭 还会有警告信息
disabled:SELinux彻底关闭

4>检查SELinux状态

[root@linuxfuxiji01 ~]# grep '=disabled' /etc/selinux/config
SELINUX=disabled

注:如果在工作中,服务器无法重启的时候,临时和永久都要修改

2.7 关闭防火墙

1>临时关闭防火墙(重启服务器失效)

systemctl stop firewalld(start开启)

2>永久关闭防火墙(重启服务器失效)

systemctl disable firewalld(enable永久开启)

3>检查防火墙

systemctl status firewalld(检查防火墙的状态)

注:如果在工作中,服务器无法重启的时候,临时和永久都要修改

2.8 关闭NetworkManager的状态

1>永久关闭NetworkManager(重启生效)

systemctl disable NetworkManager

2>检查NetworkManager的状态

systemctl status NetworkManager

2.9 修改PS1环境变量

1>vim /etc/profile将下面的命令追加到最后一行

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

2>使变量生效:source /etc/profile

2.10 添加oldboy用户,visudo配置oldboy

[root@oldboyedu ~]# grep oldboy /etc/sudoers  
oldboy ALL=(ALL) NOPASSWD:ALL  
[root@oldboyedu ~]#

最后,这些优化完成之后,检查没有问题进行拍摄快照

三、 克隆虚拟机

3.1 简单介绍:

完整克隆:

好处:两台机器之间没有任何关系
缺点:占用比较多磁盘空间

链接克隆:

好处:磁盘空间占用比较少
缺点:模板机删除,其余克隆的虚拟机都无法使用

3.2 克隆2台虚拟机器

第一台(综合架构-backup-10.0.0.41)
  修改主机名:hostnamectl set-hostname backup  刷新(su -)或重连xshell
  修改2块网卡的ip地址:
    eth0:IPADDR=10.0.0.41
    eth1:IPADDR=172.16.1.41
    网卡重启生效 systemctl restart network
第二台(综合架构-nfs01-10.0.0.31)
  修改主机名:hostnamectl set-hostname nfs01  刷新(su -)或重连xshell
  修改2块网卡的ip地址:
    eth0:IPADDR=10.0.0.31
    eth1:IPADDR=172.16.1.31
    网卡重启生效 systemctl restart network

你可能感兴趣的:(33-综合架构环境准备及优化)