centos7.4 创建kvm虚拟机时报错
问题:
[root@oldboy ~]# virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name centos7 --memory 1024 --vcpus 1 --disk /opt/centos2.raw,format=raw,size=10 --cdrom /root/CentOS-7-x86_64-DVD-1804.iso --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
Starting install...
Allocating 'centos2.raw' | 10 GB 00:00:00
ERROR internal error: process exited while connecting to monitor: 2019-04-26T02:40:30.310751Z qemu-kvm: -drive file=/root/CentOS-7-x86_64-DVD-1804.iso,format=raw,if=none,id=drive-ide0-0-0,readonly=on: could not open disk image /root/CentOS-7-x86_64-DVD-1804.iso: Could not open '/root/CentOS-7-x86_64-DVD-1804.iso': Permission denied
Removing disk 'centos2.raw' | 0 B 00:00:00
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:///system start centos7
otherwise, please restart your installation.
原因:
创建过程中qemu用户会读取/root/目录下的CentOS-7-x86_64-DVD-1804.iso镜像,但是qemu用户没有读取/root目录的权限,所以报错
解决方法:
将镜像移动到opt目录下,修改创建的命令,进行创建,检查端口,成功
[root@openstack ~]# mv CentOS-7-x86_64-DVD-1804.iso /opt/
[root@openstack ~]# virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name centos7 --memory 1024 --vcpus 1 --disk /opt/centos2.raw,format=raw,size=10 --cdrom /opt/CentOS-7-x86_64-DVD-1804.iso --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
[root@openstack ~]# netstat -lntup|grep 5900
tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN 2586/qemu-kvm