对于一个云环境来说,我们不但能够虚拟化出相关的虚拟机来,我们也需要来检测相关虚拟机对象的信息,例如CPU、内存、IO等,那么Openstack有一个ceilometer组件可以帮助我们获得这些信息。
测量 (Metering):Ceilometer。像一个漏斗一样,能把OpenStack内部发生的几乎所有的事件都收集起来,然后为计费和监控以及其它服务提供数据支撑。自Havana版本集成到项目中。Ceilometer作为OpenStack内部 notification的最大消费者,OpenStack内部发生的一些事件都会发出对应的notification消息,比如说创建和删除instance,这些 信息是计量/计费的重要信息,因此第一种方式是Ceilometer第一数据来源,但是有些计量信息通过notification消息是获取不到的, 比如说instance的CPU的运行时间,或者是CPU的使用率,这些信息不会通过notification消息发送出来,因此Ceilometer增加了第二种 方式,周期性的调用相关的API去获取这些信息。
下面先介绍一下怎么安装Ceilometer组件
一、在控制节点上做以下操作(192.168.3.180)
1、安装组件
sudo aptitude install ceilometer-api ceilometer-collector ceilometer-agent-central ceilometer-agent-notification ceilometer-alarm-evaluator ceilometer-alarm-notifier python-ceilometerclient
2、安装mongodb
与其他组件安装在MySQL不同的是,Ceilometer组件存储的数据在MongoDB,个人认为可能这些数据量比较大,而且需要实时获取,MongoDB效率方面较MySQL会好一些。
sudo apt-get install mongodb-server
3、编辑MongoDB的配置文件
sudo vi /etc/mongodb.conf
更新服务器IP信息:bind_ip = 192.168.3.180
4、 重启MongoDB服务
sudo service mongodb restart
5、创建数据库和ceilometer数据库用户
库名: ceilometer
账户: ceilometerdbadmin
密码: ceilometer4smtest
sudo mongo --host 192.168.3.180 --eval '
db = db.getSiblingDB("ceilometer");
db.addUser({user: "ceilometerdbadmin",
pwd: "ceilometer4smtest",
roles: [ "readWrite", "dbAdmin" ]})'
sm@controller:~$ sudo mongo --host 192.168.3.180 --eval ' > db = db.getSiblingDB("ceilometer"); > db.addUser({user: "ceilometerdbadmin", > pwd: "ceilometer4smtest", > roles: [ "readWrite", "dbAdmin" ]})' MongoDB shell version: 2.4.9 connecting to: 192.168.3.180:27017/test { "user" : "ceilometerdbadmin", "pwd" : "693449936c0cdcf9d0da2d3c2246122d", "roles" : [ "readWrite", "dbAdmin" ], "_id" : ObjectId("55419f02f1437115033e6bb6") }
[database] # The SQLAlchemy connection string used to connect to the # database (string value) connection = mongodb://ceilometerdbadmin:[email protected]:27017/ceilometer
sm@controller:~$ sudo openssl rand -hex 10 80f7bb8ca173a3fd8fab
[publisher] # Secret value for signing metering messages (string value) metering_secret = 80f7bb8ca173a3fd8fab
[DEFAULT] rpc_backend = ceilometer.openstack.common.rpc.impl_kombu rabbit_host = 192.168.3.180 rabbit_port = 5672 rabbit_userid = guest rabbit_password = mq4smtest
[DEFAULT] log_dir = /var/log/ceilometer
sm@controller:~$ keystone user-create --name=ceilometer --pass=ceilometer4smtest [email protected] +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | [email protected] | | enabled | True | | id | 4fd9cbdca36f414590adf65cfe343743 | | name | ceilometer | | username | ceilometer | +----------+----------------------------------+
[DEFAULT] auth_strategy = keystone [keystone_authtoken] auth_uri = http://192.168.3.180:5000 auth_host = 192.168.3.180 auth_port = 35357 auth_protocol = http admin_tenant_name = service admin_user = ceilometer admin_password = ceilometer4smtest
[service_credentials] os_auth_url = http://192.168.3.180:5000/v2.0 os_username = ceilometer os_tenant_name = service os_password = ceilometer4smtest
sm@controller:~$ keystone service-create --name=ceilometer --type=metering \ > --description="Telemetry" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | Telemetry | | enabled | True | | id | 8add6525e59c4c4cb62b04065dd0f353 | | name | ceilometer | | type | metering | +-------------+----------------------------------+
sm@controller:~$ keystone endpoint-create \ > --service-id=$(keystone service-list | awk '/ metering / {print $2}') \ > --publicurl=http://192.168.3.180:8777 \ > --internalurl=http://192.168.3.180:8777 \ > --adminurl=http://192.168.3.180:8777 +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | adminurl | http://192.168.3.180:8777 | | id | 31f58a6be962408bbd280cf2b5dd747c | | internalurl | http://192.168.3.180:8777 | | publicurl | http://192.168.3.180:8777 | | region | regionOne | | service_id | 8add6525e59c4c4cb62b04065dd0f353 | +-------------+----------------------------------+
[DEFAULT] instance_usage_audit = True instance_usage_audit_period = hour notify_on_state_change = vm_and_task_state notification_driver = nova.openstack.common.notifier.rpc_notifier notification_driver = ceilometer.compute.nova_notifier
如果控制节点和计算节点是一台物理机,该Key无需再生成,如果不是,在计算节点需要重新生成)
sudo openssl rand -hex 10
sm@controller:~$ sudo openssl rand -hex 10 80f7bb8ca173a3fd8fabsudo vi /etc/ceilometer/ceilometer.conf
[publisher] # Secret value for signing metering messages (string value) metering_secret = 80f7bb8ca173a3fd8fab
[DEFAULT] rpc_backend = ceilometer.openstack.common.rpc.impl_kombu rabbit_host = 192.168.3.180 rabbit_port = 5672 rabbit_userid = guest rabbit_password = mq4smtest
[DEFAULT] auth_strategy = keystone [keystone_authtoken] auth_uri = http://192.168.3.180:5000 auth_host = 192.168.3.180 auth_port = 35357 auth_protocol = http admin_tenant_name = service admin_user = ceilometer admin_password = ceilometer4smtest
[service_credentials] os_auth_url = http://192.168.3.180:5000/v2.0 os_username = ceilometer os_tenant_name = service os_password = ceilometer4smtest
[DEFAULT] log_dir = /var/log/ceilometer
[DEFAULT] notification_driver = messaging rpc_backend = rabbit rabbit_host = 192.168.3.180 rabbit_password = mq4smtest
[DEFAULT] control_exchange = cinder notification_driver = cinder.openstack.common.notifier.rpc_notifier
sm@controller:~$ ceilometer meter-list +--------------------------+------------+-----------+-------------------------------------- +----------------------------------+----------------------------------+ | Name | Type | Unit | Resource ID | User ID | Project ID | +--------------------------+------------+-----------+-------------------------------------- +----------------------------------+----------------------------------+ | cpu | cumulative | ns | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | cpu_util | gauge | % | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.read.bytes | cumulative | B | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.read.bytes.rate | gauge | B/s | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.read.requests | cumulative | request | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.read.requests.rate | gauge | request/s | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.write.bytes | cumulative | B | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.write.bytes.rate | gauge | B/s | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.write.requests | cumulative | request | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | disk.write.requests.rate | gauge | request/s | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | image | gauge | image | f2b0f15b-bd5e-4766-973c-24547c1faf03 | None | b500268a41e34752aba847c7ea464870 | | image.size | gauge | B | f2b0f15b-bd5e-4766-973c-24547c1faf03 | None | b500268a41e34752aba847c7ea464870 | | instance | gauge | instance | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | | instance:m1.tiny | gauge | instance | 8f546f0e-4365-4e0e-b1c5-a6a3ec22ef6d | 9b1cdfc2b5614eb39f042317f54a286c | b500268a41e34752aba847c7ea464870 | +--------------------------+------------+-----------+-------------------------------------- +----------------------------------+----------------------------------+
我们可以看到,管理员项,新增了一个资源使用情况,里面包括日报和统计数据
统计数据