《Center OS KVM安装配置手册(6页).doc》由会员分享,可在线阅读,更多相关《Center OS KVM安装配置手册(6页).doc(6页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-Center OS KVM安装配置手册-第 6 页KVM安装配置手册一检查确认服务器是否开启CPU虚拟化功能# lsmod | grep kvmkvm_intel 170086 0kvm 566340 1 kvm_intelirqbypass 13503 1 kvm# echo ulimit -SHn 65535 /etc/profile# source /etc/profile# ulimit n# yum check-update & yum updaye -y# yum groupinstall “Development Tools”二KVM Network#yum install -
2、ybridge-utils新增网桥设备br0配置文件#vim /etc/sysconfig/network-scripts/ifcfg-br0DEVICE=br0ONBOOT=yesTYPE=BridgeBOOTPROTO=staticDEFROUTE=yesNM_CONTROLLED=no修改ifcfg-em1:# cat /etc/sysconfig/network-scripts/ifcfg-em1TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6
3、INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=em1UUID=c72f60ed-4e17-4297-8a16-ed3c9ab02e7dDEVICE=em1ONBOOT=yes#IPADDR=172.168.1.160#PREFIX=24#GATEWAY=172.168.1.1#DNS1=202.96.209.133#DNS2=114.114.114.114#DNS3=202.96.199.133IPV6_PRIVACY=noNM_CONTR
4、OLLED=noBRIDGE=br0蓝色注释 红色新加# systemctl disable NetworkManager# systemctl stop NetworkManager# systemctl restart network# ifconfig三Install KVM# yum -y install qemu-kvm libvirt virt-install bridge-utils policycoreutils-python# systemctl start libvirtd# systemctl enable libvirtd四安装桥接网络创建br0.xml 配置文件(文件
5、中uuid保证唯一即可br0fb48b969-b9f4-e859-d957-50aedd850fb4 virsh net-undefine br0 删除桥接网络# virsh net-list -all# virsh net-start br0# virsh net-autostart br0# virsh net-list -all# mkdir /var/kvm# semanage fcontext -a -t virt_image_t /var/kvm(/.*)?# restorecon -vvFR /var/kvm/五安装系统CentOS7# qemu-img create /var/
6、kvm/centos7-base.img 10G# virt-install -virt-type kvm -name centos7-base -ram 1200 -disk /var/kvm/centos7-base.img -network bridge=br0 -graphics vnc,listen=0.0.0.0 -noautoconsole -os-type=linux -os-variant=centos7.0 # firewall-cmd -permanent -add-service=vnc-server# firewall-cmd -reload通过VNC连接服务器IP,
7、举例172.168.1.160(宿主机)进行系统安装步骤操作安装系统要素:地区:Asia/Shanghai语言:English + 中文简体支持Software Selection:Basic WebServerInstallation Source:I will configure partitioning.重点/boot 1024Mswap 8172M 等同于内存大小值M/ 剩余全部三个分区:/boot、swap、/ 根目录,分区Standard Partion 或 LVM,默认磁盘格式xfsNetwork:选择已连接的网卡eth0 设定固定ip,且开启网卡安装完系统,重启虚拟机,再次VN
8、C连接虚拟机Enable KVM Guest console# grubby -update-kernel=ALL -args=console=ttyS0# vim/etc/default/grubfile, add console=ttyS0 to theGRUB_CMDLINE_LINUXGRUB_CMDLINE_LINUX=crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet console=ttyS0Now, reboot the virtual machine:# reboot# virsh console c
9、entos7-base/现在可以通过console 连接,VNC方式已不可用源镜像centos7-base配置完毕后,即可克隆机器# virsh suspend centos7-base /必须先挂起,完成后virsh resume centos7-base# virt-clone -connect qemu:/system -original centos7-base 源VM -name cybs-172.168.1.159 Name定义IMGvirt-clone -connect qemu:/system -original centos7-base 72 -.img# virsh lis
10、t -all/显示所有VM# virsh console /connect vm更改克隆VM的对应IP及UUID末位数字为IP末两尾VM# systemctl restart networkVM# hostnamectl set-hostname hostname/修改hostname名称六销毁VM(补充)# virsh shutdown centos7-base# virsh undefine centos7-base复制镜像源到另一台机器,进行克隆rootdev160 # mkdir /var/kvmrootdev74 # scp centos7-base.xml root172.168.
11、1.160:rootdev74 # scp /var/kvm/centos7-base.img root172.168.1.160:/var/kvm/rootdev160 # semanage fcontext -a -t virt_image_t /var/kvm(/.*)?rootdev160 # restorecon -vvFR /var/kvm/rootdev160 # virsh define /root/rootdev160 # virsh start centos7-baserootdev160 # virsh console centos7-base七KVM Rename VM# virsh shutdown vm# virsh domrename vm vm1# virsh start vm1