Cloudstack-agent KVM计算节点的安装

来源:互联网 发布:java mvc web项目实例 编辑:程序博客网 时间:2024/05/18 12:01

详情请参阅官方文档:

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

1.操作系统的准备

以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]# sestatusSELinux status:                 enabledSELinuxfs mount:                /sys/fs/selinuxSELinux root directory:         /etc/selinuxLoaded policy name:             targetedCurrent mode:                   permissiveMode from config file:          permissivePolicy MLS status:              enabledPolicy deny_unknown status:     allowedMax 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.13522 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.23222 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

2.安装cloudstack-agent

提示:cloudstack-agent安装中会自动安装libvirt 以及 qemu
本人提前从官网中下载了本地文件,所以只需要使用本地安装:

yum localinstall cloudstack-common-4.9.2.0-1.el7.centos.x86_64.rpm -yyum localinstall cloudstack-agent-4.9.2.0-1.el7.centos.x86_64.rpm -y

配置libvirt

取消以下的注释并进行修改,vim /etc/libvirt/libvirtd.conflisten_tls  = 0listen_tcp  = 1tcp_port  =  “16509”auth_tcp  =  “none”mdns_adv  = 0取消以下的注释,vim /etc/sysconfig/libvirtdLIBVIRTD_ARGS="--listen"

配置qemu

去掉以下注释,vim /etc/libvirt/qemu.confvnc_listen=0.0.0.0

配置agent

vim  /etc/cloudstack/agent/agent.properties host=192.168.77.18vim /etc/idmapd.confDomain = china.cs

3.配置桥接网络

vim /etc/sysconfig/network-scripts/ifcfg-em1TYPE=EthernetBOOTPROTO=noneDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=yesIPV6INIT=noIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noNAME=em1UUID=24578cfd-1f8f-420e-a0cf-70bc4483a256DEVICE=em1ONBOOT=yesHWADDR=a4:ba:db:4d:44:4bNM_CONTROLLED=yesBRIDGE=cloudbr0PREFIX=24vim /etc/sysconfig/network-scripts/ifcfg-cloudbr0TYPE=BridgeBOOTPROTO=staticDEFROUTE=yesIPV4_FAILURE_FATAL=yesIPV6INIT=noNAME=cloudbr0DEVICE=cloudbr0ONBOOT=yesPREFIX=24IPADDR=192.168.77.18GATEWAY=192.168.77.254DNS1=8.8.8.8DNS2=8.8.4.4NM_CONTROLLED=yes

配置完毕,service network restart

4.打开指定端口

>
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

5.启动cloudstack-agent

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配置网络桥接请参阅

http://blog.sina.com.cn/s/blog_66679c450102vl9f.html

原创粉丝点击