OpenStack Ocata Telemetry 数据收集服务
1 安装配置计算服务
在所有计算节点上:
1.1 安装配置组件
安装包:
# yum install -y openstack-ceilometer-compute
编辑配置文件/etc/ceilometer/ceilometer.conf
:
[DEFAULT]
...
transport_url = rabbit://openstack:pass123456@controller3
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller3:5000
auth_url = http://controller3:35357
memcached_servers = controller3:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = pass123456
[service_credentials]
...
auth_url = http://controller3:5000
project_domain_id = default
user_domain_id = default
auth_type = password
username = ceilometer
project_name = service
password = pass123456
interface = internalURL
region_name = RegionOne
1.2 配置计算节点使用Telemetry
编辑配置文件/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
1.3 完成安装
开启代理和配置开机启动,并重启计算服务:
# systemctl enable openstack-ceilometer-compute.service
# systemctl start openstack-ceilometer-compute.service
# systemctl restart openstack-nova-compute.service
2 安装配置控制服务
以下操作在控制节点上进行:
2.1 Ceilometer服务:
2.1.1 创建gnocchi数据库
# 用root用户登录数据库
$ mysql -u root -p
# 创建gnocchi数据库
MariaDB [(none)]> CREATE DATABASE gnocchi;
# 赋予用户操作数据库最高权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'controller3' IDENTIFIED BY 'pass123456';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' IDENTIFIED BY 'pass123456';
MariaDB [(none)]> exit
2.1.2 配置Ceilometer服务
2.1.2.1 创建ceilometer用户
$ . admin-openrc
$ openstack user create --domain default --password-prompt ceilometer
User Password:
Repeat User Password:
$ openstack role add --project service --user ceilometer admin
2.1.2.2 创建ceilometer服务实体
$ openstack service create --name ceilometer \
--description "Telemetry" metering
2.1.3 配置Gnocchi服务
2.1.3.1 创建gnocchi用户
$ openstack user create --domain default --password-prompt gnocchi
User Password:
Repeat User Password:
$ openstack role add --project service --user gnocchi admin
2.1.3.2 创建gnocchi服务实体
$ openstack service create --name gnocchi \
--description "Metric Service" metric
2.1.3.3 创建gnocchi API端点
$ openstack endpoint create --region RegionOne \
metric public http://controller3:8041
$ openstack endpoint create --region RegionOne \
metric internal http://controller3:8041
$ openstack endpoint create --region RegionOne \
metric admin http://controller3:8041
2.1.4 安装组件
2.1.4.1 安装gnocchi组件
首先安装编译所需要的工具和开发包:
# yum install -y gcc python-devel
# pip install lz4
安装包:
$ pip install gnocchi[file,postgresql,keystone]
2.1.4.2 安装ceilometer组件
安装包:
# yum install -y openstack-ceilometer-collector openstack-ceilometer-notification \
openstack-ceilometer-central python-ceilometerclient
2.1.5 配置组件
创建一些会使用到的文件夹
$ mkdir /etc/gnocchi
$ mkdir /var/log/gnocchi
2.1.5.1 配置ceilometer服务
编辑配置文件/etc/ceilometer/ceilometer.conf
:
[DEFAULT]
debug = true
verbose = true
meter_dispatchers=gnocchi
event_dispatchers=gnocchi
transport_url = rabbit://openstack:pass123456@controller3
[dispatcher_gnocchi]
filter_service_activity = False
archive_policy = low
[service_credentials]
...
auth_type = password
auth_url = http://controller3:5000/v3
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = pass123456
interface = internalURL
region_name = RegionOne
2.1.5.2 配置gnocchi服务
编辑/etc/gnocchi/gnocchi.conf
文件
[DEFAULT]
debug = true
verbose = true
log_dir = /var/log/gnocchi
[api]
workers = 4
auth_mode = keystone
middlewares = oslo_middleware.cors.CORS
[indexer]
url = mysql+pymysql://gnocchi:pass123456@controller3/gnocchi?charset=utf8
[keystone_authtoken]
auth_type = password
auth_url = http://controller3:5000/v3
auth_uri = http://controller3:35357/v3
memcached_servers = controller3:11211
project_domain_name = Default
user_domain_name = Default
project_name = service
username = gnocchi
password = pass123456
interface = internalURL
region_name = RegionOne
[statsd]
host = controller3
resource_id = 83746b69-87e8-4ee2-b9af-39769cc32b75
archive_policy_name = low
初始化gnocchi的indexer和storage
$ gnocchi-upgrade
编辑启动脚本/usr/bin/gnocchi-api
, ,将默认的8000 API服务端口改为8041:
parser.add_argument('--port', '-p', type=int, default=8041,
help='TCP port to listen on')
运行gnocchi:
$ gnocchi-api
$ gnocchi-statsd
$ gnocchi-metricd
在admin-openrc
用户权限环境脚本里添加:
export OS_AUTH_TYPE=password
创建在gnocchi中Ceilometer资源:
# ceilometer-upgrade --skip-metering-database
2.1.3 完成安装
开启Telemetry服务并且配置随系统启动:
# systemctl enable openstack-ceilometer-notification.service \
openstack-ceilometer-central.service \
openstack-ceilometer-collector.service
# systemctl start openstack-ceilometer-notification.service \
openstack-ceilometer-central.service \
openstack-ceilometer-collector.service
2.2 块服务
2.2.1 配置Cinder使用Telemetry
编辑配置文件/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
2.2.2 完成安装
在控制节点重启块存储服务:
# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
在存储节点重启块服务:
# systemctl restart openstack-cinder-volume.service
2.3 镜像服务
2.3.1 配置Glance使用Telemetry
编辑配置文件/etc/glance/glance-api.conf
和/etc/glance/glance-registry.conf
:
[DEFAULT]
...
transport_url = rabbit://openstack:pass123456@controller3
[oslo_messaging_notifications]
...
driver = messagingv2
2.3.2 完成安装
重启镜像服务:
# systemctl restart openstack-glance-api.service openstack-glance-registry.service
2.4 网络服务
2.4.1 配置Neutron使用Telemetry
编辑配置文件 /etc/neutron/neutron.conf
:
[oslo_messaging_notifications]
...
driver = messagingv2
2.4.2 完成安装
重启网络服务:
# systemctl restart neutron-server.service
3 验证操作
$ . admin-openrc
$ gnocchi resource list --type image
+--------------------------------------+-------+----------------------------------+---------+--------------------------------------+----------------------------------+----------+----------------------------------+--------------+
| id | type | project_id | user_id | original_resource_id | started_at | ended_at | revision_start | revision_end |
+--------------------------------------+-------+----------------------------------+---------+--------------------------------------+----------------------------------+----------+----------------------------------+--------------+
| a6b387e1-4276-43db-b17a-e10f649d85a3 | image | 6fd9631226e34531b53814a0f39830a9 | None | a6b387e1-4276-43db-b17a-e10f649d85a3 | 2017-01-25T23:50:14.423584+00:00 | None | 2017-01-25T23:50:14.423601+00:00 | None |
+--------------------------------------+-------+----------------------------------+---------+--------------------------------------+----------------------------------+----------+----------------------------------+--------------+
$ gnocchi resource show a6b387e1-4276-43db-b17a-e10f649d85a3
+-----------------------+-------------------------------------------------------------------+
| Field | Value |
+-----------------------+-------------------------------------------------------------------+
| created_by_project_id | aca4db3db9904ecc9c1c9bb1763da6a8 |
| created_by_user_id | 07b0945689a4407dbd1ea72c3c5b8d2f |
| creator | 07b0945689a4407dbd1ea72c3c5b8d2f:aca4db3db9904ecc9c1c9bb1763da6a8 |
| ended_at | None |
| id | a6b387e1-4276-43db-b17a-e10f649d85a3 |
| metrics | image.download: 839afa02-1668-4922-a33e-6b6ea7780715 |
| | image.serve: 1132e4a0-9e35-4542-a6ad-d6dc5fb4b835 |
| | image.size: 8ecf6c17-98fd-446c-8018-b741dc089a76 |
| original_resource_id | a6b387e1-4276-43db-b17a-e10f649d85a3 |
| project_id | 6fd9631226e34531b53814a0f39830a9 |
| revision_end | None |
| revision_start | 2017-01-25T23:50:14.423601+00:00 |
| started_at | 2017-01-25T23:50:14.423584+00:00 |
| type | image |
| user_id | None |
+-----------------------+-------------------------------------------------------------------+
$ IMAGE_ID=$(glance image-list | grep 'cirros' | awk '{ print $2 }')
$ glance image-download $IMAGE_ID > /tmp/cirros.img
$ gnocchi measures show 839afa02-1668-4922-a33e-6b6ea7780715
+---------------------------+-------------+-----------+
| timestamp | granularity | value |
+---------------------------+-------------+-----------+
| 2017-01-26T15:35:00+00:00 | 300.0 | 3740163.0 |
+---------------------------+-------------+-----------+
$ rm /tmp/cirros.img