1.安装虚拟机
2.设定虚拟机的基础配置
(1)删除文件
由于mac地址不匹配,如果不删除该文件,重启网络时会报错
cd /etc/udev/rules.d/
rm -f 70-persistent-net.rules
(2)设定ip
cd /etc/sysconfig/network-scripts/
vi ifcfg-eth1
/etc/init.d/network restart #重启网络
(3)配置yum源
前提:虚拟机和物理机可以通信
#发现网络不可达
[root@foundation66 ~]# ping 172.25.66.1
PING 172.25.66.1 (172.25.66.1) 56(84) bytes of data.
^C
--- 172.25.66.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms
#查看网桥,发现是网桥未连接
[root@foundation66 ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.54ee75c50823 no enp3s0
virbr0 8000.525400f8acd9 yes virbr0-nic
#给br0接口桥接vnet0设备
[root@foundation66 ~]# brctl addif br0 vnet0
#查看网桥
[root@foundation66 ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.54ee75c50823 no enp3s0
vnet0
virbr0 8000.525400f8acd9 yes virbr0-nic
#测试:此时便可以通信
[root@foundation66 ~]# ping 172.25.66.1
PING 172.25.66.1 (172.25.66.1) 56(84) bytes of data.
64 bytes from 172.25.66.1: icmp_seq=1 ttl=64 time=0.255 ms
64 bytes from 172.25.66.1: icmp_seq=2 ttl=64 time=0.202 ms
^C
--- 172.25.66.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.202/0.228/0.255/0.030 ms
1).下载镜像
rhel-server-6.5-x86_64-dvd.iso
2).共享镜像(在物理机中)
只需将镜像挂载到apache的默认发布目录下即可实现共享镜像资源
[root@foundation66 Desktop]# mv rhel-server-6.5-x86_64-dvd.iso /iso/
[root@foundation66 Desktop]# cd /iso/
[root@foundation66 iso]# ls
rhel-server-6.5-x86_64-dvd.iso rhel-server-7.4-x86_64-dvd.iso
rhel-server-7.0-x86_64-dvd.iso rhel-server-7.5-x86_64-dvd.iso
rhel-server-7.2-x86_64-dvd.iso
[root@foundation66 ~]# mkdir /var/www/html/rhel6.5
#先临时挂载(因为永久性挂载需要reboot才能生效)
[root@foundation66 ~]# mount /iso/rhel-server-6.5-x86_64-dvd.iso /var/www/html/rhel6.5
mount: /dev/loop3 is write-protected, mounting read-only
[root@foundation66 ~]# df
#设定开机自动挂载
[root@foundation66 ~]# vim /etc/rc.local
######################
mount /iso/rhel-server-6.5-x86_64-dvd.iso /var/www/html/rhel6.5/
#给脚本一个可执行权限
[root@foundation66 ~]# chmod +x /etc/rc.d/rc.local
3)编写文件:指定yum源地址
vim /etc/yum.repos.d/rhel-source.repo
#检测yum源是否配置成功
yum clean all
yum repolist
(4)下载常用软件
yum install -y vim lftp openshh-clients
(5)更改主机名
hostname server1 #临时性更改主机名
hostname
vim /etc/sysconfig/network #永久性更改主机名
(6)本地解析
vim /etc/hosts
(7)关闭防火墙
#关闭防火墙(两种)
/etc/init.d/iptables stop
/etc/init.d/ip6tables stop
#开机自动关闭
chkconfig iptables off
chkconfig ip6tables off
(8)关闭selinux
vim /etc/sysconfig/selinux
9)关机
poweroff # 注意:一定不能重启 ,否则刚才的操作就都无效了
3.制作快照
制作快照:是为了保护母盘,如果快照坏了,重新再照即可,但若是母盘坏了就得重新封装虚拟机
[root@foundation66 ~]# cd /var/lib/libvirt/images/
[root@foundation66 images]# ls
node1-1.qcow2 node4.qcow rh124-desktop-vda.qcow2 rh124-server-vdb.qcow2
node1-2.qcow2 node4.qcow2 rh124-desktop-vdb.ovl rh124-server.xml
node1.qcow2 node5-1.qcow2 rh124-desktop-vdb.qcow2 rhel6.5.qcow2
node2-1.qcow2 node5-2.qcow2 rh124-desktop.xml rhel7.2.qcow2
node2-2.qcow2 node5.qcow2 rh124-server-vda.ovl
node2.qcow2 node6.qcow2 rh124-server-vda.qcow2
node3.qcow2 rh124-desktop-vda.ovl rh124-server-vdb.ovl
#创建快照
[root@foundation66 images]# qemu-img create -f qcow2 -b rhel6.5.qcow2 test1.qcow2
Formatting 'test1.qcow2', fmt=qcow2 size=21474836480 backing_file='rhel6.5.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
[root@foundation66 images]# qemu-img create -f qcow2 -b rhel6.5.qcow2 test2.qcow2
Formatting 'test2.qcow2', fmt=qcow2 size=21474836480 backing_file='rhel6.5.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
[root@foundation66 images]# qemu-img create -f qcow2 -b rhel6.5.qcow2 test3.qcow2
Formatting 'test3.qcow2', fmt=qcow2 size=21474836480 backing_file='rhel6.5.qcow2' encryption=off cluster_size=65536 lazy_refcounts=off
4.导入快照
更改ip
ip addr #查看系统中存在的网卡设备,发现只有eth1网卡设备
vim /etc/sysconfig/network-scripts/ifcfg-eth1 #更改ip