前言

CloudStack 和OpenStack 一样都是IaaS层 开源框架,可以管理XenServer、ESXI、KVM、OVM等主流虚拟机,相对OpenStack比较简单、稳定;

二、Cloud Stack架构

Zone:相当于现实中的1个数据中心,它是CloudStack中最大的一个单元

Pod(机柜):1个Zone包含N个Pod

Pod(集群):1个Pod包含N个Cluster

Host(主机):1个Cluster包含N个Host

三、基于centos7安装Cloud Stack4.8.0

1.下载cloudstack4.8.0

Management

Common

Agent

2.修改hostname 和 hosts文件

agent1

vim /etc/hostname

192.168.226.159 master1

vim /etc/hosts

检查主机名是否修改成功?

[root@master1 zhanggen]# hostname --fqdn
master1

hostname --fqdn

3.关闭Selinux和Firewalld

setenforce
systemctl stop firewalld.service

setenforce 0 && systemctl stop firewalld.service

4.安装epel yum源

yum -y install epel*

yum -y install epel*

5.安装 ntp服务 保证主从间时间同步 

 yum -y install ntp

yum -y install ntp

启动ntpd服务

[root@master1 zhanggen]# chkconfig ntpd on
注意:正在将请求转发到“systemctl enable ntpd.service”。
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
[root@master1 zhanggen]# systemctl enable ntpd.service
[root@master1 zhanggen]#

systemctl enable ntpd.service

6.安装nfs服务

yum -y install nfs-utils

yum -y install nfs-utils

配置

/export/secondary *(rw,async,no_root_squash,no_subtree_check)

vim /etc/exports

LOCKD_TCPPORT=
LOCKD_UDPPORT=
MOUNTD_PORT=
STATD_PORT=
RQUOTAD_PORT=
STATD_OUTGOING_PORT=

vim /etc/sysconfig/nfs

启动nfs、rpcbind 服务

systemctl start nfs

systemctl start nfs

[root@master1 /]# systemctl start rpcbind

systemctl start rpcbind

7.master1主节点和 agent从节点挂载NFS

master1主节点

[root@master1 /]# echo "/dev/sdb /export/secondary ext4 defaults 0 0 " >> /etc/fstab
[root@master1 /]#

echo "/dev/sdb /export/secondary ext4 defaults 0 0 " >> /etc/fstab

agent1从节点

[root@agent1 export]#  echo "/dev/sdb /export/primary ext4 defaults 0 0 " >> /etc/fstab
[root@agent1 export]# mount -a
[root@agent1 export]# df
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda3 % /
devtmpfs % /dev
tmpfs % /dev/shm
tmpfs % /run
tmpfs % /sys/fs/cgroup
/dev/sda1 % /boot
tmpfs % /run/user/
/dev/sdb % /export/primary
[root@agent1 export]#

echo "/dev/sdb /export/primary ext4 defaults 0 0 " >> /etc/fstab

检查NFS是否挂载成功

[root@agent1 export]# showmount -e master1
Export list for master1:
/export/secondary *
[root@agent1 export]#

showmount -e master1

8.master节点

CloudStack管理端安装

cloudstack-management-4.8.0-1.el7.centos.x86_64.rpm 和 cloudstack-common-4.8.0-1.el7.centos.x86_64.rpm

[root@master1 Desktop]# ls
cloudstack-common-4.8.-.el7.centos.x86_64.rpm
cloudstack-management-4.8.-.el7.centos.x86_64.rpm
[root@master1 Desktop]# yum install cloudstack-management-4.8.-.el7.centos.x86_64.rpm cloudstack-common-4.8.-.el7.centos.x86_64.rpm

yum install cloudstack-management-4.8.0-1.el7.centos.x86_64.rpm cloudstack-common-4.8.0-1.el7.centos.x86_64.rpm

yum install mariadb-server mariadb
systemctl enable mariadb

mariadb 安装

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid #
# include all files from the config directory
#
!includedir /etc/my.cnf.d

vim /etc/my.cnf

[root@master1 /]# mysqladmin -uroot password .com
[root@master1 /]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 5.5.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> delete from mysql.user where user='';
Query OK, rows affected (0.00 sec) MariaDB [(none)]>

设置mysql密码删除空用户

[root@master1 /]# mysql -uroot -p123.com -e "GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY '123.com'";
[root@master1 /]#

给root用户授权

9.Agent 节点 安装KVM代理

[root@agent1 Desktop]# yum -y install cloudstack-agent-4.8.-.el7.centos.x86_64.rpm cloudstack-common-4.8.-.el7.centos.x86_64.rpm

yum -y install cloudstack-agent-4.8.0-1.el7.centos.x86_64.rpm cloudstack-common-4.8.0-1.el7.centos.x86_64.rpm

10.Master节点初始化数据库

[root@master1 Desktop]# rpm -qa | grep cloud
cloudstack-management-4.8.-.el7.centos.x86_64
cloudstack-common-4.8.-.el7.centos.x86_64
[root@master1 Desktop]# cloudstack-setup-databases cloud:.com@localhost --deploy-as=root:.com
Mysql user name:cloud [ OK ]
Mysql user password:****** [ OK ]
Mysql server ip:localhost [ OK ]
Mysql server port: [ OK ]
Mysql root user name:root [ OK ]
Mysql root user password:****** [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Detected local IP address as 192.168.226.159, will use as cluster management server node IP[ OK ]
Preparing /etc/cloudstack/management/db.properties [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/server-setup.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/templates.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ] CloudStack has successfully initialized database, you can check your database configuration in /etc/cloudstack/management/db.properties [root@master1 Desktop]# mysql -uroot -p123.com
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 5.5.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cloud |
| cloud_usage |
| mysql |
| performance_schema |
| test |
+--------------------+
rows in set (0.04 sec) MariaDB [(none)]>

cloudstack-setup-databases cloud:123.com@localhost --deploy-as=root:123.com Mysql user name:cloud

11.启动Master

[root@master1 management]# cloudstack-setup-management --tomcat7
Starting to configure CloudStack Management Server:
Configure Firewall ... [OK]
Configure CloudStack Management Server ...[OK]
CloudStack Management Server setup is Done!
[root@master1 management]# systemctl status cloudstack-management.service
● cloudstack-management.service - CloudStack Management Server
Loaded: loaded (/usr/lib/systemd/system/cloudstack-management.service; enabled; vendor preset: disabled)
Active: active (running) since 三 -- :: CST; 5s ago
Main PID: (java)
CGroup: /system.slice/cloudstack-management.service
└─ /usr/lib/jvm/jre/bin/java -Djava.awt.headless=true -Dcom.sun.management.jmxremote=false -Xmx2g -XX:+HeapDumpOnOutOfMem... 4月 :: master1 server[]: Apr , :: PM org.apache.catalina.core.StandardEngine startInternal
4月 :: master1 server[]: INFO: Starting Servlet Engine: Apache Tomcat/7.0.
4月 :: master1 server[]: Apr , :: PM org.apache.catalina.startup.HostConfig deployDirectory
4月 :: master1 server[]: INFO: Deploying web application directory /usr/share/cloudstack-management/webapps/client
4月 :: master1 server[]: Apr , :: PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
4月 :: master1 server[]: INFO: validateJarFile(/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/servlet-...t.class
4月 :: master1 server[]: Apr , :: PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
4月 :: master1 server[]: INFO: validateJarFile(/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/servlet-...t.class
4月 :: master1 server[]: Apr , :: PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
4月 :: master1 server[]: INFO: validateJarFile(/usr/share/cloudstack-management/webapps/client/WEB-INF/lib/tomcat-e...t.class
Hint: Some lines were ellipsized, use -l to show in full.
[root@master1 management]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN *: *:*
LISTEN 192.168.122.1: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN 127.0.0.1: *:*
LISTEN 127.0.0.1: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN :::

cloudstack-setup-management --tomcat7

12.访问

http://192.168.226.159:8080/client/

默认user :admin 默认密码:password

13.下载KVM模板

[root@master1 Desktop]# /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /export/secondary/ -f /home/zhanggen/Desktop/systemvm64template-4.6.-ovm.raw.bz2 -h kvm -F
Uncompressing to /usr/share/cloudstack-common/scripts/storage/secondary/3a2c5a43-2dd0--b225-.qcow2.tmp (type bz2)...could take a long time
Moving to /export/secondary/template/tmpl/////3a2c5a43-2dd0-4130-b225-535221756540.qcow2...could take a while
Successfully installed system VM template /home/zhanggen/Desktop/systemvm64template-4.6.-ovm.raw.bz2 to /export/secondary/template/tmpl///
[root@master1 Desktop]# cd /export/secondary/
lost+found/ template/
[root@master1 Desktop]# cd /export/secondary/template/tmpl///
[root@master1 ]# ls
3a2c5a43-2dd0--b225-.qcow2 template.properties
[root@master1 ]#

加载kvm模板

14.Agent libvert配置文件

CloudStack也是通过libverd来管理kvm的所有要修改 agent节点配置文件

vnc_listen = "0.0.0.0"

vim /etc/libvirt/qemu.conf

listen_tls =
listen_tcp =
tcp_port = ""
auth_tcp = "none"
mdns_adv =

vim /etc/libvirt/libvirtd.conf

四、配置CloudStack

查看管理节点日志

tail -f /var/log/cloudstack/management/management-server.log

 查看Agent节点日志

tail -f /var/log/cloudstack/agent/agent.log 

1.添加资源

 2.基本资源

3.设置DNS

 4.设置网卡名称

4.设置网络

注意网段不要包含master 和agent的IP,避免造成IP冲突

5.设置管理网络 

就是管理虚拟机用得网络,注意不要和上面的IP冲突

 6.设置集群名称

7.添加agent节点

设置agent节点

8.  设置主存储

主存储 就是Agent上的存储路径,通过网络挂载到 Master 节点的NFS路径

9.设置二级存储

二级存储就是 Master节点中 NFS路径

10.添加资源成功

五、搭建网络镜像仓库

搭建http服务器,用于管理ISO镜像和虚拟机模板,通过url下载镜像、模板

1.安装Nginx

yum -y install nginx
systemctl start nginx

安装Nginx

2.修改Nginx配置文件成为文件目录服务器

    access_log  /var/log/nginx/access.log  main;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
sendfile on;

/etc/nginx/nginx.conf

 3.开放secstrage.allow权限

4.重启cloudstack-management.service

[root@master1 html]# systemctl restart cloudstack-management.service
[root@master1 html]#

六、注册ISO镜像

1.组册ISO

七、添加实例

资源和镜像全有了,也该添加虚拟机实例了

1.添加实例

 2.选择通过ISO镜像的方式创建虚拟机

八、python3调用CloudStack的API

import requests
import urllib,hmac,base64,hashlib api_url='http://192.168.226.159:8080/client/api'
api_key='Y3-zVsLYyBjf1sJr73Eb_17BitmsErXrvc6oIJBQBVjaIn2SbOvapI7gTs5Lycw8DqbzWu3NyVu8urR6ldcMyQ'
security_key='JqNOR8WtSvSS7wdDRhmwQn1VU8HBc5LbgWIImdzpRsvojYLvS1ClIGgBe_t40j7BaOtSHU7cMEe803QvN6FcdQ' def get_url(cmd): #获取加密后的签名+拼接URL
arges={
"apikey":api_key.lower(),
"command":cmd.lower(),
"response":"json"
}
sig_url=urllib.parse.urlencode(arges)
hmac_byte=hmac.new(bytes(security_key,'utf-8'),bytes(sig_url,'utf-8'),hashlib.sha1 ).digest()
base64_str=base64.b64encode(hmac_byte).strip()
sig = urllib.parse.quote_plus(base64_str) full_url = api_url + '?' + 'command=' + cmd + '&apikey=' + api_key + '&response=json' + '&signature=' + sig
return full_url urI=get_url(cmd='listHosts') print(requests.get(url=urI).json())

获取主机

参考

CloudStack 云计算平台框架的更多相关文章

  1. OpenStack云计算平台框架

    概:  OpenStack是包含很多独立组件的一个云计算平台框架.在安装组件前,需要先将框架搭建出来,才能向其中放置组件. 搭建open stack云计算平台框架 一.安装open stack云计算平 ...

  2. 云计算平台简介(App Engine)

    云计算平台简介(App Engine)     1   简介 App Engine: 应用程序引擎,是托管网络应用程序的云计算平台. 1.1  什么是云 云计算通常简称为“云”,是一种通过 Inter ...

  3. Cloudstack云平台实践

    laaS平台的虚拟化 利用率高 资源整合 节约电能 节约空间 灾难恢复 CloudStack是一个开源的具有高可用性及扩展性的云计算平台.支持管理大部分主流的hypervisor,如KVM虚拟机,Xe ...

  4. 运用Hadoop能否搭建完整的云计算平台?

    Apache Hadoop 是一个用java语言实现的软件框架,在由大量计算机组成的集群中运行海量数据的分布式计算,它可以让应用程序支持上千个节点和PB级别的数据. Hadoop并不完全代表云计算,所 ...

  5. APT攻击将向云计算平台聚焦

    APT攻击作为一种高效.精确的网络攻击方式,在近几年被频繁用于各种网络攻击事件之中,并迅速成为企业信息安全最大的威胁之一. 近日,飞塔中国首席技术顾问X在谈及APT攻击时表示,随着云计算的不断发展普及 ...

  6. (转)Hprose与WCF在云计算平台Azure上的对决

    Windows Azure Platform是一个运行在微软数据中心的云计算平台.它包括一个云计算操作系统和一个为开发者提供的服务集合.开发人员创建的应用既可以直接在该平台 中运行,也可以使用该云计算 ...

  7. 基于google earth engine 云计算平台的全国水体变化研究

    第一个博客密码忘记了,今天才来开通第二个博客,时间已经过去两年了,三年的硕士生涯,真的是感慨良多,最有收获的一段时光,莫过于在实验室一个人敲着代码了,研三来得到中科院深圳先进院,在这里开始了新的研究生 ...

  8. 深入浅出OpenStack云计算平台管理(nova-compute/network)

    一.本课程是怎么样的一门课程(全面介绍)          1.1. 课程的背景           OpenStack是 一个由Rackspace发起.全球开发者共同参与的开源项目,旨在打造易于部署 ...

  9. 搭建自己的XenServer+CloudStack云平台,提供IaaS服务(一)环境搭建

    目标 搭建一个完整的基于XenServer和CloudStack的虚拟化平台,提供IaaS服务. 搭建三台安装了XenServer的服务器 搭建一台安装了CloudStack的服务器用以管理云平台 搭 ...

随机推荐

  1. 使用第三方jar时出现的问题

    Eclipse下把jar包放到工程lib下和通过buildpath加载有什么不同(解决找不到类的中级方法) 我通过Eclipse的 User Libranry 将jar导入 Eclipse里面,编译没 ...

  2. SQL并发处理方案——乐观锁和悲观锁

    (一)乐观锁和悲观锁的概念 悲观锁 在关系数据库管理系统里,悲观并发控制(又名“悲观锁”,Pessimistic Concurrency Control,缩写“PCC”)是一种并发控制的方法.它可以阻 ...

  3. JavaScript--图片放大镜

    图片放大镜的原理: 两张相同的图片img1和img2,img1上有一个#dd的div,通过鼠标移动dd,根据dd区域内的图片,来裁剪img2的图片,并将img2的图片放大,显示出来 关键词:img1坐 ...

  4. OGG 18.1 for mysql远程捕获测试

    Ogg18.1 remote capture要求mysql为5.7版本,只能从linux远程捕获mysql on windows or linux,且不支持DDL捕获.支持远程mysql为commun ...

  5. leetcode 1——两数之和

    问题描述 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不能重复利用这个数组 ...

  6. VUE引入字体图标库

    1. 下载阿里图标 2. 解压文件,并复制文件到VUE项目内 3. 找到添加的字体图标的.css文件,将.iconfont改成[class^="iconfont"], [class ...

  7. Gatling实战(三)

    无论是性能测试还是自动化测试,有一个很重要的点就是变量(参数化),因为真实环境是很少同时产生并发很高而且所有参数都一模一样的请求的,就算有这样的接口,开发肯定用缓存来挡了,这种一般不会是瓶颈,真正瓶颈 ...

  8. context使用

    1. 概述 go语言中goroutine之间的关联关系,缺乏维护,在erlang中有专门的机制来保障新开协程的生命周期,在go语言中,只能通过channel + select来实现,但不够直观,很绕. ...

  9. day17

    包什么是包 包的本质是文件夹为什么使用包 函数可以使得同一个文件中代码结构更清晰 木块(py文件)是以文件形式来组织代码结构 如果文件越来越多管理起来也不方便,所以需要使用文件夹来管理.从文件夹级别来 ...

  10. 机器学习实战(笔记)------------KNN算法

    1.KNN算法 KNN算法即K-临近算法,采用测量不同特征值之间的距离的方法进行分类. 以二维情况举例:         假设一条样本含有两个特征.将这两种特征进行数值化,我们就可以假设这两种特种分别 ...