部署ceilometer监控组件
a.安装mongodb数据库
#apt-get install mongodb-server mongodb-clients python-pymongo
b.重启mongodb服务
#service mongodb stop
#service mongodb start
c.创建ceilometer数据库
# mongodb --host localhost --eval '
> db = db.get SiblingDB("ceilometer");
> dn.addUser({user: "ceilometer",
> pwd: "ceilometer",
> roles: [ "readWrite", "dbAdmin" ]})'
执行结果:
MongoDB shell veersion:2.4.x
connecting to : localhost:27017/test
{
"user" : "ceilometer",
"pwd" : "72f25aeee7ad4be52437d7cd3fc60f6f",
"roles" : [
"readWrite",
"dbAdmin"
],
"_id" : ObjectId("5489c22270d7fad1ba631dc3")
}
d.创建一个环境(csrc)
export OS_USERNAME=admin
export OS_PASSWORD=keystone
export OS_TENANT_NAME=admin
export OS_SERVICE_ENDPOINT=http://127.0.0.1:35357/v2.0
export OS_SERVICE_TOKEN=b9e61571f3b4de09ca60
export OS_AUTH_URL=http://127.0.0.1:35357/v2.0
#source csrc
e.keystone 中创建ceilometer用户及服务endpoint
#keystone user-create --name=ceilometer --pass=ceilometer --email=ceilometer@example.com
#keystone user-role-add --name=ceilometer --tenant=service --role=admin
#keystone service-create --name=ceilometer --type=metering --description="Ceilometer Telemetery Service"
#keystone endpoint-create --service-id=the_service_id_on_ above --publicurl=http://127.0.0.1:8777 --internalurl=http://127.0.0.1:8777 --adminurl=http://127.0.0.1:8777
f.安装ceilometer包
#apt-get install ceilometer-api ceilometer-collector ceilometer-agent-central ceilometer-agent-notification ceilometer-alarm-evaluator ceilometer-alarm-notifier python-ceilometerclient
g.生成随机值作为telemetry secret
#openssl rand -hex 10
h. 修改/etc/ceilometer/ceilometer.conf
[DEFAULT]
rpc_backend=ceilometer.openstack.common.rpc.impl_kombu
auth_strategy=keystone
verbose=True
[database]
connection = mongodb://ceilometer:ceilometer@localhost:27017/ceilometer
[oslo_messaging_rabbit]
rabbit_host=localhost
rabbit_userid=guest
rabbit_paaword=guest
[keystone_authtoken]
auth_uri=http://127.0.0.1:5000/v2.0
auth_host=127.0.0.1
auth_port=35357
auth_protocol=http
注:也可以用identity_url=http://127.0.0.1:35357替换auth_host,auth_port,auth_protocol
admin_tenant_name=service
admin_user=ceilometer
admin_password=ceilometer
[service_credentials]
os_auth_url=http://127.0.0.1:5000/v2.0
os_username=ceilometer
os_password=ceilometer
os_endpoint_type=internalURL
os_region_name=RegionOne
[publisher]
metering_secret = CEILOMETER_TOKEN (上面随机生成的值)
i.重启服务
#service ceilometer-agent-central restart
#service ceilometer-agent-notification restart
#service ceilometer-api restart
#service ceilometer-collector restart
#service ceilometer-agent-evaluator restart
#service ceilometer-agent-notifier restart
j.安装compute包
#apt-get install ceilometer-agent-compute
k.编辑/etc/nova/nvoa.conf,/etc/nova/nova-compute.conf,/etc/glance/glance-api.conf与/etc/galnce/glance-registry.conf
/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
notification_driver = ceilometer.compute.nova_notifier
/etc/nova/nova-compute.conf
virt_type = qemu
重启两个服务
#service ceilometer-agent-compute restart
#service nova-compute restart
/etc/glance/glance-api.conf与/etc/glance/glance-registry.conf
[DEFAULT]
notification_driver = messagingv2
rpc_backend = rabbit
rabbit_host = 127.0.0.1
rabbit_user=guest
rabbit_password=guest
重启服务
#service glance-api restart
#service glance-registry restart
l.验证
使用命令:
ceilometer meter-list //列举所有测量值
ceilometer meter-list -q resource_id=XXX //列举某一实例测量值
ceilometer sample-list -m cpu -q resource_id=XXX //列举某一实例的cpu采集数据
ceilometer statistics -m cpu //列举实例的统计数据
ceilometer resource-list //列举所有实例列表
#ceilometer meter-list
+-------------------------------+------------+-----------+----------------------------------------------+----------------------------------+----------------------------------+
| Name | Type | Unit | Resource ID | User ID | Project ID |
+-------------------------------+------------+-----------+----------------------------------------------+----------------------------------+----------------------------------+
| cpu | cumulative | ns | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| cpu | cumulative | ns | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| cpu_util | gauge | % | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| cpu_util | gauge | % | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.ephemeral.size | gauge | GB | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.ephemeral.size | gauge | GB | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.bytes | cumulative | B | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.bytes | cumulative | B | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.bytes.rate | gauge | B/s | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.bytes.rate | gauge | B/s | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.requests | cumulative | request | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.requests | cumulative | request | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.requests.rate | gauge | request/s | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.read.requests.rate | gauge | request/s | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.root.size | gauge | GB | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.root.size | gauge | GB | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.bytes | cumulative | B | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.bytes | cumulative | B | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.bytes.rate | gauge | B/s | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.bytes.rate | gauge | B/s | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.requests | cumulative | request | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.requests | cumulative | request | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.requests.rate | gauge | request/s | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| disk.write.requests.rate | gauge | request/s | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| instance | gauge | instance | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| instance | gauge | instance | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| instance:m1.medium | gauge | instance | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| instance:m1.small | gauge | instance | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| memory | gauge | MB | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| memory | gauge | MB | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.bytes | cumulative | B | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.bytes | cumulative | B | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.bytes.rate | gauge | B/s | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.bytes.rate | gauge | B/s | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.packets | cumulative | packet | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.packets | cumulative | packet | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.packets.rate | gauge | packet/s | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.incoming.packets.rate | gauge | packet/s | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.bytes | cumulative | B | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.bytes | cumulative | B | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.bytes.rate | gauge | B/s | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.bytes.rate | gauge | B/s | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.packets | cumulative | packet | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.packets | cumulative | packet | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.packets.rate | gauge | packet/s | nova-instance-instance-00000001-fa163e5b8465 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| network.outgoing.packets.rate | gauge | packet/s | nova-instance-instance-00000002-fa163e781a4d | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| vcpus | gauge | vcpu | 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| vcpus | gauge | vcpu | a0f47cb7-91ef-41be-ba37-5e45746cb347 | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
+-------------------------------+------------+-----------+----------------------------------------------+----------------------------------+----------------------------------+
#ceilometer resource-list
+----------------------------------------------+-----------+----------------------------------+----------------------------------+
| Resource ID | Source | User ID | Project ID |
+----------------------------------------------+-----------+----------------------------------+----------------------------------+
| 16b72673-0a6d-4aff-b33a-edc2a2fe12f3 | openstack | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| a0f47cb7-91ef-41be-ba37-5e45746cb347 | openstack | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| nova-instance-instance-00000001-fa163e5b8465 | openstack | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
| nova-instance-instance-00000002-fa163e781a4d | openstack | 1eb55f701e974e0891cba5e3100f7de9 | 5efe506adf664aa786c39816982ef965 |
+----------------------------------------------+-----------+----------------------------------+----------------------------------+
到这里ceilometer组件应该部署好了。
注: 在部署终于到了问题,在/var/log/ceilometer/ceilometer-alarm-notifier.log中提示:
2015-11-09 09:49:53.870 1590 ERROR ceilometer.openstack.common.rpc.common [-] AMQP server on localhost:5672 is unreachable: [Errno 111] ECONNREFUSED. Trying again in 1 seconds.
在/var/log/ceilometer/ceilometer-alarm-evaluator.log中提示:
2015-11-09 15:37:12.505 1586 WARNING keystoneclient.httpclient [-] Failed to retrieve management_url from token
2015-11-09 15:37:12.505 1586 ERROR ceilometer.alarm.service [-] alarm evaluation cycle failed
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service Traceback (most recent call last):
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/ceilometer/alarm/service.py", line 91, in _evaluate_assigned_alarms
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service alarms = self._assigned_alarms()
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/ceilometer/alarm/service.py", line 133, in _assigned_alarms
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service return self._client.alarms.list(q=[{'field': 'enabled',
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/ceilometer/alarm/service.py", line 86, in _client
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service self.api_client = ceiloclient.get_client(2, **creds)
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/ceilometerclient/client.py", line 87, in get_client
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service _get_endpoint(_ksclient, **ks_kwargs)
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/ceilometerclient/client.py", line 42, in _get_endpoint
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service endpoint_type=kwargs.get('endpoint_type') or 'publicURL')
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/keystoneclient/utils.py", line 318, in inner
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service return func(*args, **kwargs)
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service File "/usr/lib/python2.7/dist-packages/keystoneclient/service_catalog.py", line 201, in url_for
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service raise exceptions.EndpointNotFound(msg)
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service EndpointNotFound: internalURL endpoint for metering not found
2015-11-09 15:37:12.505 1586 TRACE ceilometer.alarm.service
在/var/log/nova/nova-compute.log中提示:
2015-11-09 10:14:02.870 2220 INFO nova.compute.manager [-] Running instance usage audit for host wh-B85M-D2V-TM from 2015-11-09 01:00:00 to 2015-11-09 02:00:00. 2 instances.
2015-11-09 10:14:02.876 2220 ERROR nova.openstack.common.periodic_task [-] Error during ComputeManager._instance_usage_audit: Remote error: DBError SQLite DateTime type only accepts Python datetime and date objects as input. (original cause: TypeError: SQLite DateTime type only accepts Python datetime and date objects as input.) u'INSERT INTO task_log (created_at, updated_at, deleted_at, deleted, task_name, state, host, period_beginning, period_ending, message, task_items, errors) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' [{'period_ending': u'2015-11-09T02:00:00.000000', 'state': 'RUNNING', 'updated_at': None, 'host': u'wh-B85M-D2V-TM', 'task_items': 2, 'task_name': u'instance_usage_audit', 'period_beginning': u'2015-11-09T01:00:00.000000', 'message': u'Instance usage audit started...', 'deleted_at': None}]
[u'Traceback (most recent call last):\n', u' File "/usr/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 133, in _dispatch_and_reply\n incoming.message))\n', u' File "/usr/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 176, in _dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n', u' File "/usr/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 122, in _do_dispatch\n result = getattr(endpoint, method)(ctxt, **new_args)\n', u' File "/usr/lib/python2.7/dist-packages/nova/conductor/manager.py", line 996, in task_log_begin_task\n host, task_items, message)\n', u' File "/usr/lib/python2.7/dist-packages/nova/conductor/manager.py", line 503, in task_log_begin_task\n message)\n', u' File "/usr/lib/python2.7/dist-packages/nova/db/api.py", line 1891, in task_log_begin_task\n message)\n', u' File "/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/api.py", line 146, in wrapper\n return f(*args, **kwargs)\n', u' File "/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/api.py", line 5541, in task_log_begin_task\n task.save()\n', u' File "/usr/lib/python2.7/dist-packages/nova/db/sqlalchemy/models.py", line 52, in save\n super(NovaBase, self).save(session=session)\n', u' File "/usr/lib/python2.7/dist-packages/nova/openstack/common/db/sqlalchemy/models.py", line 49, in save\n session.flush()\n', u' File "/usr/lib/python2.7/dist-packages/nova/openstack/common/db/sqlalchemy/session.py", line 464, in _wrap\n raise exception.DBError(e)\n', u"DBError: SQLite DateTime type only accepts Python datetime and date objects as input. (original cause: TypeError: SQLite DateTime type only accepts Python datetime and date objects as input.) u'INSERT INTO task_log (created_at, updated_at, deleted_at, deleted, task_name, state, host, period_beginning, period_ending, message, task_items, errors) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' [{'period_ending': u'2015-11-09T02:00:00.000000', 'state': 'RUNNING', 'updated_at': None, 'host': u'wh-B85M-D2V-TM', 'task_items': 2, 'task_name': u'instance_usage_audit', 'period_beginning': u'2015-11-09T01:00:00.000000', 'message': u'Instance usage audit started...', 'deleted_at': None}]\n"].
以上问题不知是什么原因,正在检查,也希望大家帮忙解决一下。同时发现问题欢迎提出,谢谢!
补充内容 (2015-11-27 16:30):
错误纠正:在第h小步,修改配置文件[service_credentials]时少一个配置:os_tenant_name=service |