CentOS Stream 9
Sponsored Link

OpenStack Yoga : Gnocchi 設定2022/06/13

 
時系列データベース [TDBaaS (Time Series Database as a Service)] Gnocchi をインストールします。
当例では以下のような環境を例に 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  httpd     |     |     Neutron Server    |     |      Nova Compute     |
|  Keystone   Glance    |     |      OVN-Northd       |     |      Open vSwitch     |
|  Nova API  Cinder API |     |     Cinder Volume     |     |   OVN Metadata Agent  |
|                       |     |     Gnocchi httpd     |     |     OVN-Controller    |
+-----------------------+     +-----------------------+     +-----------------------+

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

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

+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | 0f2625947bf0433a9519ba8a29434bdf |
| domain_id           | default                          |
| enabled             | True                             |
| id                  | fd661cc4e91243f0b05d132834fde42e |
| name                | gnocchi                          |
| options             | {}                               |
| 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                            |
+-------------+----------------------------------+
| description | Metric Service                   |
| enabled     | True                             |
| id          | 4ddd4e3baeee45bbbd88048bad094b9a |
| name        | gnocchi                          |
| type        | metric                           |
+-------------+----------------------------------+

# 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           | 39c1e3f0cfd246e4858d2982ab63c2d6 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4ddd4e3baeee45bbbd88048bad094b9a |
| 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           | fc1c7a734f6c441397afedf631c3345a |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4ddd4e3baeee45bbbd88048bad094b9a |
| 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           | 92288df8f07145e98af59830fa5f4fcd |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4ddd4e3baeee45bbbd88048bad094b9a |
| service_name | gnocchi                          |
| service_type | metric                           |
| url          | https://network.srv.world:8041   |
+--------------+----------------------------------+
[2] Gnocchi 用のユーザーとデータベースを MariaDB に作成しておきます。
[root@dlp ~(keystone)]#
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 497
Server version: 10.5.13-MariaDB 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)]> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit 
Bye
[3] Network ノードで Gnocchi サービスをインストールします。
# Yoga, EPEL, CRB からインストール

[root@network ~]#
dnf --enablerepo=centos-openstack-yoga,epel,crb -y install openstack-gnocchi-api openstack-gnocchi-metricd python3-gnocchiclient httpd python3-mod_wsgi
[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@dlp.srv.world/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
# httpd Keystone で自己署名の証明書を使用の場合は [true]
insecure = false

[root@network ~]#
vi /etc/httpd/conf.d/10-gnocchi_wsgi.conf
# 新規作成

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

  CustomLog /var/log/httpd/gnocchi_wsgi_access.log combined
  ErrorLog /var/log/httpd/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
# gnocchiclient が下記バージョンの場合はアップデート

[root@network ~]#
rpm -q python3-gnocchiclient

python3-gnocchiclient-7.0.4-2.el9s.noarch
[root@network ~]#
pip3 install --upgrade gnocchiclient

Requirement already satisfied: gnocchiclient in /usr/lib/python3.9/site-packages (7.0.4)
Collecting gnocchiclient
  Downloading gnocchiclient-7.0.7-py2.py3-none-any.whl (66 kB)

.....
.....

Installing collected packages: gnocchiclient
Successfully installed gnocchiclient-7.0.7
[5] Nginx にプロキシの設定をします。
[root@network ~]#
vi /etc/nginx/nginx.conf
# [stream] セクション内に追記

stream {
    upstream neutron-api {
        server 127.0.0.1:9696;
    }
    server {
        listen 10.0.0.50:9696 ssl;
        proxy_pass neutron-api;
    }
    upstream gnocchi-api {
        server 127.0.0.1:8041;
    }
    server {
        listen 10.0.0.50:8041 ssl;
        proxy_pass gnocchi-api;
    }
    ssl_certificate "/etc/letsencrypt/live/network.srv.world/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/network.srv.world/privkey.pem";
}
[6] SELinux を有効にしている場合は、ポリシーの変更が必要です。
[root@network ~]#
setsebool -P httpd_can_network_connect on

[root@network ~]#
semanage port -a -t http_port_t -p tcp 8041

[7] Firewalld を有効にしている場合は、サービスポートの許可が必要です。
[root@network ~]#
firewall-cmd --add-port=8041/tcp

success
[root@network ~]#
firewall-cmd --runtime-to-permanent

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

[root@network ~]#
systemctl enable --now openstack-gnocchi-metricd httpd

[root@network ~]#
systemctl restart nginx

[9] Control ノードで動作確認します。
[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-yoga,epel,crb -y install python3-gnocchiclient
# 動作確認

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

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

関連コンテンツ