CloudStack 云计算平台框架
前言
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
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
[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 云计算平台框架的更多相关文章
- OpenStack云计算平台框架
概: OpenStack是包含很多独立组件的一个云计算平台框架.在安装组件前,需要先将框架搭建出来,才能向其中放置组件. 搭建open stack云计算平台框架 一.安装open stack云计算平 ...
- 云计算平台简介(App Engine)
云计算平台简介(App Engine) 1 简介 App Engine: 应用程序引擎,是托管网络应用程序的云计算平台. 1.1 什么是云 云计算通常简称为“云”,是一种通过 Inter ...
- Cloudstack云平台实践
laaS平台的虚拟化 利用率高 资源整合 节约电能 节约空间 灾难恢复 CloudStack是一个开源的具有高可用性及扩展性的云计算平台.支持管理大部分主流的hypervisor,如KVM虚拟机,Xe ...
- 运用Hadoop能否搭建完整的云计算平台?
Apache Hadoop 是一个用java语言实现的软件框架,在由大量计算机组成的集群中运行海量数据的分布式计算,它可以让应用程序支持上千个节点和PB级别的数据. Hadoop并不完全代表云计算,所 ...
- APT攻击将向云计算平台聚焦
APT攻击作为一种高效.精确的网络攻击方式,在近几年被频繁用于各种网络攻击事件之中,并迅速成为企业信息安全最大的威胁之一. 近日,飞塔中国首席技术顾问X在谈及APT攻击时表示,随着云计算的不断发展普及 ...
- (转)Hprose与WCF在云计算平台Azure上的对决
Windows Azure Platform是一个运行在微软数据中心的云计算平台.它包括一个云计算操作系统和一个为开发者提供的服务集合.开发人员创建的应用既可以直接在该平台 中运行,也可以使用该云计算 ...
- 基于google earth engine 云计算平台的全国水体变化研究
第一个博客密码忘记了,今天才来开通第二个博客,时间已经过去两年了,三年的硕士生涯,真的是感慨良多,最有收获的一段时光,莫过于在实验室一个人敲着代码了,研三来得到中科院深圳先进院,在这里开始了新的研究生 ...
- 深入浅出OpenStack云计算平台管理(nova-compute/network)
一.本课程是怎么样的一门课程(全面介绍) 1.1. 课程的背景 OpenStack是 一个由Rackspace发起.全球开发者共同参与的开源项目,旨在打造易于部署 ...
- 搭建自己的XenServer+CloudStack云平台,提供IaaS服务(一)环境搭建
目标 搭建一个完整的基于XenServer和CloudStack的虚拟化平台,提供IaaS服务. 搭建三台安装了XenServer的服务器 搭建一台安装了CloudStack的服务器用以管理云平台 搭 ...
随机推荐
- 用 webpack 创建 vue 项目
1.安装支持webpack 包 npm i -D webpack webpack-cli aspnet-webpack webpack-dev-middleware webpack-hot-mi ...
- Oarcle之序列
序列:是一种数据库对象,用来自动产生一组唯一的序号: 序列:是一种共享式的对象,多个用户可以共同使用序列中的序号. 创建序列 create sequence seq_emp_temp incremen ...
- mongo 修改器
[$inc] 作用:修改器$inc可以对文档的某个值为数字型(只能为满足要求的数字)的键进行增减的操作. Example: db.b.update({"uid" : "2 ...
- 1.3:Render Pipeline and GPU Pipeline
文章著作权归作者所有.转载请联系作者,并在文中注明出处,给出原文链接. 本系列原更新于作者的github博客,这里给出链接. 在学习SubShader之前,我们有必要对 Render Pipeline ...
- k8s构建镜像-基于centos的python环境+pip
FROM centos:7.4.1708 #维护者信息MAINTAINER by icdss # 标签LABEL version="1.0" # 安装依赖RUN yum -y up ...
- 通过KSoap三方插件解析WebService接口方法
话不多说,正文如下: 1.在lib中放入ksoap2的jar包并导入 2.在xml 配置文件中加入: <!-- 访问网络的权限 --> <uses-permission androi ...
- Conclusions about Deep Learning with Python
Conclusions about Deep Learning with Python Last night, I start to learn the python for deep learn ...
- selenium python 中浏览器操作
1.启用浏览器 browser = webdriver.Chrome() 谷歌浏览器 browser = webdriver.Firefox() ...
- 关于win10触控板两指点击无效的问题
一.前言 最近发现公司的本本两指点击触控板没有反应,单指和三指点击触控板都是正常的.网上也搜了 一些解决的方法,最开始因为没有明确自己的触控板是Synaptics还是Elan的,导致没有解决.首先我们 ...
- scss、sass、less的对比与区别
什么是Sass和Less? sass和less都属于CSS预处理器. css预处理定义了一种新的语言,其基本思想是,用一种专门的编程语言,为css增加了一些编程的特性,将CSS作为目标生成文件,然后开 ...