OpenStack Cinder服務(wù)狀態(tài)排錯
本文轉(zhuǎn)載自微信公眾號「新鈦云服」,作者舒祝 。轉(zhuǎn)載本文請聯(lián)系新鈦云服公眾號。
最近手動搭建了一個openstack環(huán)境,創(chuàng)建硬盤時失敗,查看日志,提示無法進行調(diào)度,懷疑是cinder節(jié)點出現(xiàn)問題,去cinder節(jié)點查看服務(wù) ,狀態(tài)顯示正常。
- systemctl status openstack-cinder-volume.service
然后在控制節(jié)點查看cinder服務(wù),openstack volume service list
正常情況下顯示:
結(jié)果顯示cinder-volume的state為down,查看日志發(fā)現(xiàn)沒有任何錯誤信息,重啟cinder的各種服務(wù)仍然沒有效果,最后決定跟蹤源碼(說明:文中代碼對應(yīng)的是OpenStack Train版)。
找到openstack volume service list對應(yīng)的實現(xiàn)代碼。
- now = timeutils.utcnow(with_timezone=True)
由于openstack-cinder-api.servic服務(wù)在controller節(jié)點啟動,所以獲取的是controller節(jié)點的當(dāng)前時間。
services = objects.ServiceList.get_all(context, filters)最終會從cinder數(shù)據(jù)庫的services表中獲取所有服務(wù)數(shù)據(jù)。
alive = abs(delta_sec) <= CONF.service_down_time,比較時間差的絕對值是否小于配置的service_down_time,其中service_down_time默認(rèn)時間是60s。
- cfg.IntOpt('service_down_time',
- default=60,
- help='Maximum time since last check-in for a service to be '
- 'considered up'),
art = "up" if alive else "down" 差值小于60,則service 狀態(tài)為 up,否則為down。由此可見cinder service的state值取決于cinder數(shù)據(jù)庫中 service 表每行數(shù)據(jù)的 updated_at 列的值和當(dāng)前 controller 節(jié)點的時間差是否在配置的范圍之內(nèi)。
解決問題
上面cinder-volume出現(xiàn)down的原因就是因為運行openstack-cinder-volume.service服務(wù)的存儲節(jié)點時間與controller節(jié)點時間差值過大。為了保證狀態(tài)為up,必須保證兩節(jié)點的時間差在service_down_time - report_interval之內(nèi),默認(rèn)情況下,差值為50秒。所以同步兩臺服務(wù)器時間之后,再次查看,發(fā)現(xiàn)cinder-volume的state變?yōu)閡p。
cinder服務(wù)更新機制
下面說下 Cinder Service 的更新機制。
report_interval默認(rèn)時間是10s,
- cfg.IntOpt('report_interval',
- default=10,
- help='Interval, in seconds, between nodes reporting state '
- 'to datastore'),
























