[ English | Indonesia | русский ]

使用 Gnocchi、Ceph 和 Redis 的遥测示例

默认的 OpenStack-Ansible 安装配置 gnocchi 使用文件作为存储后端。如果您已经预先安装了 ceph,可以使用它作为 gnocchi 的后端。本文档将指导您如何设置 gnocchi 以使用您的 ceph 作为存储后端。

Ceph 作为指标存储

gnocchi_storage_driver: ceph

您需要在 gnocchi 设置中添加一些 pip 包

gnocchi_pip_packages:
- cryptography
- gnocchiclient
# this is what we want:
#  - "gnocchi[mysql,ceph,ceph_alternative_lib,redis,keystone]"
# but as there is no librados >=12.2 pip package we have to first install ceph without alternative support
# after adding the ceph repo to gnocchi container, python-rados>=12.2.0 is installed and linked automatically
# and gnocchi will automatically take up the features present in the used rados lib.
- "gnocchi[mysql,ceph,redis,keystone]"
- keystonemiddleware
- python-memcached

但是,当您的设置增长时,gnocchi 可能会变慢或阻塞您的 ceph 安装。您可能会遇到缓慢的请求和 Ceph 中的卡住的 PG。由于这可能有多种原因,请查看 Gnocchi 性能测试 部分中链接的演示文稿。它们还包括您可以调整的各种参数。

Redis 作为度量存储

解决可能性能问题的一种方法是为您的 gnocchi 安装使用传入的度量存储。 支持的存储系统

  • 文件(默认)

  • Ceph(首选)

  • OpenStack Swift

  • Amazon S3

  • Redis

如果您的 Swift API 端点使用 Ceph 作为后端,那么此设置中剩下的只有 Redis。

因此,首先使用此 ansible role 设置 redis 服务器/集群。接下来,您需要使用 OpenStack-Ansible 配置 Gnocchi 以将 Redis 集群用作传入存储

gnocchi_conf_overrides:
  incoming:
    driver: redis
    redis_url: redis://{{ hostvars[groups['redis-master'][0]]['ansible_default_ipv4']['address'] }}:{{ hostvars[groups['redis-master'][0]]['redis_sentinel_port'] }}?sentinel=master01{% for host in groups['redis-slave'] %}&sentinel_fallback={{ hostvars[host]['ansible_default_ipv4']['address'] }}:{{ hostvars[host]['redis_sentinel_port'] }}{% endfor %}&db=0

您还需要安装额外的 pip/distro 包才能使用 redis 集群

gnocchi_distro_packages:
- apache2
- apache2-utils
- libapache2-mod-wsgi
- git
- build-essential
- python3-dev
- librados-dev
- libpq-dev
- python3-rados
# additional package for python redis client
- python3-redis
- libsystemd-dev
gnocchi_pip_packages:
- cryptography
- gnocchiclient
# this is what we want:
#  - "gnocchi[mysql,ceph,ceph_alternative_lib,redis,keystone]"
# but as there is no librados >=12.2 pip package we have to first install ceph without alternative support
# after adding the ceph repo to gnocchi container, python-rados>=12.2.0 is installed and linked automatically
# and gnocchi will automatically take up the features present in the used rados lib.
- "gnocchi[mysql,ceph,redis,keystone]"
- keystonemiddleware
- python-memcached
- redis
- systemd-python

注意

需要注意的是:Ceph 替代库实现(ceph_alternative_lib)的名称因 Gnocchi 版本而异。

Zookeeper 用于协调

如果您在多台服务器上部署 Gnocchi 以分配工作,请添加 Zookeeper 作为协调后端。要设置 Zookeeper,可以使用 此 ansible role

创建 Zookeeper 容器

## conf.d
zookeeper_hosts:
{% for server in groups['control_nodes'] %}
{{ server }}:
  ip: {{ hostvars[server]['ansible_facts']['default_ipv4']['address'] }}
{% endfor%}
## env.d
component_skel:
  zookeeper_server:
    belongs_to:
      - zookeeper_all

container_skel:
  zookeeper_container:
    belongs_to:
      - infra_containers
      - shared-infra_containers
    contains:
      - zookeeper_server
    properties:
      service_name: zookeeper

现在您可以将 Zookeeper 设置为 Gnocchi 的协调后端

gnocchi_coordination_url: "zookeeper://{% for host in groups['zookeeper_all'] %}{{ hostvars[host]['management_address'] }}:2181{% if not loop.last %},{% endif %}{% endfor %}"

您还需要安装额外的软件包

gnocchi_pip_packages:
- cryptography
- gnocchiclient
# this is what we want:
#  - "gnocchi[mysql,ceph,ceph_alternative_lib,redis,keystone]"
# but as there is no librados >=12.2 pip package we have to first install ceph without alternative support
# after adding the ceph repo to gnocchi container, python-rados>=12.2.0 is installed and linked automatically
# and gnocchi will automatically take up the features present in the used rados lib.
- "gnocchi[mysql,ceph,redis,keystone]"
- keystonemiddleware
- python-memcached
- redis
- systemd-python
# addiitional pip packages needed for zookeeper coordination backend
- tooz
- lz4
- kazoo

Gnocchi 性能测试

有关如何调整您的 Gnocchi 堆栈的更多想法,请查看以下演示文稿