Created
May 21, 2018 00:47
-
-
Save novohool/87fc60f074e7281986c6fbcb6421f40f to your computer and use it in GitHub Desktop.
脱离openstack的kvm部署
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```language | |
yum -y install qemu-kvm libvirt python-virtinst bridge-utils avahi dmidecode virt-* | |
chkconfig NetworkManager off | |
service NetworkManager stop | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
vi /etc/libvirt/qemu.conf | |
vnc_listen = "0.0.0.0" | |
user = "root" | |
group = "root" | |
dynamic_ownership = 0 | |
service libvirtd start | |
service libvirtd restart | |
``` | |
``` | |
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-br0 | |
``` | |
``` | |
vi /etc/sysconfig/network-scripts/ifcfg-eth0 | |
DEVICE=eth0 | |
TYPE=Ethernet | |
ONBOOT=yes | |
NM_CONTROLLED=yes | |
BRIDGE=br0 | |
``` | |
``` | |
vi /etc/sysconfig/network-scripts/ifcfg-br0 | |
DEVICE=br0 | |
TYPE=Bridge | |
ONBOOT=yes | |
NM_CONTROLLED=yes | |
BOOTPROTO=stataic | |
IPADDR=10.0.0.156 | |
NETMASK=255.255.255.0 | |
GATEWAY=10.0.0.1 | |
DNS1=202.96.64.68 | |
DNS2=202.96.69.38 | |
``` | |
``` | |
service network restart | |
``` | |
``` | |
mkdir -p /data/kvm/vm | |
ln -s /data/kvm/ /kvm | |
cd /kvm | |
镜像下载: | |
http://mirrors.aliyun.com/centos/6.9/isos/x86_64/CentOS-6.9-x86_64-LiveDVD.iso | |
http://mirrors.aliyun.com/centos/6.9/isos/x86_64/CentOS-6.9-x86_64-minimal.iso | |
``` | |
安装虚拟机和noVNC | |
``` | |
dd if=/kvm/CentOS-6.9-x86_64-minimal.iso of=/kvm/vm/CentOS6.iso | |
virsh undefine vir-centos | |
cd /kvm/vm/ | |
qemu-img create -f qcow2 -o preallocation=metadata kvm1.img 10G | |
virt-install --name vir-centos --ram 1024 --vcpus=1 --disk path=/kvm/vm/kvm1.img,size=10 --network bridge=br0 --os-variant=rhel6 --cdrom /kvm/CentOS-6.9-x86_64-minimal.iso --vnclisten=0.0.0.0 --vncport=6900 --vnc | |
``` | |
如果name占用了: kill掉相应进程 然后 virsh undefine {相应的name} | |
虚拟机随系统启动 :virsh start {相应的name} | |
这里vnclisten 使用0.0.0.0可以直接用vnc客户端登陆 | |
使用127.0.0.1则是使用noVNC转发可直接使用浏览器登陆 | |
``` | |
vnc://116.85.11.234:6900 | |
部署noVNC | |
git clone git://github.com/kanaka/noVNC | |
cd ./noVNC/utils/ | |
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem | |
cd ../ | |
./utils/launch.sh --vnc localhost:6900 | |
访问: | |
http://116.85.11.234:6080/vnc.html?host=116.85.11.234&port=6080 | |
``` | |
 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment