openstack之kilo安装 监控服务

Telemetry 提供一个监控和检测 OpenStack 云的框架。也就是大家所知道的 ceilometer 项目。

Telemetry 模块表现有如下功能:

Efficiently polls metering data related to OpenStack services.

Collects event and metering data by monitoring notifications sent from services.

Publishes collected data to various targets including data stores and message queues.

Creates alarms when collected data breaks defined rules.

Telemetry 模块通常包含下面组件:

  • A compute agent (ceilometer-agent-compute)
    运行在每个计算节点中,推送资源的使用状态,也许在未来会有其他类型的代理,但是目前来说社区专注于创建计算节点代理。

  • A central agent (ceilometer-agent-central)
    Runs on a central management server to poll for resource utilization statistics for resources not tied to instances or compute nodes. Multiple agents can be started to scale service horizontally.

  • A notification agent (ceilometer-agent-notification)
    Runs on a central management server(s) and consumes messages from the message queue(s) to build event and metering data.

  • A collector (ceilometer-collector)
    运行在一个或多个中心管理服务器,当警告发生是由于相关联的统计趋势超过阈值以上的滑动时间窗口,然后作出决定。

  • An alarm evaluator (ceilometer-alarm-evaluator)
    运行在一个或多个中心管理服务器,允许警告为一组收集的实例基于评估阀值来设置。

  • An alarm notifier (ceilometer-alarm-notifier)
    Runs on one or more central management servers to allow alarms to be set based on the threshold evaluation for a collection of samples.

  • An API server (ceilometer-api)
    运行在一个或多个中心管理服务器,提供从数据存储的数据访问。

这些服务使用OpenStack消息总线来通信,只有收集者和API服务可以访问数据存储。

参考:Chapter 11. Add the Telemetry module

Install and configure controller node

Telemetry模块使用分离的代理来从您环境的 OpenStack 服务中收集评估。

安装 MongoDB package:

#
yum install -y mongodb-server mongodb

编辑 /etc/mongod.conf 文件:

#
echo "
bind_ip = 10.0.0.11
smallfiles = true">>/etc/mongod.conf

启动 MongoDB 服务并将其配置为随系统启动:

#
systemctl enable mongod.service
systemctl start mongod.service

创建 ceilometer database:

#
mongo --host controller --eval '
db = db.getSiblingDB("ceilometer");
db.createUser({user: "ceilometer",
pwd: "CEILOMETER_DBPASS",
roles: [ "readWrite", "dbAdmin" ]})'

导入 admin身份凭证以执行管理员用户专有的命令:

#
source admin-openrc.sh

创建 ceilometer user:

#
openstack user create ceilometer --password ceilometer

添加 admin role to the ceilometer user.

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

创建 ceilometer service entity:

#
openstack service create --name ceilometer \
--description "Telemetry" metering

创建 Telemetry module API endpoint:

#
openstack endpoint create \
--publicurl http://controller:8777 \
--internalurl http://controller:8777 \
--adminurl http://controller:8777 \
--region RegionOne \
metering

安装软件包:

#
yum install -y openstack-ceilometer-api openstack-ceilometer-collector \
openstack-ceilometer-notification openstack-ceilometer-central openstack-ceilometer-alarm \
python-ceilometerclient

Generate a random value to use as the telemetry secret:

#
openssl rand -hex 10

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

#
cp /etc/ceilometer/ceilometer.conf /etc/ceilometer/ceilometer.confbak
echo "[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
verbose = True
[api]
port = 8777
host = 0.0.0.0
# MongoDB connection info
[database]
connection = mongodb://ceilometer:CEILOMETER_DBPASS@controller:27017/ceilometer
# RabbitMQ connection info
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_port = 5672
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
# Keystone auth info
[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = ceilometer
admin_password = ceilometer
# set the secret key which is shared among nodes.(set any words you like)
[publisher]
telemetry_secret = TELEMETRY_SECRET
# Ceilometer auth info
[service_credentials]
os_auth_url = http://controller:5000/v2.0
os_username = ceilometer
os_tenant_name = service
os_password = ceilometer
os_endpoint_type = internalURL
os_region_name = RegionOne">/etc/ceilometer/ceilometer.conf

启动Telemetry服务并将其配置为随系统启动:

#
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
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

Configure the Compute service

Telemetry uses a combination of notifications and an agent to collect Compute metrics. Perform these steps on each compute node.

安装软件包:

#
yum install -y openstack-ceilometer-compute python-ceilometerclient python-pecan

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

#
cp /etc/ceilometer/ceilometer.conf /etc/ceilometer/ceilometer.confbak
echo "[DEFAULT]
rpc_backend = rabbit
verbose = True
# RabbitMQ connection info
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_port = 5672
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
# Keystone auth info
[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = ceilometer
admin_password = ceilometer
# set the secret key which is shared among nodes.(set any words you like)
[publisher]
telemetry_secret = TELEMETRY_SECRET
# Ceilometer auth info
[service_credentials]
os_auth_url = http://controller:5000/v2.0
os_username = ceilometer
os_tenant_name = service
os_password = ceilometer
os_endpoint_type = internalURL
os_region_name = RegionOne">/etc/ceilometer/ceilometer.conf

Configure the Compute service to send notifications to the message bus.

修改配置文件 /etc/nova/nova.conf并在 [DEFAULT]部分配置消息机制:

#
echo "
[DEFAULT]
instance_usage_audit = True
instance_usage_audit_period = hour
notify_on_state_change = vm_and_task_state
notification_driver = messagingv2">>/etc/nova/nova.conf

Start the Telemetry agent and configure it to start when the system boots:

#
systemctl enable openstack-ceilometer-compute.service
systemctl start openstack-ceilometer-compute.service

重启 Compute service:

#
systemctl restart openstack-nova-compute.service

Configure the Image service

To retrieve image-oriented events and samples, configure the Image service to send notifications to the message bus. Perform these steps on the controller node.

编辑 /etc/glance/glance-api.conf 和 /etc/glance/glance-registry.conf 文件:

#
echo "
[DEFAULT]
notification_driver = messagingv2
rpc_backend = rabbit
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS">>/etc/glance/glance-api.conf
#
echo "
[DEFAULT]
notification_driver = messagingv2
rpc_backend = rabbit
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS">>/etc/glance/glance-registry.conf

重启Image service:

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

Configure the Block Storage service

To retrieve volume-oriented events and samples, you must configure the Block Storage service to send notifications to the message bus. Perform these steps on the controller and storage nodes.

编辑 /etc/cinder/cinder.conf :

#
echo "
[DEFAULT]
control_exchange = cinder
notification_driver = messagingv2">> /etc/cinder/cinder.conf

重启 Block Storage services on the storage nodes:

#
systemctl restart openstack-cinder-volume.service

重启 Block Storage services on the controller node:

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

Use the cinder-volume-usage-audit command to retrieve metrics on demand. For more information, see Block Storage audit script setup to get notifications.

Configure the Object Storage service

To retrieve storage-oriented events and samples, configure the Object Storage service to send notifications to the message bus.

The Telemetry service requires access to the Object Storage service using the ResellerAdmin role. Perform these steps on the controller node.

Source the admin credentials to gain access to admin-only CLI commands.

#
source admin-openrc.sh

Create the ResellerAdmin role:

#
openstack role create ResellerAdmin

添加 ResellerAdmin role to the service tenant and ceilometer user:

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

Perform these steps on the controller and any other nodes that run the Object Storage proxy service.

编辑 /etc/swift/proxy-server.conf 文件:

echo "
[filter:keystoneauth]
operator_roles = admin,user,ResellerAdmin
[pipeline:main]
pipeline = ceilometer
[filter:ceilometer]
paste.filter_factory = ceilometermiddleware.swift:filter_factory
control_exchange = swift
url = rabbit://openstack:RABBIT_PASS@controller:5672/
driver = messagingv2
topic = notifications
log_level = WARN">>/etc/swift/proxy-server.conf

Add the swift system user to the ceilometer system group to permit access to the Telemetry configuration files by the Object Storage service:

#
usermod -a -G ceilometer swift

安装 ceilometermiddleware package:

#
yum install -y python-pip
pip install ceilometermiddleware
pip install ceilometermiddleware -i http://192.178.102.249/pypi/web/simple/ --trusted-host 192.178.102.249

重启 the Object Storage proxy service:

#
systemctl restart openstack-swift-proxy.service

Verify the Telemetry installation

This section describes how to verify operation of the Telemetry module.

[Note] Note
Perform these steps on the controller node.

Source the admin credentials to gain access to admin-only CLI commands:

#
source admin-openrc.sh

List available meters:

#
ceilometer meter-list

Download an image from the Image service:

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

List available meters again to validate detection of the image download:

#
ceilometer meter-list

Retrieve usage statistics from the image.download meter:

#
ceilometer statistics -m image.download -p 60

Remove the previously downloaded image file /tmp/cirros.img:

#
rm /tmp/cirros.img