Debian 13 trixie

OpenStack Epoxy : Gnocchi 設定2025/09/03

 

時系列データベース [TDBaaS (Time Series Database as a Service)] Gnocchi をインストールします。

当例では以下のような環境を例に Network ノードに Gnocchi をインストールします。

------------+--------------------------+--------------------------+------------
            |                          |                          |
        eth0|10.0.0.30             eth0|10.0.0.50             eth0|10.0.0.51
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |     Gnocchi httpd     |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] Control ノードの Keystone に Gnocchi 用のユーザー等々を登録しておきます。
# [service] プロジェクト所属で [gnocchi] ユーザーを作成

root@dlp ~(keystone)#
openstack user create --domain default --project service --password servicepassword gnocchi

+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | a60814a6c56241edbbdfae6c290f8abc |
| domain_id           | default                          |
| email               | None                             |
| enabled             | True                             |
| id                  | fe39c8d6fee24c499a3b3b1ed13ce90e |
| name                | gnocchi                          |
| description         | None                             |
| password_expires_at | None                             |
+---------------------+----------------------------------+

# [gnocchi] ユーザーを [admin] ロール に加える

root@dlp ~(keystone)#
openstack role add --project service --user gnocchi admin
# [gnocchi] 用サービスエントリ作成

root@dlp ~(keystone)#
openstack service create --name gnocchi --description "Metric Service" metric

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| id          | d4f5bde2507d4b6c812ac0c4b204eda8 |
| name        | gnocchi                          |
| type        | metric                           |
| enabled     | True                             |
| description | Metric Service                   |
+-------------+----------------------------------+

# Gnocchi API ホストを定義

root@dlp ~(keystone)#
export controller=network.srv.world
# [gnocchi] 用エンドポイント作成 (public)

root@dlp ~(keystone)#
openstack endpoint create --region RegionOne metric public https://$controller:8041

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 7d2eefdb634643d2b617cc15c8d11c15 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | d4f5bde2507d4b6c812ac0c4b204eda8 |
| service_name | gnocchi                          |
| service_type | metric                           |
| url          | https://network.srv.world:8041   |
+--------------+----------------------------------+

# [gnocchi] 用エンドポイント作成 (internal)

root@dlp ~(keystone)#
openstack endpoint create --region RegionOne metric internal https://$controller:8041

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 54535a2dd9d94846985c974f7134750e |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | d4f5bde2507d4b6c812ac0c4b204eda8 |
| service_name | gnocchi                          |
| service_type | metric                           |
| url          | https://network.srv.world:8041   |
+--------------+----------------------------------+

# [gnocchi] 用エンドポイント作成 (admin)

root@dlp ~(keystone)#
openstack endpoint create --region RegionOne metric admin https://$controller:8041

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | efc7eda60f4e4d39af5e6e59234620ea |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | d4f5bde2507d4b6c812ac0c4b204eda8 |
| service_name | gnocchi                          |
| service_type | metric                           |
| url          | https://network.srv.world:8041   |
+--------------+----------------------------------+
[2] Network ノードで Gnocchi サービスをインストールします。インストール中の問いには全て [No] で OK です。
root@network:~#
apt -y install gnocchi-api gnocchi-metricd python3-gnocchiclient apache2 libapache2-mod-wsgi-py3 mariadb-server
[3] Network ノードで Gnocchi 用のユーザーとデータベースを MariaDB に作成しておきます。
root@network:~#
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 260
Server version: 11.8.2-MariaDB-1 from Debian -- Please help get to 10k stars at https://github.com/MariaDB/Server

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

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

MariaDB [(none)]> create database gnocchi; 
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on gnocchi.* to gnocchi@'localhost' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on gnocchi.* to gnocchi@'%' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit 
Bye
[4] Gnocchi の基本設定です。
root@network:~#
mv /etc/gnocchi/gnocchi.conf /etc/gnocchi/gnocchi.conf.org

root@network:~#
vi /etc/gnocchi/gnocchi.conf
# 新規作成

[DEFAULT]
log_dir = /var/log/gnocchi

[api]
auth_mode = keystone

[database]
backend = sqlalchemy

# MariaDB 接続情報
[indexer]
url = mysql+pymysql://gnocchi:password@127.0.0.1/gnocchi

[storage]
driver = file
file_basepath = /var/lib/gnocchi

# Keystone 認証情報
[keystone_authtoken]
www_authenticate_uri = https://dlp.srv.world:5000
auth_url = https://dlp.srv.world:5000
memcached_servers = dlp.srv.world:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = gnocchi
password = servicepassword
service_token_roles_required = true
# Apache2 Keystone で自己署名の証明書を使用の場合は [true]
insecure = false

[oslo_policy]
enforce_new_defaults = true

root@network:~#
vi /etc/apache2/sites-available/gnocchi-api.conf
# 新規作成
# SSL/TLS 証明書は自身のものに置き換え

Listen 8041
<VirtualHost *:8041>
  <Directory /usr/bin>
    AllowOverride None
    Require all granted
  </Directory>

  SSLEngine on
  SSLHonorCipherOrder on
  SSLCertificateFile /etc/letsencrypt/live/network.srv.world/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/network.srv.world/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/network.srv.world/chain.pem

  CustomLog /var/log/apache2/gnocchi_wsgi_access.log combined
  ErrorLog /var/log/apache2/gnocchi_wsgi_error.log
  SetEnvIf X-Forwarded-Proto https HTTPS=1
  WSGIApplicationGroup %{GLOBAL}
  WSGIDaemonProcess gnocchi display-name=gnocchi_wsgi user=gnocchi group=gnocchi processes=6 threads=6
  WSGIProcessGroup gnocchi
  WSGIScriptAlias / /usr/bin/gnocchi-api
</VirtualHost>

root@network:~#
chmod 640 /etc/gnocchi/gnocchi.conf

root@network:~#
chgrp gnocchi /etc/gnocchi/gnocchi.conf
[5] データベースにデータを追加して Gnocchi サービスを起動します。
root@network:~#
su -s /bin/bash gnocchi -c "gnocchi-upgrade"

root@network:~#
a2enmod wsgi

root@network:~#
a2enmod ssl

root@network:~#
a2ensite gnocchi-api

root@network:~#
systemctl disable --now gnocchi-api

root@network:~#
systemctl restart gnocchi-metricd apache2

root@network:~#
systemctl enable gnocchi-metricd
[6] Control ノードで動作確認します。
root@dlp ~(keystone)#
apt -y install python3-gnocchiclient

root@dlp ~(keystone)#
export OS_AUTH_TYPE=password

root@dlp ~(keystone)#
gnocchi resource list
# 何も表示されなければ問題なし

関連コンテンツ