创建镜像
kvm-img create -f raw centos.img 5G
启动安装
kvm -m 2048 -cdrom CentOS-6.2-i386.iso -drive file=centos.img -boot d -net nic -nographic -vnc :1
操作安装过程
vncviewer 192.168.139.50:5901
再次启动安装好的镜像
kvm -m 2048 -drive file=centos.img -boot c -net nic -nographic -vnc :1
在虚拟机内部安装ssh,以便可以远程登录实例
yum install openssh-server
service sshd start (虚拟机内部)
chkconfig sshd on (不然,重启又不能ssh)
上传镜像
glance add name="CentOS6.2" is_public=true container_format=ovf disk_format=raw < centos.img
要使虚拟机内部访问外网,需要在节点上执行
sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1 (vi /proc/sys/net/ipv4/ip_forward)