配置dhcpd服务器动态分配ip到客户端
服务器desktop
cd /etc/yum.repo.d/
ls
vim rhel_dvd.repo
修改:
baseurl = http://172.25.254.250/rhel7
yum clean all
yum install vsftpd lftp -y
vim dhcpd.conf
cp /usr/share/doc/dhcp*/dhcpd.conf.example/etc/dhcp/dhcpd.conf
ls
cd /etc/dhcp
vim dhcpd.conf
{
7行 optiondomain-name "example.com"
8行 optiondomain-name 114.114.144.114;
27行 28行 删除subnet 10 ~ 255.0{ }
倒数删除后面的行数删除到倒数34行
把30行到33行修改为
subnet 172.25.254.0 netmask255.255.255.0 {
rang 172.25.254.200 172.25.254.100;
option routers 172.25.254.250;
}
systemctl start dhcpd 开启dhcpd服务
systemctl status dhcpd 查看dpcpd的状态
Systemctl enable dhcpd 开机启动dhcpd
开启dhcpd服务
cat /var/lib/dhcpd/dhcpd.leases
查看dhcp分配的动态ip
与硬件网卡mac
实验结果
查看客服端的server分配到的动态ip与网卡硬件mac
qemu kvm 硬件文件 qemuimg 硬盘文件
安装图形5g 图形cpu800mb
swap 500 暂时存内存
boot 200 开机文件空间
/ 空 根分区
$1 把外部的数据传到内部
sh 后面跟什么就输出什么
$* 表示所有文件
& 后台运行
sh westos 输出westos
Disk bus 硬盘类型
运用脚本自动化安装虚拟机
1 #!/bin/bash
2 virt-install \
3 --cdrom /home/kisk/Desktop/rhel-server-7.0-x86_64-dvs.iso \ 镜像的安装位置
4 --ram 1024 \ 内存
5 --cpus 1 \ cpu核心数
6 --disk /var/lib/libvirt/images/$1.qcow2,size=9,bus=virtio \虚拟硬盘镜像文件
7 --name $1 \ 把外部输入的文件名导入脚本
8 --network source=br0,model=virtio & 虚拟网卡 &后台运行
iso文件 chmod 755权限
判断虚拟机好不好
给硬件硬盘更改为虚拟硬盘
虚拟机开不了 虚拟机坏
给安装的虚拟机照片,根据Linux的系统7.2 7.0分成qcow2 img 硬盘文件
Xml为虚拟的硬件文件
cd /var/lib/libvirt
显示有qemu存放xml硬件文件目录
显示有images存放img硬盘文件的目录
Cd/images/
ls
目录显示有sing.img硬盘文件
qemu-img create -f qcow2 -b sing.img node1.qcow2输入硬盘拍照命令
Ls
node1.qcow2 显示有node1 这个拍照文件
查看目录
存在qemu目录内的xml硬件文件 images的硬盘文件对
假设移动虚拟机进行恢复
mv sing.img /mnt/
把img硬盘文件移动到/mnt/目录
cd /var/lib/libvirt/qemu/
mv sing.xml /mnt/
把xml 硬件文件移动到/mnt/目录
输入virsh undefinesing卸载虚拟机
对虚拟进行恢复
把/mnt/下的xml硬件文件移动到/etc/libvirt/qemu/
把/mnt/下的img硬盘文件移动到/etc/libvirt/images/
假设只有img文件没有硬件文件可以在Virt-Manager
中import exiting disk image 导入文件
[root@foundation77 images]# cd /mnt/
[root@foundation77 mnt]# mv sing.img/var/lib/libvirt/images/
[root@foundation77 mnt]# ls
vm_create.sh
[root@foundation77 mnt]# virsh createsing.xml 一次性恢复系统img
error: Failed to open file 'sing.xml':No such file or directory
[root@foundation77 mnt]# virsh createdefine sing.xml 永久恢复系统img
error: Failed to open file 'define': Nosuch file or directory
制作照片
倒入到虚拟机
Disk bus 硬盘类型