【百炼成魔】Linux学习环境准备
  xgwtwgn2FgJ6 2023年11月02日 31 0

前言

本文以centos7.9为例,准备前期学习环境,确保学习效果,降低学习难度,后续在逐步增加学习难度,逐层升级打怪。

实验环境搭建过程

1. 清空防火墙
[root@gaosh-63 ~]# iptables -F   ## 清空防火墙规则
[root@gaosh-63 ~]# systemctl stop firewalld   ## 关闭防火墙
[root@gaosh-63 ~]# systemctl disable firewalld   ## 设置开机不启动防火墙
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@gaosh-63 ~]# 

2. 关闭selinux
1)临时关闭selinux
[root@gaosh-63 ~]# setenforce 0  ##临时关闭selinux
[root@gaosh-63 ~]# getenforce   ## 查看selinux状态
Permissive

2) 永久关闭selinux

配置文件: /etc/selinux/config 把下图的: 在这里插入图片描述 改为:

SELINUX=disabled

注意: 永久关闭selinux,需要重启生效。

3. 配置静态IP

为了做实验方便,一定要配置静态IP,防止关机后IP改变。

配置文件如下:

[root@gaosh-63 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32

在这里插入图片描述

关闭NetworkManager

[root@gaosh-63 ~]# systemctl stop NetworkManager
[root@gaosh-63 ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.

4. 修改主机名

很多人做实验,都是用localhost,三台服务器做实验,三台的主机名都是localhost,不方便区分。

所以我们把域名改成 公司名-Ip最后两位的形式。 比如公司叫致码教育(zmedu),本机的IP为192.168.1.64, 那我们可以定义主机名为: zmedu-64

配置文件:/etc/hostname

[root@gaosh-63 ~]# cat /etc/hostname
gaosh-64

配置完后需要重启,当然现在不需要重启,等全部配置完后重启即可

5. 配置主机名与IP的映射关系

添加ip与主机名的对应关系

vim /etc/hosts
192.168.0.64  gaosh-64
6. 配置yum源

一般centos7的网络yum源,其实都可以直接用,当然你也可以配置本地yum源。

配置文件 [root@gaosh-1 ~]# vim /etc/yum.repos.d/centos7.repo

[centos]
name=centos-repo
baseurl=file:///mnt
enabled=1
gpgcheck=0

挂载:

[root@gaosh-1 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only

查看是否挂载成功

在这里插入图片描述

7. 重启创建快照

reboot 按照下图创建快照

image.png

总结

做好一次实验环境,下次没做实验的时候都可以还原快照,不用一次次重装系统,当然,如果你是用的云服务器,也一样可以创建快照。

17aca22d22f92b7d69422729651bb6d.png

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  6YY0QMPUXEwu   2023年12月10日   32   0   0 linux网卡
  nIt0XG0acU8j   2023年12月11日   34   0   0 linuxhtop
  Yoru5qB4TSKM   2023年12月10日   43   0   0 服务器重启IP
  nIt0XG0acU8j   2023年12月09日   39   0   0 linuxsort