在全部計算節點上:python
安裝包:mysql
# yum install -y openstack-ceilometer-compute
編輯配置文件/etc/ceilometer/ceilometer.conf
:sql
[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
編輯配置文件/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
開啓代理和配置開機啓動,並重啓計算服務:api
# systemctl enable openstack-ceilometer-compute.service # systemctl start openstack-ceilometer-compute.service # systemctl restart openstack-nova-compute.service
如下操做在控制節點上進行:bash
# 用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
$ . admin-openrc $ openstack user create --domain default --password-prompt ceilometer User Password: Repeat User Password: $ openstack role add --project service --user ceilometer admin
$ openstack service create --name ceilometer \ --description "Telemetry" metering
$ openstack user create --domain default --password-prompt gnocchi User Password: Repeat User Password: $ openstack role add --project service --user gnocchi admin
$ openstack service create --name gnocchi \ --description "Metric Service" metric
$ 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
首先安裝編譯所須要的工具和開發包:網絡
# yum install -y gcc python-devel # pip install lz4
安裝包:cors
$ pip install gnocchi[file,postgresql,keystone]
安裝包:dom
# yum install -y openstack-ceilometer-collector openstack-ceilometer-notification \ openstack-ceilometer-central python-ceilometerclient
建立一些會使用到的文件夾memcached
$ mkdir /etc/gnocchi $ mkdir /var/log/gnocchi
編輯配置文件/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
編輯/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
開啓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
編輯配置文件/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
在控制節點重啓塊存儲服務:
# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
在存儲節點重啓塊服務:
# systemctl restart openstack-cinder-volume.service
編輯配置文件/etc/glance/glance-api.conf
和/etc/glance/glance-registry.conf
:
[DEFAULT] ... transport_url = rabbit://openstack:pass123456@controller3 [oslo_messaging_notifications] ... driver = messagingv2
重啓鏡像服務:
# systemctl restart openstack-glance-api.service openstack-glance-registry.service
編輯配置文件/etc/neutron/neutron.conf
:
[oslo_messaging_notifications] ... driver = messagingv2
重啓網絡服務:
# systemctl restart neutron-server.service
$ . 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