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
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后即可方便使用!!!