十一、安装计量服务(Telemetry service):ceilometer
11.1主要功能:
##有效收集OPENSTACK服务相关的计量数据
##通过监控服务发送的通知收集事件和计量数据
##发布收集的数据到多种目标包括数据存储和消息队列
##当收集的数据触发定义的规则时创建警报。
11.2主要组件:
A compute agent (ceilometer-agent-compute):计算代理,运行于各个计算节点并统计资源利用情况。
A central agent (ceilometer-agent-central):中心代理,运行于中心管理服务器,收集统计与实例或计算节点无关的资源利用情况。
A notification agent (ceilometer-agent-notification):通知代理,运行于中心管理服务器,根据消息队列中信息产生事件和计量数据。
A collector (ceilometer-collector):收集器,运行于中心管理服务器,调度收集计量数据存储或未修改的外部用户
An alarm evaluator (ceilometer-alarm-evaluator):警报器,运行于一个或多个中心管理服务器,用于确定当超过阈值时产生警报的间隔。
An alarm notifier (ceilometer-alarm-notifier):通知器,运行于一个或多个中心管理服务器,为一堆以阈值为基础的模板设置告警。
An API server (ceilometer-api):API服务,运行于一个或多个中心管理服务器,提供对存储的计量数据的访问。
##这些组件使用消息总线联系,只有收集器和API服务使用数据存储。
11.3准备与安装
11.3.1安装配置数据库,参考环境准备阶段
11.3.2创建数据库
[root@comtroller1 ~]# mongo --host controller1 --eval ' db = db.getSiblingDB("ceilometer"); db.createUser({user: "ceilometer", pwd: "ceilometer", roles: [ "readWrite", "dbAdmin" ]})' MongoDB shell version: 2.6.11 connecting to: controller1:27017/test Successfully added user: { "user" : "ceilometer", "roles" : [ "readWrite", "dbAdmin" ] }
11.3.3创建用户并加入角色和项目
[root@comtroller1 ~]# . admin-openrc.sh [root@comtroller1 ~]# openstack user create --domain default --password-prompt ceilometer User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id | 7a55a2056ceb460aa661ce0bfb881a4d | | name | ceilometer | +-----------+----------------------------------+ [root@comtroller1 ~]# openstack role add --project service --user ceilometer admin
11.3.4创建服务实体和AIP端点
[root@comtroller1 ~]# openstack service create --name ceilometer --description "Telemetry" metering +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Telemetry | | enabled | True | | id | 252426fc2d2642e5a09c1a35d1caa4c8 | | name | ceilometer | | type | metering | +-------------+----------------------------------+ [root@comtroller1 ~]# openstack endpoint create --region RegionOne metering public http://controller1:8777 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 696639b6d93d4841bd1e10555b0e05b8 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 252426fc2d2642e5a09c1a35d1caa4c8 | | service_name | ceilometer | | service_type | metering | | url | http://controller1:8777 | +--------------+----------------------------------+ [root@comtroller1 ~]# openstack endpoint create --region RegionOne metering internal http://controller1:8777 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 4873da56114445de86f822b360e0614d | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 252426fc2d2642e5a09c1a35d1caa4c8 | | service_name | ceilometer | | service_type | metering | | url | http://controller1:8777 | +--------------+----------------------------------+ [root@comtroller1 ~]# openstack endpoint create --region RegionOne metering admin http://controller1:8777 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 1d8e2e499b6840178f5d09a172abce06 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 252426fc2d2642e5a09c1a35d1caa4c8 | | service_name | ceilometer | | service_type | metering | | url | http://controller1:8777 | +--------------+----------------------------------+
11.3.4安装配置组件
[root@comtroller1 ~]# yum install openstack-ceilometer-api openstack-ceilometer-collector openstack-ceilometer-notification openstack-ceilometer-central openstack-ceilometer-alarm python-ceilometerclient -y [root@comtroller1 ~]# vi /etc/ceilometer/ceilometer.conf [database] connection = mongodb://ceilometer:ceilometer@controller1:27017/ceilometer ##此中不能包含 ‘:’, ‘/’, ‘+’, and ‘@’ 字符。 [DEFAULT] rpc_backend = rabbit [oslo_messaging_rabbit] rabbit_host = controller1 rabbit_userid = openstack rabbit_password = openstack [DEFAULT] auth_strategy = keystone [keystone_authtoken] auth_uri = http://controller1:5000 auth_url = http://controller1:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = ceilometer password = ceilometer [service_credentials] os_auth_url = http://controller1:5000/v2.0 os_username = ceilometer os_tenant_name = service os_password = ceilometer os_endpoint_type = internalURL os_region_name = RegionOne [DEFAULT] verbose = True ##可选,用于排错
11.3.5启动服务并设置自启动
[root@comtroller1 ~]# systemctl enable openstack-ceilometer-api.service openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service openstack-ceilometer-alarm-evaluator.service openstack-ceilometer-alarm-notifier.service [root@comtroller1 ~]# systemctl start openstack-ceilometer-api.service openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service openstack-ceilometer-alarm-evaluator.service openstack-ceilometer-alarm-notifier.service [root@comtroller1 ~]# systemctl status openstack-ceilometer-api.service openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service openstack-ceilometer-alarm-evaluator.service openstack-ceilometer-alarm-notifier.service
11.4配置IMAGE使用TELEMETRY
[root@comtroller1 ~]# vi /etc/glance/glance-api.conf [DEFAULT] notification_driver = messagingv2 rpc_backend = rabbit [oslo_messaging_rabbit] rabbit_host = controller1 rabbit_userid = openstack rabbit_password = openstack [root@comtroller1 ~]# vi /etc/glance/glance-registry.conf [DEFAULT] notification_driver = messagingv2 rpc_backend = rabbit [oslo_messaging_rabbit] rabbit_host = controller1 rabbit_userid = openstack rabbit_password = openstack [root@comtroller1 ~]# systemctl restart openstack-glance-api.service openstack-glance-registry.service [root@comtroller1 ~]# systemctl status openstack-glance-api.service openstack-glance-registry.service
11.5配置compute使用telemetry(执行此操作于每个计算节点)
11.5.1安装包
[root@compute1 ~]# yum install openstack-ceilometer-compute python-ceilometerclient python-pecan -y 11.5.2配置 [root@compute1 ~]# vi /etc/ceilometer/ceilometer.conf [DEFAULT] rpc_backend = rabbit [oslo_messaging_rabbit] rabbit_host = controller1 rabbit_userid = openstack rabbit_password = openstack [DEFAULT] auth_strategy = keystone [keystone_authtoken] auth_uri = http://controller1:5000 auth_url = http://controller1:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = ceilometer password = ceilometer [service_credentials] os_auth_url = http://controller1:5000/v2.0 os_username = ceilometer os_tenant_name = service os_password = ceilometer os_endpoint_type = internalURL os_region_name = RegionOne [DEFAULT] verbose = True [root@compute1 ~]# /etc/nova/nova.conf [DEFAULT] instance_usage_audit = True instance_usage_audit_period = hour notify_on_state_change = vm_and_task_state notification_driver = messagingv2 [root@compute1 ~]# systemctl enable openstack-ceilometer-compute.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-ceilometer-compute.service to /usr/lib/systemd/system/openstack-ceilometer-compute.service. [root@compute1 ~]# systemctl start openstack-ceilometer-compute.service [root@compute1 ~]# systemctl restart openstack-nova-compute.service
11.6配置块存储节点(cinder)使用telemetry(执行此操作于控制节点和块存储节点)
[root@block1 ~]# vi /etc/cinder/cinder.conf [DEFAULT] notification_driver = messagingv2 [root@comtroller1 ~]# vi /etc/cinder/cinder.conf [DEFAULT] notification_driver = messagingv2 [root@comtroller1 ~]# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service [root@block1 ~]# # systemctl restart openstack-cinder-volume.service
11.7配置对象存储节点(swift)使用TELEMETRY
11.7.1准备###执行此操作于控制节点
[root@comtroller1 ~]# . admin-openrc.sh [root@comtroller1 ~]# openstack role create ResellerAdmin +-------+----------------------------------+ | Field | Value | +-------+----------------------------------+ | id | 53cf5d6b41384caa8d2658e3d86da9a7 | | name | ResellerAdmin | +-------+----------------------------------+ [root@comtroller1 ~]# openstack role add --project service --user ceilometer ResellerAdmin [root@comtroller1 ~]# yum install python-ceilometermiddleware -y
11.7.2配置###执行此操作于控制节点以及运行有对象存储代理服务(Object Storage proxy service)节点
[root@comtroller1 ~]# vi /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 ###增加ceilometer,顺序有关系。 ####增加此配置组 [filter:ceilometer] paste.filter_factory = ceilometermiddleware.swift:filter_factory control_exchange = swift url = rabbit://openstack:openstack@controller1:5672/ driver = messagingv2 topic = notifications log_level = WARN [root@comtroller1 ~]# systemctl restart openstack-swift-proxy.service
11.8验证
[root@comtroller1 ~]# . admin-openrc.sh [root@comtroller1 ~]# ceilometer meter-list +------------+-------+-------+--------------------------------------+---------+----------------------------------+ | Name | Type | Unit | Resource ID | User ID | Project ID | +------------+-------+-------+--------------------------------------+---------+----------------------------------+ | p_w_picpath | gauge | p_w_picpath | ba4fd4dd-7717-4e11-8a64-5b063882b0aa | None | b56d4cdbaea54df1b3cd3b769ce896a0 | | p_w_picpath.size | gauge | B | ba4fd4dd-7717-4e11-8a64-5b063882b0aa | None | b56d4cdbaea54df1b3cd3b769ce896a0 | +------------+-------+-------+--------------------------------------+---------+----------------------------------+ [root@comtroller1 ~]# IMAGE_ID=$(glance p_w_picpath-list | grep 'cirros' | awk '{ print $2 }') [root@comtroller1 ~]# glance p_w_picpath-download $IMAGE_ID > /tmp/cirros.img [root@comtroller1 ~]# ceilometer meter-list +----------------+-------+-------+--------------------------------------+----------------------------------+----------------------------------+ | Name | Type | Unit | Resource ID | User ID | Project ID | +----------------+-------+-------+--------------------------------------+----------------------------------+----------------------------------+ | p_w_picpath | gauge | p_w_picpath | ba4fd4dd-7717-4e11-8a64-5b063882b0aa | 2a087a69805b423698e58c8830938167 | b56d4cdbaea54df1b3cd3b769ce896a0 | | p_w_picpath.download | delta | B | ba4fd4dd-7717-4e11-8a64-5b063882b0aa | 2a087a69805b423698e58c8830938167 | b56d4cdbaea54df1b3cd3b769ce896a0 | | p_w_picpath.serve | delta | B | ba4fd4dd-7717-4e11-8a64-5b063882b0aa | 2a087a69805b423698e58c8830938167 | b56d4cdbaea54df1b3cd3b769ce896a0 | | p_w_picpath.size | gauge | B | ba4fd4dd-7717-4e11-8a64-5b063882b0aa | 2a087a69805b423698e58c8830938167 | b56d4cdbaea54df1b3cd3b769ce896a0 | +----------------+-------+-------+--------------------------------------+----------------------------------+----------------------------------+ [root@comtroller1 ~]# ceilometer statistics -m p_w_picpath.download -p 60 +--------+----------------------------+----------------------------+------------+------------+------------+------------+-------+----------+----------------------------+----------------------------+ | Period | Period Start | Period End | Max | Min | Avg | Sum | Count | Duration | Duration Start | Duration End | +--------+----------------------------+----------------------------+------------+------------+------------+------------+-------+----------+----------------------------+----------------------------+ | 60 | 2016-08-08T08:09:51.673000 | 2016-08-08T08:10:51.673000 | 13287936.0 | 13287936.0 | 13287936.0 | 13287936.0 | 1 | 0.0 | 2016-08-08T08:10:30.985000 | 2016-08-08T08:10:30.985000 | +--------+----------------------------+----------------------------+------------+------------+------------+------------+-------+----------+----------------------------+----------------------------+ [root@comtroller1 ~]# rm /tmp/cirros.img rm: remove regular file ‘/tmp/cirros.img’? y