当前位置: 首页 > 工具软件 > Ceilometer > 使用案例 >

openstack Rocky版本安装和配置ceilometer服务教程

逄嘉木
2023-12-01

写在前面

1、openstack版本:rocky

2、linux版本:centos7

3、确保集群已经安装nova、glance、keystone等

4、有$符号的是命令,没有的是文本,本文代码中#号为注释

 首先确保已经具备了基础的openstack环境,确保计算(Compute)、镜像(Image)和身份(Identity)服务。

目录

1、安装和配置ceilometer(本节命令运行在控制节点上)

2、启用cinder计量器(本节命令在控制器和块存储节点上都运行)

3、启用glance服务计量器(本节命令运行在控制节点上)

4、启用heat服务计量器(本节命令运行在控制节点上)

5、启用neutron服务计量器(本节命令运行在控制节点上)

6、启用swift服务计量器(本节命令运行在控制节点上)

7、启用计算服务计量器(本节命令在计算节点上运行)

8、验证操作


1、安装和配置ceilometer(本节命令运行在控制节点上)

配置发送计量数据的端点——Gnocchi

获取admin凭据使用属于管理员的命令行命令

$ source admin-openstack.sh

创建ceilometer用户

$ openstack user create --domain default --password-prompt ceilometer

将admin角色添加给ceilometer用户

$ openstack role add --project service --user ceilometer admin

在 Keystone 中注册 Gnocchi 服务

创建gnocchi用户

$ openstack user create --domain default --password-prompt gnocchi

创建gnocchi服务实体

$ openstack service create --name gnocchi \
  --description "Metric Service" metric

将admin角色添加给gnocchi用户

$ openstack role add --project service --user gnocchi admin

创建 Metric 服务 API 端点

$ openstack endpoint create --region RegionOne \
  metric public http://controller:8041
$ openstack endpoint create --region RegionOne \
  metric internal http://controller:8041
$ openstack endpoint create --region RegionOne \
  metric admin http://controller:8041

安装Gnocchi

$ yum install openstack-gnocchi-api openstack-gnocchi-metricd \
  python-gnocchiclient

创建数据库

$ mysql -u root -p
CREATE DATABASE gnocchi;
GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'localhost' \
  IDENTIFIED BY 'gnocchi';
GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' \
  IDENTIFIED BY 'gnocchi';

编辑配置文件的keystone选项,注意你自己的密码

$ vim /etc/gnocchi/gnocchi.conf

[api]
auth_mode = 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 = 1234
interface = internalURL
region_name = RegionOne

[indexer]
url = mysql+pymysql://gnocchi:gnocchi@controller/gnocchi

[storage]
coordination_url = redis://controller:6379
file_basepath = /var/lib/gnocchi
driver = file

控制节点需要安装redis以启用6379端口。

redis安装

#首先安装编译环境c++
$ yum install gcc-c++

# 在线下载redis
$ wget http://download.redis.io/releases/redis-2.8.18.tar.gz

#解压
$ tar xzf redis-2.8.18.tar.gz

cd redis-2.8.18

#运行make命令
$ make prefix=/usr/local/redis install
#安装完成后在/usr/local/redis/bin下有几个可执行文件

#修改redis.conf
daemonize yes

#拷贝配置文件
$ cp redis.conf /usr/local/redis

#启动redis
$ cd /usr/local/redis/
#执行
$ ./bin/redis-server ./redis.conf
#即可查看端口情况
$ ps -ef | grep -i redis

初始化Gnocchi

$ gnocchi-upgrade

完成 Gnocchi 安装

启动 Gnocchi 服务并将它们配置为在系统启动时启动

$ systemctl enable openstack-gnocchi-api.service \
  openstack-gnocchi-metricd.service
$ systemctl start openstack-gnocchi-api.service \
  openstack-gnocchi-metricd.service

安装和配置组件

安装 Ceilometer 软件包

$ yum install openstack-ceilometer-notification \
  openstack-ceilometer-central

编辑/etc/ceilometer/pipeline.yaml文件

$ vim /etc/ceilometer/pipeline.yaml
#配置 Gnocchi 连接
publishers:
    - gnocchi://?filter_project=service&archive_policy=low

编辑/etc/ceilometer/ceilometer.conf文件

$ vim /etc/ceilometer/ceilometer.conf

[DEFAULT]
transport_url = rabbit://openstack:openstack@controller

[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 = 1234
interface = internalURL
region_name = RegionOne

在 Gnocchi 中创建 Ceilometer 资源

$ ceilometer-upgrade

完成安装

$ systemctl enable openstack-ceilometer-notification.service \
  openstack-ceilometer-central.service
$ systemctl start openstack-ceilometer-notification.service \
  openstack-ceilometer-central.service

2、启用cinder计量器(本节命令在控制器和块存储节点上都运行)

编辑/etc/cinder/cinder.conf文件并完成以下操作

$ vim /etc/cinder/cinder.conf

[oslo_messaging_notifications]

driver = messagingv2

启用与块存储相关的定期使用统计

$ cinder-volume-usage-audit  --start_time='YYYY-MM-DD HH:MM:SS' \
  --end_time='YYYY-MM-DD HH:MM:SS' --send_actions

或者使用cron计划任务服务

$ yum install yum-cron
$ vim cron.sh
*/5 * * * * /path/to/cinder-volume-usage-audit --send_actions

#每五分钟运行一次
$ crontab -u root cron.sh

完成安装

重启控制器节点上的块存储服务

$ systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service

重启存储节点上的块存储服务

$ systemctl restart openstack-cinder-volume.service

3、启用glance服务计量器(本节命令运行在控制节点上)

编辑/etc/glance/glance-api.conf和

$ vim /etc/glance/glance-registry.conf
[DEFAULT]

transport_url = rabbit://openstack:RABBIT_PASS@controller

[oslo_messaging_notifications]

driver = messagingv2

文件并完成以下操作

$ vim /etc/glance/glance-api.conf
[DEFAULT]

transport_url = rabbit://openstack:RABBIT_PASS@controller

[oslo_messaging_notifications]

driver = messagingv2

完成安装

$ systemctl restart openstack-glance-api.service openstack-glance-registry.service

4、启用heat服务计量器(本节命令运行在控制节点上)

编辑/etc/heat/heat.conf并完成以下操作

$ vim /etc/heat/heat.conf

[oslo_messaging_notifications]
driver = messagingv2

重新启动编排服务

$ systemctl restart openstack-heat-api.service \
  openstack-heat-api-cfn.service openstack-heat-engine.service

5、启用neutron服务计量器(本节命令运行在控制节点上)

编辑/etc/neutron/neutron.conf并完成以下操作

$vim /etc/neutron/neutron.conf
[oslo_messaging_notifications]

driver = messagingv2

重启网络服务

$ systemctl restart neutron-server.service

6、启用swift服务计量器(本节命令运行在控制节点上)

ceilometer服务需要使用ResellerAdmin角色访问对象存储服务

$ source admin-openstack.sh

 创建ResellerAdmin角色

$ openstack role create ResellerAdmin

将ResellerAdmin角色添加到ceilometer用户

$ openstack role add --project service --user ceilometer ResellerAdmin

安装软件包

$ yum install python-ceilometermiddleware

编辑/etc/swift/proxy-server.conf文件并完成以下操作

$ vim /etc/swift/proxy-server.conf

[filter:keystoneauth]

operator_roles = admin, user, ResellerAdmin

[pipeline:main]
pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging ceilometer proxy-server

[filter:ceilometer]
paste.filter_factory = ceilometermiddleware.swift:filter_factory
control_exchange = swift
url = rabbit://openstack:openstack@controller:5672/
driver = messagingv2
topic = notifications
log_level = WARN

完成安装

$ systemctl restart openstack-swift-proxy.service

7、启用计算服务计量器(本节命令在计算节点上运行)

安装软件包

$ yum install openstack-ceilometer-compute
$ yum install openstack-ceilometer-ipmi 

编辑/etc/ceilometer/ceilometer.conf文件并完成以下操作注意密码

$ vim /etc/ceilometer/ceilometer.conf

[DEFAULT]

transport_url = rabbit://openstack:openstack@controller

[service_credentials]

auth_url = http://controller:5000
project_domain_id = default
user_domain_id = default
auth_type = password
username = ceilometer
project_name = service
password = 1234
interface = internalURL
region_name = RegionOne

编辑/etc/nova/nova.conf文件并在部分中配置通知

$ vim /etc/nova/nova.conf
[DEFAULT]

instance_usage_audit = True
instance_usage_audit_period = hour
notify_on_state_change = vm_and_task_state

[oslo_messaging_notifications]

driver = messagingv2

配置计算以轮询 IPMI 仪表

编辑/etc/sudoers文件

ceilometer ALL = (root) NOPASSWD: /usr/bin/ceilometer-rootwrap /etc/ceilometer/rootwrap.conf *

编辑/etc/ceilometer/polling.yaml以包含所需的仪表

$ vim /etc/ceilometer/polling.yaml
- name: ipmi
  interval: 300
  meters:
    - hardware.ipmi.temperature

完成安装

$ systemctl enable openstack-ceilometer-compute.service
$ systemctl start openstack-ceilometer-compute.service
$ systemctl enable openstack-ceilometer-ipmi.service 
$ systemctl start openstack-ceilometer-ipmi.service 

重启计算服务

$ systemctl restart openstack-nova-compute.service

8、验证操作

$ source admin-openstack.sh

$ gnocchi resource list  --type image

$ gnocchi resource show ID
#将id换成上一步生成的id

如果报AttributeError: _Environ instance has no attribute ‘set‘的错误

File "/usr/lib/python2.7/site-packages/gnocchiclient/shell.py", line 131, in build_option_parser
    os.environ.set("OS_AUTH_TYPE","password")
AttributeError: _Environ instance has no attribute 'set'

可以

就是将os.environ.set("OS_AUTH_TYPE","password")修改为os.environ["OS_AUTH_TYPE"]="password"

从图像服务下载 CirrOS 图像

$ IMAGE_ID=$(glance image-list | grep 'cirros' | awk '{ print $2 }')
$ glance image-download $IMAGE_ID > /tmp/cirros.img

再次列出可用仪表以验证对图像下载的检测

$ gnocchi measures show ID

删除之前下载的图像文件/tmp/cirros.img

$ rm /tmp/cirros.img

 类似资料: