详情请参阅官方文档:
http://docs.cloudstack.apache.org/projects/cloudstack-installation/en/4.9/hypervisor/kvm.html
以下为个人的安装情况,请大家视情况选择安装
开发环境:centos7.2
使用工具:KVM,NTP,libvirt/qemu
先要查看设备是否支持虚拟化KVM环境
egrep ‘(vmx|svm)’ –color=always /proc/cpuinfo
如果支持,请安装kvm软件包
yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v libguestfs-tools
以root的身份登陆到操作系统修改ip
vim /etc/sysconfig/network-scripts/ifcfg-em1
#修改
BOOTPROTO="static"
ONBOOT='yes'
#添加
IPADDR=192.168.77.18
NETMASK=255.255.255.0
确保能够与互联网通讯
vim /etc/sysconfig/network
#添加网关:
GATEWAY=192.168.77.254
需要域名解析
vim /etc/resolv.conf
nameserver 192.168.77.254
配置主机名
hostname B-KVM.china.cs
重启也更改:
vim /etc/sysconfig/network
HOSTNAME=B-KVM.china.cs
vim /etc/hosts
添加:192.168.77.16 B-KVM.china.cs
检查主机名字是否合法
hostname --fqdn
检查机器能否连接到internet
ping cloudstack.apach.org
然后关闭防火墙,以及安装iptbales-services
systemctl stop firewalld
systemctl disable firewalld
vi /etc/selinux/conf
# This file controls the state of SELinux on the system.
SELINUX=permissive
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
利用sestatus命令查看
[root@cloudstack-KVM network-scripts]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: permissive
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
[root@cloudstack-KVM network-scripts]#
yum install iptables-services -y
yum install net-tools -y
请一定要安装net-tools,因为cloudstack-agent的python脚本要使用route命令。如果不安装,在执行cloudstack-setup-agent 会failed
ntp—client
vim /etc/ntpd.conf
server 192.168.77.232
restrict 192.168.77.232 nomodify notrap noquery
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
OK,保存退出,请求服务器前,请先使用ntpdate手动同步下时间
# ntpdate -u 192.168.0.135
22 Dec 17:09:57 ntpdate[6439]: adjust time server 192.168.1.135 offset 0.004882 sec
这里有可能出现同步失败,一般情况下原因都是本地的NTPD服务器还没有正常启动起来,一般需要几分钟时间后才能开始同步。
如果还是无法同步,有一个简单粗暴的办法,禁止防火墙的启动
# service ntpd start
....
启动后,查看同步情况
# ntpq -p
# ntpstat
.....
因为是内网,一般ntpstat很快就可以同步上,几分钟需要等下.
OK,本机客户端配置完成后,使用SCP拷贝/etc/ntp.conf到其他需要同步的客户端机器,启动NTPD服务即可。
其他客户端机器上操作配置如下:
# ntpdate -u 192.168.77.232
22 Dec 17:09:57 ntpdate[6439]: adjust time server 192.168.77.232 offset 0.004882 sec
# scp 192.168.1.xxx:/etc/ntp.conf /etc/ntp.conf
# service ntpd start
查看
chkconfig |grep ntpd
提示:cloudstack-agent安装中会自动安装libvirt 以及 qemu
本人提前从官网中下载了本地文件,所以只需要使用本地安装:
yum localinstall cloudstack-common-4.9.2.0-1.el7.centos.x86_64.rpm -y
yum localinstall cloudstack-agent-4.9.2.0-1.el7.centos.x86_64.rpm -y
配置libvirt
取消以下的注释并进行修改,vim /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = “16509”
auth_tcp = “none”
mdns_adv = 0
取消以下的注释,vim /etc/sysconfig/libvirtd
LIBVIRTD_ARGS="--listen"
配置qemu
去掉以下注释,vim /etc/libvirt/qemu.conf
vnc_listen=0.0.0.0
配置agent
vim /etc/cloudstack/agent/agent.properties
host=192.168.77.18
vim /etc/idmapd.conf
Domain = china.cs
vim /etc/sysconfig/network-scripts/ifcfg-em1
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=em1
UUID=24578cfd-1f8f-420e-a0cf-70bc4483a256
DEVICE=em1
ONBOOT=yes
HWADDR=a4:ba:db:4d:44:4b
NM_CONTROLLED=yes
BRIDGE=cloudbr0
PREFIX=24
vim /etc/sysconfig/network-scripts/ifcfg-cloudbr0
TYPE=Bridge
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=cloudbr0
DEVICE=cloudbr0
ONBOOT=yes
PREFIX=24
IPADDR=192.168.77.18
GATEWAY=192.168.77.254
DNS1=8.8.8.8
DNS2=8.8.4.4
NM_CONTROLLED=yes
配置完毕,service network restart
>
iptables -I INPUT -p tcp -m tcp –dport 22 -j ACCEPT
iptables -I INPUT -p tcp -m tcp –dport 1798 -j ACCEPT
iptables -I INPUT -p tcp -m tcp –dport 16509 -j ACCEPT
iptables -I INPUT -p tcp -m tcp –dport 5900:6100 -j ACCEPT
iptables -I INPUT -p tcp -m tcp –dport 49152:49216 -j ACCEPT
写入配置文件并保存,开机启动会自动加载
$ iptables-save > /etc/sysconfig/iptables
cloudstack-setup-agent
Stopping Cloud Agent:
Starting Cloud Agent:
[root@B-KVM network-scripts]# cloudstack-setup-agent
Welcome to the CloudStack Agent Setup:
Please input the Management Server Hostname/IP-Address:[192.168.77.18]
Please input the Zone Id:[default]
Please input the Pod Id:[default]
Please input the Cluster Id:[default]
Please choose which network used to create VM:[cloudbr0]
Starting to configure your system:
Configure Cgroup … [OK]
Configure SElinux … [OK]
Configure Network … [OK]
Configure Libvirt … [OK]
Configure Firewall … [OK]
Configure Nfs … [OK]
Configure cloudAgent … [OK]
CloudStack Agent setup is done!
service cloudstack-agent restart
Stopping Cloud Agent:
Starting Cloud Agent:
service libvirtd restart
/etc/init.d/cloudstack-agent status
cloudstack-agent (pid 13952) is running…
“`
PS:如果想使用openVswitch配置网络桥接请参阅