部署环境
系统版本: CentOS7
Openstack版本: Mitaka
1.创建Gnocchi的数据库
1 CREATE DATABASE gnocchi; 2 GRANT ALL PRIVILEGES ON glance.* TO ‘$USERNAME‘@‘localhost‘ IDENTIFIED BY ‘$PASSOWRD‘; 3 GRANT ALL PRIVILEGES ON glance.* TO ‘$USERNAME‘@‘%‘ IDENTIFIED BY ‘$PASSOWRD‘;
2.控制节点安装Gnocchi
1 sudo yum install openstack-gnocchi-api openstack-gnocchi-carbonara openstack-gnocchi-common 2 openstack-gnocchi-doc openstack-gnocchi-indexer-sqlalchemy openstack-gnocchi-metricd 3 openstack-gnocchi-statsd
3.创建Username及Service
1 openstack user create --domain default --password-prompt gnocchi 2 openstack role add --project service --user gnocchi admin 3 4 openstack service create --name gnocchi --description "OpenStack Metric" metric 5 openstack endpoint create --region RegionOne metric public http://$CONTROLLER_IP:8041 6 openstack endpoint create --region RegionOne metric admin http://$CONTROLLER_IP:8041 7 openstack endpoint create --region RegionOne metric internal http://$CONTROLLER_IP:8041
4. 配置Gnocchi
1 vim /etc/gnocchi/gnocchi.conf 2 3 [database] 4 backend = sqlalchemy #配置存储index的数据库类型 5 6 7 [indexer] 8 url = mysql+pymysql://$USERNAME:[email protected]$CONTROLLER_ip/Gnocchi 9 10 11 [keystone_authtoken] #配置gnocchi服务的权限信息 12 auth_uri = http://$CONTROLLER_IP:5000/v2.0 13 identity_uri = http://$CONTROLLER_IP:35357/ 14 admin_user = $USERNAME 15 admin_password = $PASSWORD 16 admin_tenant_name = service 17 signing_dir = /var/cache/gnocchi 18 19 20 [statsd] #配置gnocchi服务的标识信息(忽略Gnocchi的采样数据),Gnocchi服务相关的信息 21 resource_id = 22 user_id = 23 project_id = 24 archive_policy_name = low 25 26 27 [storage] #配置storage的后端driver,默认是file 28 coordination_url = file:///var/lib/gnocchi/locks 29 driver = file 30 file_basepath = /var/lib/gnocchi 31 32 --------------------------------------------------------------------------------------------------- 33 vim /etc/gnocchi/api-paste.ini 34 35 [pipeline:main] #鉴权请求,否则无法执行policy.conf指定admin的操作 36 pipeline = gnocchi+auth
5.初始化Gnocchi 服务的数据库 (Mitaka版本初始化数据库时,并创建默认的archive-policy https://review.openstack.org/#/c/290626/ )
1 gnocchi-upgrade 2 gnocchi archive-policy create -d granularity:5m,points:12 -d granularity:1h,points:24 -d granularity:1d,points:30 low 3 gnocchi archive-policy create -d granularity:60s,points:60 -d granularity:1h,points:168 -d granularity:1d,points:365 medium 4 gnocchi archive-policy create -d granularity:1s,points:86400 -d granularity:1m,points:43200 -d granularity:1h,points:8760 high 5 gnocchi archive-policy-rule create -a low -m "*" default
6.启动Gnocchi服务
1 systemctl enable openstack-gnocchi-api.service 2 systemctl enable openstack-gnocchi-metricd.service 3 systemctl enable openstack-gnocchi-statsd.service 4 5 systemctl start openstack-gnocchi-api.service 6 systemctl start openstack-gnocchi-metricd.service 7 systemctl start openstack-gnocchi-statsd.service
7.修改Ceilometer配置文件
1 vim /etc/ceilometer/ceilometer.conf 2 3 [DEFAULT] 4 meter_dispatchers = gnocchi 5 6 [api] 7 gnocchi_is_enabled = true 8 9 [dispatcher_gnocchi] 10 filter_project = service #忽略service project的监控item 11 filter_service_activity = True 12 url = http://$CONTROLLER_IP:8041
8.重启Ceilometer服务
1 systemctl restart openstack-ceilometer-api.service 2 systemctl restart openstack-ceilometer-collector.service 3 systemctl restart openstack-ceilometer-notification.service
9.示例
创建Ceilometer告警
1 gnocchi metric list 2 gnocchi resource list 3 4 5 ceilometer alarm-gnocchi-resources-threshold-create --name gnocchi_test_network --description ‘storage.objects.containers‘ --alarm-action ‘log://‘ --evaluation-periods 2 6 --aggregation-method max --comparison-operator gt --threshold 5871354.0 -m network.incoming.bytes --resource-type instance_network_interface 7 --resource-id addbb3ba-5b1e-543f-ba8a-1010e5d36dbc --repeat-actions true
10.参考文档
http://www.cnblogs.com/knitmesh/p/5464709.html
https://www.ustack.com/blog/telemetry/
http://docs.openstack.org/developer/gnocchi/rest.html#archive-policy
https://julien.danjou.info/blog/2014/openstack-ceilometer-the-gnocchi-experiment
时间: 2024-10-10 06:11:06