前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【openstack】cloudkitty组件,入门级安装(快速)

【openstack】cloudkitty组件,入门级安装(快速)

原创
作者头像
秋意零
修改2022-05-02 22:39:12
7950
修改2022-05-02 22:39:12
举报
文章被收录于专栏:YeTechLogYeTechLog

@TOC

前言

**什么是CloudKitty?**

CloudKitty是OpenStack等的评级即服务项目。该项目旨在成为云的退款和评级的通用解决方案。从历史上看,它只能在OpenStack上下文中运行它,但现在可以在独立模式下运行CloudKitty。

CloudKitty允许进行基于指标的评级:它轮询终端节点以检索有关特定指标的度量值和元数据,将评级规则应用于收集的数据,并将评级数据推送到其存储后端。

CloudKitty是高度模块化的,这使得添加新功能变得容易。

架构

CloudKitty可以分为四大部分:

  • Data retrieval (API) 数据检索
  • Data collection (cloudkitty-processor) 数据收集
  • Data rating 数据评级
  • Data storage 数据存储

这些部分由两个进程处理:和 。数据检索部分由进程处理,其他部分由 处理。cloudkitty-apicloudkitty-processorcloudkitty-apicloudkitty-processo

以下是 CloudKitty 架构的概述:

在这里插入图片描述
在这里插入图片描述

安装

代码语言:shell
复制
yum install openstack-cloudkitty-api openstack-cloudkitty-processor openstack-cloudkitty-ui

配置

编辑/etc/cloudkitty/cloudkitty.conf以配置 CloudKitty

代码语言:shell
复制
[DEFAULT]

verbose = True

log\_dir = /var/log/cloudkitty



[oslo\_messaging\_rabbit]

rabbit\_userid = openstack

rabbit\_password = RABBIT\_PASSWORD

rabbit\_hosts = RABBIT\_HOST



[auth]

username = cloudkitty

password = CK\_PASSWORD

tenant = service

region = RegionOne

url = http://localhost:5000/v2.0



[keystone\_authtoken]

username = cloudkitty

password = CK\_PASSWORD

project\_name = service

region = RegionOne

auth\_url = http://localhost:5000/v2.0

auth\_plugin = password



[database]

connection = mysql://cloudkitty:CK\_DBPASS@localhost/cloudkitty



[keystone\_fetcher]

username = admin

password = ADMIN\_PASSWORD

tenant = admin

region = RegionOne

url = http://localhost:5000/v2.0



[ceilometer\_collector]

username = cloudkitty

password = CK\_PASSWORD

tenant = service

region = RegionOne

url = http://localhost:5000

设置数据库和存储后端

代码语言:shell
复制
[root@controller ~]# mysql -uroot -p000000

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 374

Server version: 10.1.20-MariaDB MariaDB Serve

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



MariaDB [(none)]> CREATE DATABASE cloudkitty;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cloudkitty.\* TO 'cloudkitty'@'localhost' IDENTIFIED BY '000000';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cloudkitty.\* TO 'cloudkitty'@'%' IDENTIFIED BY '000000';

Query OK, 0 rows affected (0.00 sec)

运行数据库同步脚本

代码语言:shell
复制
[root@controller ~]# cloudkitty-dbsync upgrade

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.runtime.migration] Running upgrade  -> 464e951dc3b8, Initial migration

INFO  [alembic.runtime.migration] Running upgrade 464e951dc3b8 -> 2ac2217dcbd9, Added support for meta collecto

INFO  [alembic.runtime.migration] Running upgrade 2ac2217dcbd9 -> 385e33fef139, Added priority to modules\_state.

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.runtime.migration] Running upgrade  -> 3dd7e13527f3, Initial migration

INFO  [alembic.runtime.migration] Running upgrade 3dd7e13527f3 -> 4fa888fd7eda, Added threshold support.

INFO  [alembic.runtime.migration] Running upgrade 4fa888fd7eda -> 54cc17accf2c, Fixed constraint name.

INFO  [alembic.runtime.migration] Running upgrade 54cc17accf2c -> 10d2738b67df, Rename mapping table to hashmap\_mappings.

INFO  [alembic.runtime.migration] Running upgrade 10d2738b67df -> f8c799db4aa0, Fix unnamed constraints.

INFO  [alembic.runtime.migration] Running upgrade f8c799db4aa0 -> c88a06b1cfce, Clean hashmap fields constraints.

/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py:507: Warning: Duplicate index `uniq\_field\_per\_service`. This is deprecated and will be disallowed in a future release.

  cursor.execute(statement, parameters)

INFO  [alembic.runtime.migration] Running upgrade c88a06b1cfce -> 4da82e1c11c8, Add per tenant hashmap support

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.runtime.migration] Running upgrade  -> 4f9efa4601c0, Initial migration.

初始化存储后端

代码语言:shell
复制
[root@controller ~]# cloudkitty-storage-init

No handlers could be found for logger "cloudkitty.utils"

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

INFO  [alembic.runtime.migration] Running upgrade  -> 17fd1b237aa3, Initial migration

INFO  [alembic.runtime.migration] Running upgrade 17fd1b237aa3 -> 792b438b663, added tenant informations

INFO  [alembic.runtime.migration] Running upgrade 792b438b663 -> 307430ab38bc, improve qty precision

INFO  [alembic.runtime.migration] Running upgrade 307430ab38bc -> c703a1bad612, improve\_qty\_digit

CloudKitty 使用 Keystone 进行身份验证,并提供rating服务。

代码语言:shell
复制
[root@controller ~]# openstack user create --domain demo --password 000000 cloudkitty

+---------------------+----------------------------------+

| Field               | Value                            |

+---------------------+----------------------------------+

| domain\_id           | d5db5c4ee4a14492b69408f63107d11f |

| enabled             | True                             |

| id                  | f1dea9309b834edba3aa4c1b8607dc16 |

| name                | cloudkitty                       |

| options             | {}                               |

| password\_expires\_at | None                             |

+---------------------+----------------------------------+
代码语言:shell
复制
[root@controller ~]# openstack role add --project service --user cloudkitty admin

对于应由 CloudKitty处理的每个租户,将rating角色赋予 cloudkitty :

代码语言:shell
复制
[root@controller ~]# openstack role create rating

+-----------+----------------------------------+

| Field     | Value                            |

+-----------+----------------------------------+

| domain\_id | None                             |

| id        | ee01d36a397b4b0ebcb579044c32a73c |

| name      | rating                           |

+-----------+----------------------------------+

创建rating服务及其端点:

代码语言:shell
复制
[root@controller ~]# openstack service create --name cloudkitty --description "OpenStack rating" rating

+-------------+----------------------------------+

| Field       | Value                            |

+-------------+----------------------------------+

| description | OpenStack rating                 |

| enabled     | True                             |

| id          | 78f3d51cf74843cd8d325b790e0c2b1c |

| name        | cloudkitty                       |

| type        | rating                           |

+-------------+----------------------------------+
代码语言:shell
复制
openstack endpoint create --region RegionOne rating public http://controller:9292

openstack endpoint create --region RegionOne rating internal http://controller:9292

openstack endpoint create --region RegionOne rating admin http://controller:9292
代码语言:shell
复制
[root@controller ~]# openstack endpoint create --region RegionOne rating public http://controller:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 48b75b9d2d764b56a5bee00ff75b03b1 |

| interface    | public                           |

| region       | RegionOne                        |

| region\_id    | RegionOne                        |

| service\_id   | 78f3d51cf74843cd8d325b790e0c2b1c |

| service\_name | cloudkitty                       |

| service\_type | rating                           |

| url          | http://controller:9292           |

+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne rating internal http://controller:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | b4f7fffa539441a68506db90b3ae89ce |

| interface    | internal                         |

| region       | RegionOne                        |

| region\_id    | RegionOne                        |

| service\_id   | 78f3d51cf74843cd8d325b790e0c2b1c |

| service\_name | cloudkitty                       |

| service\_type | rating                           |

| url          | http://controller:9292           |

+--------------+----------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne rating admin http://controller:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | a607a077f119417d9e650c16dcd61f10 |

| interface    | admin                            |

| region       | RegionOne                        |

| region\_id    | RegionOne                        |

| service\_id   | 78f3d51cf74843cd8d325b790e0c2b1c |

| service\_name | cloudkitty                       |

| service\_type | rating                           |

| url          | http://controller:9292           |

+--------------+----------------------------------+

启动

代码语言:shell
复制
[root@controller ~]# systemctl start cloudkitty-processor.service

[root@controller ~]# cloudkitty-api -p 8889  #临时启动API

No handlers could be found for logger "cloudkitty.utils"

/usr/lib/python2.7/site-packages/pecan/\_\_init\_\_.py:122: RuntimeWarning: `static\_root` is only used when `debug` is True, ignoring

  RuntimeWarning

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

STARTING test server cloudkitty.api.app.build\_wsgi\_app

Available at http://controller:8889/

DANGER! For testing only, do not use in production

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

192.168.200.1 - - [29/Apr/2022 15:06:41] "GET / HTTP/1.1" 200 209

检索并安装 CloudKitty 的仪表板

代码语言:shell
复制
git clone https://opendev.org/openstack/cloudkitty-dashboard.git



python setup.py install

yum install -y wget

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum -y install python-pip

PY\_PACKAGES\_PATH=`pip --version | cut -d' ' -f4`

ln -s $PY\_PACKAGES\_PATH/cloudkittydashboard/enabled/\_[0-9]\*.py /usr/share/openstack-dashboard/openstack\_dashboard/enabled/
代码语言:shell
复制
[root@controller bin]# systemctl restart httpd.service memcached.service

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 架构
    • 安装
      • 配置
        • 启动
          • 检索并安装 CloudKitty 的仪表板
          相关产品与服务
          云数据库 MariaDB
          腾讯云数据库 MariaDB(TencentDB for MariaDB) 让您轻松在云端部署、使用 MariaDB 数据库。MariaDB 是在 MySQL 版权被 Oracle 收购后,由 MySQL 创始人 Monty 创立,其版权授予了“MariaDB基金会(非营利性组织)”以保证 MariaDB 永远开源,良好的开源策略,是企业级应用的最优选择,主流开源社区系统/软件的数据库系统,均已默认配置 MariaDB。
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档