本處主要講述Gnocchi 的安裝及配置,其它Module的安裝能夠參考 http://docs.openstack.org/mitaka/install-guide-rdo/html
部署環境mysql
系統版本: CentOS7 sql
Openstack版本: Mitaka數據庫
1.建立Gnocchi的數據庫vim
1 CREATE DATABASE gnocchi; 2 GRANT ALL PRIVILEGES ON gnocchi.* TO '$USERNAME'@'localhost' IDENTIFIED BY '$PASSOWRD'; 3 GRANT ALL PRIVILEGES ON gnocchi.* TO '$USERNAME'@'%' IDENTIFIED BY '$PASSOWRD';
2.控制節點安裝Gnocchi後端
1 sudo yum install openstack-gnocchi-api openstack-gnocchi-metricd openstack-gnocchi-statsd
3.建立Username及Serviceapi
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. 配置Gnocchidom
1 vim /etc/gnocchi/gnocchi.conf 2 3 [database] 4 backend = sqlalchemy #配置存儲index的數據庫類型 5 6 7 [indexer] 8 url = mysql+pymysql://$USERNAME:$PASSWORD@$CONTROLLER_ip/gnocchi 9 10 11 [keystone_authtoken] #配置gnocchi服務的權限信息 12 auth_uri = http://$CONTROLLER_IP:5000/v3 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 37 38 #建立gnocchi服務須要的目錄 39 mkdir /var/cache/gnocchi && chown gnocchi:gnocchi -R /var/cache/gnocchi 40 mkdir /var/lib/gnocchi && chown gnocchi:gnocchi -R /var/lib/gnocchi
5.初始化Gnocchi 服務的數據庫ide
1 gnocchi-upgrade
6.啓動Gnocchi服務ui
1 systemctl enable openstack-gnocchi-api.service openstack-gnocchi-metricd.service openstack-gnocchi-statsd.service 2 3 systemctl start openstack-gnocchi-api.service openstack-gnocchi-metricd.service openstack-gnocchi-statsd.service 4 #Mitaka版本初始化數據庫時,並建立默認的archive-policy https://review.openstack.org/#/c/290626/ 5 gnocchi archive-policy create -d granularity:5m,points:12 -d granularity:1h,points:24 -d granularity:1d,points:30 low 6 gnocchi archive-policy create -d granularity:60s,points:60 -d granularity:1h,points:168 -d granularity:1d,points:365 medium 7 gnocchi archive-policy create -d granularity:1s,points:86400 -d granularity:1m,points:43200 -d granularity:1h,points:8760 high 8 gnocchi archive-policy-rule create -a low -m "*" default
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 11 filter_service_activity = True 12 url = http://$CONTROLLER_IP:8041
8.重啓Ceilometer服務
1 systemctl restart openstack-ceilometer-api.service openstack-ceilometer-collector.service 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