OpenStack Ceilometer
像昨天的heat的宗旨一樣,當服務一大管理服務的服務就由然而生,在此大家會想說從外部觀看nova資源不就好了為甚麼要這樣的服務,但有沒有想過VM中到底使用多少的資源量?如果一個服務整天空閒或整天繁忙,就要適時的調整資源狀況,所以實戰起來通常還會一併使用Heat這樣的編配服務。
1.安裝資料庫
他比較獨特的點是說他不是使用MongoDB而是使用NoSQL的服務
因而我們要為了他用一個NoSQL
2.建立資料庫
sudo mongo --host controller --eval '
db = db.getSiblingDB("ceilometer");
db.addUser({user: "ceilometer",
pwd: "CEILOMETER資料庫密碼",
roles: [ "readWrite", "dbAdmin" ]})'
MongoDB shell version: 2.4.x
connecting to: controller:27017/test
{
"user" : "ceilometer",
"pwd" : "72f25aeee7ad4be52437d7cd3fc60f6f",
"roles" : [
"readWrite",
"dbAdmin"
],
"_id" : ObjectId("5489c22270d7fad1ba631dc3")
}
§如果上面失敗的話
sudo vim /etc/mongodb.conf
# auth ...
3.重啟服務
sudo systemctl restart mongodb
1.登入admin管理員指令模式
2.建立使用者
openstack user create --domain default --password-prompt ceilometer
3.將使用者加入服務群組
openstack role add --project service --user ceilometer admin
4.建立服務
openstack service create --name ceilometer --description "Telemetry" metering
5.建立API
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
1.安裝套件
sudo zypper install openstack-ceilometer-api openstack-ceilometer-collector \
openstack-ceilometer-agent-notification openstack-ceilometer-agent-central
python-ceilometerclient -y
2.編輯設定檔
sudo vim /etc/ceilometer/ceilometer.conf
[DEFAULT]
#訊息模式
rpc_backend = rabbit
#驗證模式
auth_strategy = keystone
[database]
connection = mongodb://ceilometer:CEILOMETER資料庫密碼@controller:27017/ceilometer
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = AMQP密碼
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = CEILOMETER密碼
[service_credentials]
auth_type = password
auth_url = http://controller:5000/v3
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = CEILOMETER密碼
interface = internalURL
region_name = RegionOne
#設定管理員儲存方式
[collector]
dispatcher = database
3.設定Apache
sudo vim /etc/apache2/conf.d/wsgi-ceilometer.conf
Listen 8777
<VirtualHost *:8777>
WSGIDaemonProcess ceilometer-api processes=2 threads=10 user=ceilometer group=ceilometer display-name=%{GROUP}
WSGIProcessGroup ceilometer-api
WSGIScriptAlias / "/var/www/cgi-bin/ceilometer/app"
WSGIApplicationGroup %{GLOBAL}
ErrorLog /var/log/apache2/ceilometer_error.log
CustomLog /var/log/apache2/ceilometer_access.log combined
</VirtualHost>
WSGISocketPrefix /var/run/apache2
4.重新讀取Apache
sudo systemctl reload apache2.service
5.重啟服務
sudo systemctl enable openstack-ceilometer-agent-notification.service \
openstack-ceilometer-agent-central.service openstack-ceilometer-collector.service
sudo systemctl start openstack-ceilometer-agent-notification.service \
openstack-ceilometer-agent-central.service openstack-ceilometer-collector.service
1.編輯設定檔(確認以下內容)
sudo vim /etc/glance/glance-api.conf
sudo vim /etc/glance/glance-registry.conf
[DEFAULT]
rpc_backend = rabbit
[oslo_messaging_notifications]
driver = messagingv2
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = AMQP密碼
2.重啟服務
sudo service glance-registry restart
sudo service glance-api restart
在計算節點上安裝
1.安裝套件
sudo apt-get install ceilometer-agent-compute -y
2.編輯設定檔
確認以下內容(需要修改兩個檔案喔)
sudo vim /etc/ceilometer/ceilometer.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = AMQP密碼
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = CEILOMETER密碼
[service_credentials]
auth_url = http://controller:5000
project_domain_id = default
user_domain_id = default
auth_type = password
username = ceilometer
project_name = service
password = CEILOMETER密碼
interface = internalURL
region_name = RegionOne
sudo vim /etc/nova/nova.conf
[DEFAULT]
instance_usage_audit = True
instance_usage_audit_period = hour
notify_on_state_change = vm_and_task_state
[oslo_messaging_notifications]
driver = messagingv2
3.重啟服務
sudo service ceilometer-agent-compute restart
sudo service nova-compute restart
1.編輯設定檔
控制和儲存節點都要編輯
sudo vim /etc/cinder/cinder.conf
[oslo_messaging_notifications]
driver = messagingv2
2.重啟服務
sudo service cinder-api restart
sudo service cinder-scheduler restart
sudo service cinder-volume restart
只有控制節點需要做的
1.登入admin管理者指令模式
2.新增規則
openstack role create ResellerAdmin
3.將使用者加進服務中
openstack role add --project service --user ceilometer ResellerAdmin
控制及結點都要做
1.安裝套件
sudo apt-get install python-ceilometermiddleware -y
2.編輯設定檔(確認是否存在)
sudo vim /etc/swift/proxy-server.conf
[filter:keystoneauth]
operator_roles = admin, user, ResellerAdmin
[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
[filter:ceilometer]
paste.filter_factory = ceilometermiddleware.swift:filter_factory
control_exchange = swift
url = rabbit://openstack:AMQP密碼@controller:5672/
driver = messagingv2
topic = notifications
log_level = WARN
3.重啟服務
sudo service swift-proxy restart
1.登入admin管理者指令模式
2.列出列表
ceilometer meter-list
3.下載映像檔
IMAGE_ID=$(glance image-list | grep 'cirros' | awk '{ print $2 }')
glance image-download $IMAGE_ID > /tmp/cirros.img
4.列出列表
ceilometer meter-list
5.檢視使用量
ceilometer statistics -m image.download -p 60
6.刪除測試檔
rm /tmp/cirros.img
今天的內容好多ㄚㄚㄚ
東西要做大服務就要做的更大
今天的安裝步驟其實很麻煩
但希望大家可以好好應用這樣的服務喔喔!
希望大家可以在這一個月中讀到非常多的應用技巧,那如果有問題可以以私訊我的方式是使用問題回復,我會盡可能地回答問題,那會在後面統一做回覆,或者如果有想知道的相關的應用也可以提出討論喔。