综合架构准备

模板机

        重新安装一台 Linux

        优化

        软件

        yum

创建虚拟机

注意:一共2块网卡

        一个nat模式

        一个lan区段模式

安装系统

修改网卡名:ens××--->eth0  eth1

在安装界面 光标移动到install centos7,按tab键   在最后输入 net.ifnames=0  biosdevname=0

如果忘了在安装启动系统时修改网卡名,就等系统装完后改

vim  /boot/grub2/grub.cfg

 找到Linux16的行,找第一个就行,并在行尾加上biosdevname=0  net.ifnames=0,加完后确认下防火墙和selinux是否关闭(如果没关闭可能无法生效),然后重启虚拟机

重启动后网卡可能启动不了,xshell无法连接。

因为原来网卡名是ens33,现在被改为eth0,所以网卡配置文件可能受到影响了。

cd到/etc/sysconfig/network-scripts/

cd /etc/sysconfig/network-scripts/

把ifcfg-ens33 修改成 ifcfg-eth0

mv  ifcfg-ens33        ifcfg-eth0         

然后再到ifcfg-eth0 配置文件内的NMAE和DEVICE也改成eth0

最后重启网卡 systemctl restart network

xshell即可链接

 注意:更改网卡最好是在安装系统时完成,那样更简便快捷。

配置网卡

eth0 **.0.0.200 配置网关,DNS

eth1 172.16.1.***  不配置网关,DNS

Linux系统基础优化

1、配置yum源base,epel

2、安装常用软件

3、关闭服务器和selinux

4、ssh连接慢解决

5、网络服务 关闭NetworkManager保留network

6、配置时间同步 定时任务

关闭防火墙和selinux

# 关闭防火墙 firewalld  、  iptables

systemctl stop firewalld

systemctl disable firewalld

# 关闭selinux(增强版的安全工具)

临时关闭  setenforce 0

                getenforce     #关闭 disabled 或 Permissive selinux关闭

永久关闭  --->重启Linux系统后生效

vi /etc/selinux/config

 将上图选中的SELINUX=enforcing  修改为disabled 彻底关闭

enforcing --->selinux 启动状态

permissive---> selinux关闭状态,但是会提示警告信息

disabled  ---->selinux彻底关闭状态

配置yum源base、epel

http://mirrors.aliyun/com/repo/Centos-7.repo

配置base源

crul -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/Centos-7.repo

常用工具

yum istall -y tree    vim wget   bash-completion   bash-completion-extras  lrzsz  net-tools sysstat

iotop   iftop   htop unzip nc nmap telnet bc   psmisc httpd-tools   bind-utils nethogs

 

 ssh连接慢解决

ssh服务端配置文件

vim  /etc/ssh/sshd_config     

 

  改完重启ssh即可:systemctl  restart sshd

网络服务关闭NetworkManager保留network

systemctl disable  NetworkManager

systemctl stop NetworkManager

配置时间同步 定时任务

crontab -e  ---->  */2 * * * *  /sbin/ntpdate    ntp.aliyun.com   &>/dev/null

PS1(修改环境变量)

控制命令行格式

命令行上色:export PS1='[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[31;1m\]\w\[\e[0m\]]\\s '

永久上色:vi /etc/porfile    将上面的命令添加到最后一行

                      source  /etc/profile   立即生效   或者重新连接

 u代表用户      h代表主机名     W代表路径    w绝对路径

export PS1='[\u@\h \w]\$'  修改后显示绝对路径

hosts解析

在一个局域网中通过主机名 互相访问Linux的服务器

在公网配置DNS:img.oldboy.com --DNS  A记录 --->10.0.0.7

内网搭建的内部的DNS服务器服务(服务器数量巨大)

服务器数量不多---修改/etc/hosts文件 写入 解析记录

/etc/hosts应用场景,配置ip地址与主机名对应关系,类似于DNS

        访问自己搭建的测试环境 jd.com --->10.0.0.200   10.0.0.200    jd.com

        让局域网中的设备通过域名(主机名),互相访问

检查各项配置

检查防火墙:status firewalld.service

检查selinux:getenforce      grep SELINUX=  /etc/selinux/config

检查yum源:yum repolist

检查ssh服务:egrep -i  'GSSAPIA|UseDNS' /etc/ssh/sshd_config

检查网络服务: systemctl  status NetworkManager

同步时间定时任务: crontab -l

检查hosts解析: cat  /etc/hosts

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

万元系数

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值