云计算基础设施平台iaas(openstack)超级详细搭建(十五)安装Ceilometer服务

李永寿
2023-12-01

注意:接与上一篇博客内容 进行更新
由于整个开源openstack安装过程过于繁琐,命令太长,太繁琐,于是把整个安装命令写成shell脚本。

脚本数量内容过多,已经推送自我的github源码托管中心了。
这是本篇脚本内容所在的github仓库位置
controller节点
compute节点

脚本内容介绍

controller节点

#!/bin/bash
source /etc/xiandian/openrc.sh
source /etc/keystone/admin-openrc.sh

mongo $HOST_NAME/ceilometer --eval "db.addUser({user: 'ceilometer', pwd: '$CEILOMETER_DBPASS', roles: [ 'readWrite', 'dbAdmin' ]})"
while [ $? -ne 0 ]
do
sleep 10
mongo $HOST_NAME/ceilometer --eval "db.addUser({user: 'ceilometer', pwd: '$CEILOMETER_DBPASS', roles: [ 'readWrite', 'dbAdmin' ]})"
done

openstack user create --domain $DOMAIN_NAME --password $CEILOMETER_PASS ceilometer
openstack role add --project service --user ceilometer admin
openstack service create --name ceilometer --description "Telemetry" metering
openstack endpoint create --region RegionOne metering public http://$HOST_NAME:8777
openstack endpoint create --region RegionOne metering internal http://$HOST_NAME:8777
openstack endpoint create --region RegionOne metering admin http://$HOST_NAME:8777

openstack role create ResellerAdmin
openstack role add --project service --user ceilometer ResellerAdmin

yum install -y openstack-ceilometer-api openstack-ceilometer-collector openstack-ceilometer-notification openstack-ceilometer-central p
ython-ceilometerclient python-ceilometermiddleware

crudini --set /etc/ceilometer/ceilometer.conf database connection  mongodb://ceilometer:$CEILOMETER_DBPASS@$HOST_NAME:27017/ceilometer
crudini --set /etc/ceilometer/ceilometer.conf DEFAULT rpc_backend rabbit
crudini --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_host $HOST_NAME
crudini --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_userid $RABBIT_USER
crudini --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_password  $RABBIT_PASS

crudini --set /etc/ceilometer/ceilometer.conf DEFAULT auth_strategy keystone
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_uri  http://$HOST_NAME:5000
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_url  http://$HOST_NAME:35357
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken memcached_servers  $HOST_NAME:11211
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_type  password
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_domain_name  $DOMAIN_NAME
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken user_domain_name $DOMAIN_NAME
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_name  service

compute节点

#!/bin/bash
source /etc/xiandian/openrc.sh
yum install openstack-ceilometer-compute python-ceilometerclient python-pecan -y

crudini --set /etc/ceilometer/ceilometer.conf DEFAULT rpc_backend rabbit
crudini --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_host $HOST_NAME
crudini --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_userid $RABBIT_USER
crudini --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_password  $RABBIT_PASS

crudini --set /etc/ceilometer/ceilometer.conf DEFAULT auth_strategy keystone
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_uri  http://$HOST_NAME:5000
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_url  http://$HOST_NAME:35357
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken memcached_servers  $HOST_NAME:11211
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_type  password
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_domain_name  $DOMAIN_NAME
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken user_domain_name $DOMAIN_NAME
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_name  service
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken username  ceilometer
crudini --set /etc/ceilometer/ceilometer.conf keystone_authtoken password  $CEILOMETER_PASS

crudini --set /etc/ceilometer/ceilometer.conf service_credentials auth_type  password
crudini --set /etc/ceilometer/ceilometer.conf service_credentials auth_url  http://$HOST_NAME:5000/v3
crudini --set /etc/ceilometer/ceilometer.conf service_credentials project_domain_name  $DOMAIN_NAME
crudini --set /etc/ceilometer/ceilometer.conf service_credentials user_domain_name  $DOMAIN_NAME
crudini --set /etc/ceilometer/ceilometer.conf service_credentials project_name  service
crudini --set /etc/ceilometer/ceilometer.conf service_credentials username  ceilometer
crudini --set /etc/ceilometer/ceilometer.conf service_credentials password  $CEILOMETER_PASS
crudini --set /etc/ceilometer/ceilometer.conf service_credentials interface  internalURL
crudini --set /etc/ceilometer/ceilometer.conf service_credentials region_name  RegionOne

crudini --set /etc/nova/nova.conf DEFAULT instance_usage_audit  True
crudini --set /etc/nova/nova.conf DEFAULT instance_usage_audit_period  hour
crudini --set /etc/nova/nova.conf DEFAULT notify_on_state_change  vm_and_task_state
crudini --set /etc/nova/nova.conf DEFAULT notification_driver  messagingv2

systemctl enable openstack-ceilometer-compute.service
systemctl restart openstack-ceilometer-compute.service
systemctl restart openstack-nova-compute.service

下面是本篇内容的命令的详细操作过程(脚本中已经包含该篇命令的所有操作,但是建议还是熟悉下整个过程之后再运行脚本)

11 安装Ceilometer监控服务

11.1通过脚本安装Ceilometer服务

11.2-11.10ceilometer监控服务的操作命令已经编写成shell脚本,通过脚本进行一键安装。如下:
#Controller节点
执行脚本iaas-install-ceilometer-controller.sh进行安装
#Compute节点
执行脚本iaas-install-ceilometer-compute.sh进行安装

11.2 安装Ceilometer监控服务软件包

# yum install -y openstack-ceilometer-api openstack-ceilometer-collector openstack-ceilometer-notification openstack-ceilometer-central python-ceilometerclient python-ceilometermiddleware

11.3 创建数据库

数据库启动之后需要等待几秒后开始创建,否则会出现报错。
# mongo --host controller --eval ' db = db.getSiblingDB("ceilometer"); db.addUser({user: "ceilometer", pwd: "000000", roles: [ "readWrite", "dbAdmin" ]})'

11.4 创建用户

# openstack user create --domain default --password 000000 ceilometer
# openstack role add --project service --user ceilometer admin
# openstack role create ResellerAdmin
# openstack role add --project service --user ceilometer ResellerAdmin

11.5 创建Endpoint和API端点

# openstack service create --name ceilometer --description "Telemetry" metering
# openstack endpoint create --region RegionOne metering public http://controller:8777
# openstack endpoint create --region RegionOne metering internal http://controller:8777
# openstack endpoint create --region RegionOne metering admin http://controller:8777

11.6 配置Ceilometer

# openstack-config --set /etc/ceilometer/ceilometer.conf database connection  mongodb://ceilometer:000000@controller:27017/ceilometer
# openstack-config --set /etc/ceilometer/ceilometer.conf DEFAULT rpc_backend rabbit
# openstack-config --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_host controller
# openstack-config --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_userid openstack
# openstack-config --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_password  000000

# openstack-config --set /etc/ceilometer/ceilometer.conf DEFAULT auth_strategy keystone
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_uri  http://controller:5000
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_url  http://controller:35357
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken memcached_servers  controller:11211
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_type  password
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_domain_name  default
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken user_domain_name default
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_name  service
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken username  ceilometer
# openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken password  000000

# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials auth_type  password
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials auth_url  http://controller:5000/v3
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials project_domain_name  default
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials user_domain_name  default
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials project_name  service
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials username  ceilometer
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials password  000000
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials interface  internalURL
# openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials region_name  RegionOne

11.7 启动服务

systemctl enable openstack-ceilometer-api.service openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service
systemctl restart openstack-ceilometer-api.service openstack-ceilometer-notification.service openstack-ceilometer-central.service openstack-ceilometer-collector.service

11.8 监控组件

openstack-config --set /etc/glance/glance-api.conf  DEFAULT rpc_backend rabbit
openstack-config --set /etc/glance/glance-api.conf  oslo_messaging_rabbit rabbit_host controller
openstack-config --set /etc/glance/glance-api.conf  oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/glance/glance-api.conf  oslo_messaging_rabbit rabbit_password  000000
openstack-config --set /etc/glance/glance-api.conf  oslo_messaging_notifications driver  messagingv2
openstack-config --set /etc/glance/glance-registry.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_host controller
openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_rabbit rabbit_password  000000
openstack-config --set /etc/glance/glance-registry.conf oslo_messaging_notifications driver  messagingv2
systemctl restart openstack-glance-api.service openstack-glance-registry.service
openstack-config --set  /etc/cinder/cinder.conf oslo_messaging_notifications driver  messagingv2
systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
openstack-config --set /etc/swift/proxy-server.conf  filter:keystoneauth operator_roles "admin, user, ResellerAdmin"
openstack-config --set /etc/swift/proxy-server.conf pipeline:main pipeline "ceilometer catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server"
openstack-config --set /etc/swift/proxy-server.conf filter:ceilometer paste.filter_factory ceilometermiddleware.swift:filter_factory
openstack-config --set /etc/swift/proxy-server.conf filter:ceilometer url  rabbit://openstack:000000@controller:5672/
openstack-config --set /etc/swift/proxy-server.conf filter:ceilometer driver  messagingv2
openstack-config --set /etc/swift/proxy-server.conf filter:ceilometer topic  notifications
openstack-config --set /etc/swift/proxy-server.conf filter:ceilometer log_level  WARN
systemctl restart openstack-swift-proxy.service

#compute 节点

11.9 安装软件包

yum install openstack-ceilometer-compute python-ceilometerclient python-pecan –y

11.10 配置Ceilometer

openstack-config --set /etc/ceilometer/ceilometer.conf DEFAULT rpc_backend rabbit
openstack-config --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_host controller
openstack-config --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/ceilometer/ceilometer.conf oslo_messaging_rabbit rabbit_password  000000

openstack-config --set /etc/ceilometer/ceilometer.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_uri  http://controller:5000
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_url  http://controller:35357
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken memcached_servers  controller:11211
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken auth_type  password
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_domain_name  default
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken project_name  service
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken username  ceilometer
openstack-config --set /etc/ceilometer/ceilometer.conf keystone_authtoken password  000000

openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials auth_type  password
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials auth_url  http://controller:5000/v3
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials project_domain_name  default
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials user_domain_name  default
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials project_name  service
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials username  ceilometer
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials password  000000
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials interface  internalURL
openstack-config --set /etc/ceilometer/ceilometer.conf service_credentials region_name  RegionOne

openstack-config --set /etc/nova/nova.conf DEFAULT instance_usage_audit  True
openstack-config --set /etc/nova/nova.conf DEFAULT instance_usage_audit_period  hour
openstack-config --set /etc/nova/nova.conf DEFAULT notify_on_state_change  vm_and_task_state
openstack-config --set /etc/nova/nova.conf DEFAULT notification_driver  messagingv2

下一篇博客内容将会安装Alarm监控服务

 类似资料: