架构开场优化

本文详细介绍在综合架构部署环境前所需进行的基础优化步骤,包括关闭防火墙、SELinux、NetworkManager等服务,配置普通用户使用sudo权限,修改yum源,安装常用软件,优化sshd服务,设置定时任务同步时间,以及网卡配置和本地主机解析。

综合架构部署环境前基础优化

1.关闭防火墙、SELinux、firewalld、NetworkManager

关闭SELinux

首先需要进行备份:cp /etc/selinux/config /etc/selinux/config.bak
然后通过sed关闭:'s#enforcing#disabled#g' /etc/selinux/config
通过grep检查:grep '=disabled' /etc/selinux/config
显示SELINUX=disabled表示修改成功

###关闭防火墙firewalld

先临时关闭:systemctl stop firewalld.service
然后永久关闭:systemctl disabled firewalld
进行检查:systemctl status firewalld  第三行Active: inactive (dead) 表示成功

###关闭NetworkManager.service

先临时关闭:systemtl stop NetworkManager.service
然后永久关闭:systemctl disabled firewalld.service
进行检查:systemctl status NetworkManager.service

2.添加普通用户 配置sudo

oldboy ALL=(ALL)  NOPASSWD:ALL
vim /etc/sudoers   100gg  或者visudo  100gg

##3、修改yum源及添加epel源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
mv /etc/yum.repos.d/epel.repo  /etc/yum.repos.d/epel.repo.backup
yum install -y wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

###查看yum源:yum repolist

[root@oldboyedu ~]# yum repolist 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id             repo name                                         status
!base/7/x86_64      CentOS-7 - Base - mirrors.aliyun.com              10,019
!epel/x86_64        Extra Packages for Enterprise Linux 7 - x86_64    13,190
!extras/7/x86_64    CentOS-7 - Extras - mirrors.aliyun.com               413
!updates/7/x86_64   CentOS-7 - Updates - mirrors.aliyun.com            1,862
repolist: 25,484    

##安装一些常用的软件

yum install -y tree vim wget bash-completion   bash-completion-extras  lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc  telnet-server  sshpass pssh

##优化sshd服务
###1、修改sshd.conf文件

vim /etc/ssh/sshd_config  进入后输入“/”可查找
79 GSSAPIAuthentication yes
115 UseDNS no

###2、查看修改状态

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

###3、重启sshd

[root@oldboyedu ~]# systemctl restart sshd

##修改PS1变量和网卡别名

vim /etc/profile
export PS1="\[\e[0;1m\][\[\e[34;1m\]\A \u\[\e[32;1m\]@\h \[\e[31;1m\]\\w\[\e[0m\]]\\$ "
alias rm='rm -i'
alias eth0=‘vim /etc/sysconfig/network-scripts/ifcfg-eth0’
alias eth1='vim /etc/sysconfig/network-scripts/ifcfg-eth1'

###设置定时任务自动同步时间

[root@oldboyedu ~]# crontab -e
\#/bin/bash-date
*/5 * * * *  sh ntpdate ntp.aliyun.com >/dev/null 2>&1 

###网卡配置文件中剩余以下项

TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.41
PREFIX=24
GATEWAY=10.0.0.254
DNS1=10.0.0.254

##添加本地主机解析

cat >/etc/hosts<<EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.5      lb01
172.16.1.6      lb02
172.16.1.7      web01
172.16.1.8      web02
172.16.1.31     nfs01
172.16.1.41     backup
172.16.1.51     db01 db01.etiantian.org
172.16.1.61     m01
EOF

仔细检查所有的优化,成功后关机拍摄快照
1.完整克隆
占用比较多磁盘空间
俩个机器之间没有关系
2.链接克隆
占用比较少磁盘空间
模板机删掉链接克隆机都不能用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值