rhel7虚拟机的封装

编程入门 行业动态 更新时间:2024-10-27 12:25:38

rhel7<a href=https://www.elefans.com/category/jswz/34/1770279.html style=虚拟机的封装"/>

rhel7虚拟机的封装

文章目录

    • 1.服务器初始化
    • 2.禁用selinux
    • 3.禁用防火墙
    • 4.配置yum源
    • 5.配置网络
    • 6.时间同步
    • 7.主机名解析
    • 8.关闭NetworkManager
    • 9.完成封装


1.服务器初始化

系统环境RHEL7.6









2.禁用selinux

[root@server1 ~]# vim /etc/sysconfig/selinux
SELINUX=disabled


reboot

3.禁用防火墙

[root@server1 ~]# systemctl disable --now firewalld

4.配置yum源

[root@server1 ~]# vim /etc/fstab
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=ddb06c77-c9da-4e92-afd7-53cd76e6a94a /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /media iso9660 defaults 0 0

[root@server1 ~]# mount -a
[root@server1 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/rhel-root 38770180 1184408 37585772 4% /
devtmpfs 1001876 0 1001876 0% /dev
tmpfs 1014056 0 1014056 0% /dev/shm
tmpfs 1014056 9764 1004292 1% /run
tmpfs 1014056 0 1014056 0% /sys/fs/cgroup
/dev/sr0 4391278 4391278 0 100% /media

[root@server1 ~]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=rhel7.6
baseurl=file:///media
gpgcheck=0

[root@server1 ~]# yum install -y vim net-tools bash-completion bash-*

5.配置网络

[root@server1 ~]# vim /boot/grub2/grub.cfg
添加内核参数,修改网卡命名: net.ifnames=0

需要重启系统才能生效
[root@server1 ~]# reboot

根据自己实际网络地址段来修改
[root@server1 ~]# cd /etc/sysconfig/network-scripts/
[root@server1 network-scripts]# vim ifcfg-eth0
BOOTPROTO=static
IPADDR=192.168.56.11
PREFIX=24
GATEWAY=192.168.56.2
DNS1=114.114.114.114
NAME=eth0
DEVICE=eth0
ONBOOT=yes

[root@server1 network-scripts]# systemctl restart network


NAT模式的ip与Windows的ip可能不是一个网段,每次都是分配而来!!!建议设置时还原默认网络设置后,根据NAT网段设置虚拟机网关和ip!!!

ping

6.时间同步

[root@server1 ~]# yum install -y chrony

[root@server1 ~]# vim /etc/chrony.conf
server ntp1.aliyun.com iburst

[root@server1 ~]# systemctl restart chronyd

[root@server1 ~]# chronyc sources -v
210 Number of sources = 1

.-- Source mode ‘^’ = server, ‘=’ = peer, ‘#’ = local clock.
/ .- Source state ‘*’ = current synced, ‘+’ = combined , ‘-’ = not combined,
| / ‘?’ = unreachable, ‘x’ = time may be in error, ‘~’ = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | |
MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================
^* 120.25.115.20 2 7 363 15 +504us[ +617us] +/- 18ms


7.主机名解析

[root@server1 ~]# hostnamectl set-hostname server1
[root@server1 ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.11 server1
192.168.56.12 server2
192.168.56.13 server3
192.168.56.14 server4
192.168.56.15 server5
192.168.56.16 server6

8.关闭NetworkManager

9.完成封装

虚拟机封装好以后直接关机,后面不要再启动了;新建虚拟机只需要克隆此虚拟机,更改主机名和ip后即可方便使用!!!

更多推荐

rhel7虚拟机的封装

本文发布于:2023-06-17 08:26:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/756080.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:虚拟机

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!