Ubuntu 安装与配置¶
本节描述了如何在控制器节点上安装和配置遥测服务,该服务代码名为 ceilometer。
先决条件¶
在安装和配置遥测服务之前,您必须配置一个目标来发送计量数据。推荐的端点是 Gnocchi。
激活
admin凭证以访问仅管理员可用的 CLI 命令$ . admin-openrc
要创建服务凭证,请完成以下步骤
创建
ceilometer用户$ openstack user create --domain default --password-prompt ceilometer User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | e0353a670a9e496da891347c589539e9 | | enabled | True | | id | c859c96f57bd4989a8ea1a0b1d8ff7cd | | name | ceilometer | +-----------+----------------------------------+
将
admin角色添加到ceilometer用户。$ openstack role add --project service --user ceilometer admin
注意
此命令不会产生任何输出。
创建
ceilometer服务实体$ openstack service create --name ceilometer \ --description "Telemetry" metering +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Telemetry | | enabled | True | | id | 5fb7fd1bb2954fddb378d4031c28c0e4 | | name | ceilometer | | type | metering | +-------------+----------------------------------+
在 Keystone 中注册 Gnocchi 服务
创建
gnocchi用户$ openstack user create --domain default --password-prompt gnocchi User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | e0353a670a9e496da891347c589539e9 | | enabled | True | | id | 8bacd064f6434ef2b6bbfbedb79b0318 | | name | gnocchi | +-----------+----------------------------------+
创建
gnocchi服务实体$ openstack service create --name gnocchi \ --description "Metric Service" metric +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Metric Service | | enabled | True | | id | 205978b411674e5a9990428f81d69384 | | name | gnocchi | | type | metric | +-------------+----------------------------------+
将
admin角色添加到gnocchi用户。$ openstack role add --project service --user gnocchi admin
注意
此命令不会产生任何输出。
创建 Metric 服务 API 端点
$ openstack endpoint create --region RegionOne \ metric public http://controller:8041 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | b808b67b848d443e9eaaa5e5d796970c | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 205978b411674e5a9990428f81d69384 | | service_name | gnocchi | | service_type | metric | | url | http://controller:8041 | +--------------+----------------------------------+ $ openstack endpoint create --region RegionOne \ metric internal http://controller:8041 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | c7009b1c2ee54b71b771fa3d0ae4f948 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 205978b411674e5a9990428f81d69384 | | service_name | gnocchi | | service_type | metric | | url | http://controller:8041 | +--------------+----------------------------------+ $ openstack endpoint create --region RegionOne \ metric admin http://controller:8041 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | b2c00566d0604551b5fe1540c699db3d | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 205978b411674e5a9990428f81d69384 | | service_name | gnocchi | | service_type | metric | | url | http://controller:8041 | +--------------+----------------------------------+
安装 Gnocchi¶
安装 Gnocchi 包。或者,也可以使用 pip 安装 Gnocchi
# apt-get install gnocchi-api gnocchi-metricd python3-gnocchiclient
注意
根据您的环境大小,可以考虑单独安装 Gnocchi,因为它会大量使用 cpu。
安装 uWSGI 包。以下方法使用操作系统提供的包。另一种选择是使用 pip(或 pip3,具体取决于发行版);本文档中没有描述使用 pip 的方法
# apt-get install uwsgi-plugin-python3 uwsgi
注意
由于提供的 gnocchi-api 围绕 uwsgi 运行,因此如果您想使用 gnocchi-api 运行 Gnocchi API,则需要确保已安装 uWSGI。由于 Gnocchi API 层使用 WSGI 运行,因此也可以使用 Apache httpd 和 mod_wsgi,或任何其他 HTTP 守护程序来运行它。
创建 Gnocchi 索引器的数据库
使用数据库访问客户端以
root用户身份连接到数据库服务器$ mysql -u root -p
创建
gnocchi数据库CREATE DATABASE gnocchi;授予对
gnocchi数据库的适当访问权限GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'localhost' \ IDENTIFIED BY 'GNOCCHI_DBPASS'; GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' \ IDENTIFIED BY 'GNOCCHI_DBPASS';
将
GNOCCHI_DBPASS替换为合适的密码。退出数据库访问客户端。
编辑
/etc/gnocchi/gnocchi.conf文件并添加 Keystone 选项在
[api]部分,配置 gnocchi 使用 keystone[api] auth_mode = keystone port = 8041 uwsgi_mode = http-socket
在
[keystone_authtoken]部分,配置 keystone 身份验证[keystone_authtoken] ... auth_type = password auth_url = http://controller:5000/v3 project_domain_name = Default user_domain_name = Default project_name = service username = gnocchi password = GNOCCHI_PASS interface = internalURL region_name = RegionOne
将
GNOCCHI_PASS替换为您为 Identity 服务中的gnocchi用户选择的密码。在
[indexer]部分,配置数据库访问[indexer] url = mysql+pymysql://gnocchi:GNOCCHI_DBPASS@controller/gnocchi
将
GNOCCHI_DBPASS替换为您为 Gnocchi 索引器数据库选择的密码。在
[storage]部分,配置存储指标数据的位置。在这种情况下,我们将将其存储到本地文件系统。有关更多持久且性能更高的驱动程序列表,请参阅 Gnocchi 文档[storage] # coordination_url is not required but specifying one will improve # performance with better workload division across workers. coordination_url = redis://controller:6379 file_basepath = /var/lib/gnocchi driver = file
初始化 Gnocchi
gnocchi-upgrade
完成 Gnocchi 安装¶
重新启动 Gnocchi 服务
# service gnocchi-api restart # service gnocchi-metricd restart
安装和配置组件¶
安装 ceilometer 包
# apt-get install ceilometer-agent-notification \ ceilometer-agent-central
编辑
/etc/ceilometer/pipeline.yaml文件并完成以下部分配置 Gnocchi 连接
publishers: # set address of Gnocchi # + filter out Gnocchi-related activity meters (Swift driver) # + set default archive policy - gnocchi://?filter_project=service&archive_policy=low
编辑
/etc/ceilometer/ceilometer.conf文件并完成以下操作在
[DEFAULT]部分中,配置RabbitMQ消息队列访问[DEFAULT] ... transport_url = rabbit://openstack:RABBIT_PASS@controller
将
RABBIT_PASS替换为您为RabbitMQ中的openstack帐户选择的密码。在
[service_credentials]部分,配置服务凭证[service_credentials] ... auth_type = password auth_url = http://controller:5000/v3 project_domain_id = default user_domain_id = default project_name = service username = ceilometer password = CEILOMETER_PASS interface = internalURL region_name = RegionOne
将
CEILOMETER_PASS替换为你在 Identity 服务中为ceilometer用户选择的密码。
在 Gnocchi 中创建 Ceilometer 资源。此时 Gnocchi 应该正在运行
# ceilometer-upgrade
完成安装¶
重新启动遥测服务
# service ceilometer-agent-central restart # service ceilometer-agent-notification restart