OpenNebula跨地域管理

来源:互联网 发布:iphone7 阅读软件 编辑:程序博客网 时间:2024/05/05 02:57

1.     功能定位

集中管理OpenNebula的多个实例(zone,其中管理者多个网络互连的服务器)。oZones administrator可以将zone给特定的用户授权。

l  在不同的zone中给用户、组织和负载提供不同等级的安全性和可用性配置

l  更好的可扩展性

l  可管理地理上分布在多个数据中心的资源

 

2.     概述

通过Virtual DataCenter (VDC) 抽象层对上层用户屏蔽了底层多个zone的存在,VDC是用户+一组虚拟资源的集合,这些虚拟资源包含镜像,虚拟机模板,虚拟网络,虚拟机等。一个zone对应一个VDC。

VDC administrator可以在VDC内部创建新用户,可以管理所有虚拟资源,但是不能访问其他资源,如物理机。VDC administrator和用户访问zone通过反向代理,只需要知道oZones的地址和VFC的名字,无需知道zone的具体地址。

 

oZones管理者如果拥有OpenNebula的“oneadmin”证书,就可以将OpenNebula实例嫁到oZones中作为zone。然后,他可以在zone中创建VDC,选择一组可用的主机,并给VDC创建管理员帐户。之后,就可以通过类似如下URL来访问此zone:http://ozones-server/MyVDC

3.     安装

1)   环境要求

  • Ruby Gems
    • Rubygems needs to be installed
    • gem install json thin rack sinatra libopenssl-ruby
    • gem install data_mapper
    • For sqlite DBs: gem install dm-sqlite-adapter
    • For postgres DBs: gem install dm-postgres-adapter
    • For mysql DBs: gem install dm-mysql-adapter
  • Apache
    • Version should be >=2.2
    • apt-get install libopenssl-ruby apache2
  • Zones
    • 至少有一个zone

 

2)   配置Apache

Apache要被配置成为反向代理

  • 启用如下模块
$ sudo a2enmod rewrite
$ sudo a2enmod proxy_http
  • 在/etc/apache2/apache2.conf最后添加
ServerName <hostname-of-ozones-front-end>
  • 修改/etc/apache2/mods-available/proxy.conf变 “Deny from all”为 “Allow from all”
  • 修改/etc/apache2/sites-available/default
<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None

<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
  • 重起apache
$ sudo /etc/init.d/apache2 restart

3)   配置oZones Server

编辑/etc/one/ozones-server.conf 修改如下参数:

属性

描述

databsetype

'sqlite', 'postgres' or 'mysql'.

htaccess

Location of the root apache反向代理配置文件.htaccess的位置。默认为/var/www/.htaccess此文件必须是“oneadmin” (或执行ozones-server的用户名)可写的

dbdebug

是否日志数据库时间

host

oZones server域名

port

oZones server端口

  • Set OZONES_AUTH the first time the oZones server is started, it will add to the DB the credentials of the zones administrator (which is the user entitled to add new zones and created VDCs). This credentials will be retrieved from the file pointed out by the environment variable $OZONES_AUTH, which should contain the credentials separated by a colon, like 'username:password'. The same credentials will be needed to be used to access the oZones server using the CLI or theGUI.
启动服务
> ozones-server start
ozones-server listening on 127.0.0.1:6121

4)   配置oZones Client

需要使用CLI的地方要配置如下环境变量

变量

作用

OZONES_URL

oZones server的HTTP地址 (默认“http://localhost:6121”).

OZONES_AUTH

存储证书的文件,内容为'username:password'组

 

4.     管理

1)   添加新Zone

编写模板

NAME=MyZone
ONENAME=oneadmin
ONEPASS=opennebula
ENDPOINT=http://zone.domain.name:2633/RPC2
SUNSENDPOINT=http://zone.domain.name:9869

创建

$ onezone create myzone.template
ID: 1

查看列表

$ onezone list
  ID            NAME                                 ENDPOINT
   1          MyZone        http://zone.domain.name:2633/RPC2

2)   检查Zone

$ onezone show 1
ZONE zone0 INFORMATION                                       
ID             : 1                   
NAME           : zone0               
ZONE ADMIN     : oneadmin              
ZONE PASS      : 4478db59d30855454ece114e8ccfa5563d21c9bd
ENDPOINT       : http://zone.domain.name:2633/RPC2
# VDCS         : 0    

可以在onezone show <id>后面再加如下参数

  • template for VM templates
  • image for Images
  • user for Users
  • vm for Virtual Machines
  • vn for Virtual Networks
  • host for Hosts

如:

$ onezone show 1 host   
ZONE zone0 INFORMATION                                       
ID             : 1                   
NAME           : MyZone               
ZONE ADMIN     : tinova              
ZONE PASS      : 4478db59d30855454ece114e8ccfa5563d21c9bd
ENDPOINT       : http://zone.domain.name:2633/RPC2
# VDCS         : 0                   
 
  ID NAME               RVM   TCPU   FCPU   ACPU   TMEM   FMEM   AMEM   STAT
   0 MyHost               0      0      0    100     0K     0K     0K     on
   1 EC2Host              0      0      0    100     0K     0K     0K     on
   2 64BitsComp           0      0      0    100     0K     0K     0K     on

3)   删除Zone

$ onezone delete 1
Resource zone with id 1 successfully deleted

4)   oZonesGUI

Web GUI地址为:

http://ozones.server.domainname:6121

从次界面可以进行CLI可以执行的各种zone的管理操作

5)   查看总资源状况

从GUI可以看到所有zones的总资源状况,包括模板、镜像、用户、虚拟机、虚拟网络、Hosts等。

5.     管理VDC

Virtual Data Centers (VDCs)是一个完全隔离的环境,在此环境中包含一组用户,在VDC admin的管理下可以创建和使用计算、存储和网络能力。VDC admin可以创建新用户。VDC admin和用户都可以通过反向代理访问zone。

  •  

1)   Addinga new VDC

oZones CLI工具需要预先被安装好。

创建VDC需要定义如下配置文件:

NAME= VDCTest
VDCADMINNAME=vdcadmin
VDCADMINPASS=vdcpass
ZONEID=3
HOSTS=1,2

创建命令:

$ onevdc create vdctest.ozo
ID: 2

查看列表:

$ onevdc list
  ID            NAME                                   ZONEID
   2         VDCTest                                        3

在zone 3上可以看到:

Group

$ onegroup list
  ID NAME           
   0 oneadmin       
   1 users          
 101 VDCTest    

User

$ oneuser list
  ID GROUP    NAME                                                      PASSWORD
   0 oneadmin tinova                    4478db59d30855454ece114e8ccfa5563d21c9bd
   1 VDCTest  vdcadmin                  dc3ed3d76febeaafe92c2cbd9facf59877b69f00

ACLs

$ oneacl list
   ID     USER RES_VHNIUTG   RID OPE_CDUMIPpTWY
    0       @1     V-NI-T-     *     C-----p---
    1       @1     -H-----     *     --U-------
    2     @101     V-NI-T-     *     C-----p---
    3       #1     ----U--     *     C---------
    4       #1     ----U--  @101     -D-MI-----
    5     @101     -H-----    #1     --U-------
    6     @101     -H-----    #2     --U-------

2)   VDCHost sharing

oZones默认会确保没有任何一个主机被多个VDC使用。可通过修改VDC模板调整

FORCE=yes

3)   检查VDC

$ onevdc show 2
VDC VDCTest INFORMATION                                     
ID        : 2                   
NAME      : VDCTest             
ZONEID    : 3                   
VDCADMIN  : vdcadmin      

4)   删除VDC

$ onevdc delete 2
Resource vdc with id 2 successfully deleted

5)   给VDC中增删主机

  • addhost <vdcid> <range> : will add hosts in range to the VDC. If a host is being used by other VDC, the request will fail unles the “force” option is used.
  • delhost <vdcid> <range> : will delete hosts in range from the VDC.

6)   通过CLI访问

需要预先配置的环境变量:

  • ONE_XMLRPC This is an environment variable that tells OpenNebula CLI where to look for the OpenNebula server. It is going to be the address of the reverse proxy, with a reference to the VDC that the user is trying to access. The proxy will redirect the requests to the appropriate Zone. If the VDC has MyVCD as name, the variable would look like
ONE_XMLRPC=http://ozones.server/VDCTest
  • ONE_AUTH It should point to a file containing valid credentials for the VDC.

如:

  • ONE_XMLRPC=http://ozones.server/ VDCTest
  • ONE_AUTH=~/.one/one_auth

~/.one/one_auth中包含:

vdcadmin:vdcpass

给VDC中添加新用户。

$ oneuser create vdcuser1 password

7)   通过Sunstone访问

直接输入

http://ozones.server/sunstone_VDCTest/

8)   Usingthe oZones GUI

 


原创粉丝点击