kvm环境预安装
#先安装 qemu-kvm-rhev
echo "[qemu-kvm-rhev]
name=oVirt rebuilds of qemu-kvm-rhev
baseurl=http://resources.ovirt.org/pub/ovirt-3.5/rpm/el7Server/
mirrorlist=http://resources.ovirt.org/pub/yum-repo/mirrorlist-ovirt-3.5-el7Server
enabled=1
skip_if_unavailable=1
gpgcheck=0
" > /etc/yum.repos.d/qemu-kvm-rhev.repo
yum install bridge-utils qemu-kvm-rhev centos-release-qemu-ev qemu-img virt-manager libvirt libvirt-daemon-kvm libvirt-python virt-manager libvirt-client virt-install virt-viewer libguestfs libguestfs-tools libguestfs-winsupport -y
yum install -y libvirt-devel gcc
export LIBGUESTFS_BACKEND=direct
service libvirtd start
systemctl enable libvirtd
systemctl start libvirtd
firewall-cmd --permanent --zone=trusted --add-port=1234/tcp --permanent
firewall-cmd --reload
wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
yum install virtio-win
更新:
关于hz的出口,不可以直接绑定br0
创建public
支持ipv4转发
1.临时开启,(写入内存,在内存中开启)
echo "1" > /proc/sys/net/ipv4/ip_forward
2.永久开启,(写入内核)
在 vim /etc/sysctl.conf 下
加入此行 net.ipv4.ip_forward = 1
sysctl -p # 加载一下,使之生效
3.防火墙放通转发(以iptables为例)
iptables -I FORWARD -j ACCEPT
service iptables save
如果save不存在,则
首先停止防火墙
1.systemctl stop firewalld
2.systemctl mask firewalld
然后安装iptables-services
3.yum install iptables-services
设置开机启动防火墙
4.systemctl enable iptables
可以使用下面命令管理iptables
5.systemctl [stop|start|restart] iptables
这时可以保存防火墙规则了
6.service iptables save
or
/usr/libexec/iptables/iptables.init save
如果存在网络异常,则systemctl restart network
更新
Windows server 2016存在蓝屏问题,解决方法:
echo 1 > /sys/module/kvm/parameters/ignore_msrs
echo 0 > /sys/module/kvm/parameters/report_ignored_msrs
echo "options kvm ignore_msrs=1 report_ignored_msrs=N" | sudo tee /etc/modprobe.d/kvm-ignore-msrs.conf
supervisor
yum install supervisor -y
systemctl enable supervisord
echo "
[program:node]
directory = /root/node/ ; 程序的启动目录
command = /root/node/node ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
stdout_logfile = /root/node/stdout.log
" > /etc/supervisord.d/node.ini
mkdir /etc/libvirt/hooks
for f in daemon qemu lxc libxl network; do echo '#!/bin/sh
iptables-restore < /etc/sysconfig/iptables
iptables -I FORWARD -j ACCEPT' > "/etc/libvirt/hooks/$f"; chmod +x "/etc/libvirt/hooks/$f"; done
service libvirtd restart