在centos 6 環境下KVM的安裝部分,我寫過kvm虛擬化小結(一)kvm環境安裝 。由於centos 7較之前的版本有了很大的變化,目前測試了centos 7 環境下kvm的安裝與搭建,具體如下。
一、安裝kvm 軟體
由於之前已做過較詳細的 kvm 的安裝與總結,這裡只大致列下步驟:
代碼如下 |
複製代碼 |
[root@361way ~]# yum -y install qemu-kvm libvirt virt-install bridge-utils [root@361way ~]# lsmod | grep kvm # make sure modules are loaded kvm 441119 0 [root@361way ~]# systemctl start libvirtd [root@361way ~]# systemctl enable libvirtd
|
註:centos7上服務的管理方式換成了systemctl 。
二、配置網卡橋接
centos7上預設已不再是eth0、eth1 ,我的pc server上安裝好的第一塊網卡變成了enp3s0 ,修改步驟和centos 6上沒有區別,如下
代碼如下 |
複製代碼 |
[root@361way ~]# cd /etc/sysconfig/network-scripts/ [root@361way network-scripts]# cat ifcfg-br0 TYPE=Bridge BOOTPROTO=none DEVICE=br0 ONBOOT=yes IPADDR0=192.168.0.102 PREFIX0=24 GATEWAY0=192.168.0.1 [root@361way network-scripts]# cat ifcfg-enp3s0 DEVICE=enp3s0 TYPE=Ethernet ONBOOT=yes BRIDGE=br0 [root@361way ~]reboot [root@361way network-scripts]# ifconfig br0: flags=4163 mtu 1500 inet 192.168.0.102 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::7a24:afff:fe46:ca60 prefixlen 64 scopeid 0x20 ether 78:24:af:46:ca:60 txqueuelen 0 (Ethernet) RX packets 129 bytes 14676 (14.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 148 bytes 21994 (21.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp3s0: flags=4163 mtu 1500 ether 78:24:af:46:ca:60 txqueuelen 1000 (Ethernet) RX packets 129 bytes 16482 (16.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 148 bytes 21994 (21.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 9 bytes 728 (728.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 9 bytes 728 (728.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099 mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether a6:88:9f:14:b2:66 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1 bytes 90 (90.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@361way network-scripts]# ip add show 1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp3s0: mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000 link/ether 78:24:af:46:ca:60 brd ff:ff:ff:ff:ff:ff 3: br0: mtu 1500 qdisc noqueue state UP link/ether 78:24:af:46:ca:60 brd ff:ff:ff:ff:ff:ff inet 192.168.0.102/24 brd 192.168.0.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::7a24:afff:fe46:ca60/64 scope link valid_lft forever preferred_lft forever 4: virbr0: mtu 1500 qdisc noqueue state DOWN link/ether a6:88:9f:14:b2:66 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever
|
註:由於ip 命令屬於iproute2軟體包中的工具,由於代替舊的ifconfig命令,儘可能的習慣使用新的命令和工具包來淘汰老的軟體和工具。
三、selinux防火牆關閉
代碼如下 |
複製代碼 |
# setenforce 0 # sed -i 's/=enforcing/=disabled/g' /etc/selinux/config |