openstack常見錯誤總結

以下主要爲安裝部署過程中遇到的一些問題,因爲openstack版本問題,帶來的組件差異導致不同的版本安裝的方法也完全不一樣。經過測試,目前已可成功部署Essex和Grizzly兩個版本,其中間還有個版本是Folsom,這個版本沒有部署成功,也沒有花太多時間去研究,因爲Folsom版本中使用的quantum組件還不成熟,對於網絡連通性還有很多問題,網上也很少有成功的案例,大多數人使用的還是folsom+nova-network模式。

到了Grizzly版本,quantum組件才比較穩定,可以正常使用,自己也花了很多時間研究,現在已可以成功部署多節點環境。以下是部署過程中遇到的一些問題,包括Essex和Grizzly兩個版本。國內網上關於這方面的資料很少,很多資料也都是國外網站上看到的。而且很多情況下日誌錯誤信息相同,但導致錯誤的原因卻不盡相同,這時候就需要仔細分析其中的原理,才能準確定位。遇到錯誤並不可怕,我們可以通過對錯誤的排查加深對系統的理解,這樣也是好事。

關於安裝部署,網上有一些自動化的部署工具,如devstack和onestack,一鍵式部署。如果你是初學者,並不建議你使用這些工具,很明顯,這樣你學不到任何東西,不會有任何收穫。如果沒有問題可以暫時恭喜你一下,一旦中間環節出現錯誤信息,你可能一頭霧水,根本不知道是哪裏錯了,加之後期的維護也是相當困難的。你可能需要花更多的時間去排查故障。因爲你根本不瞭解中間經過了哪些環節,需要做哪些配置!這些工具大多數是爲了快速部署開發環境所用,正真生產環境還需要我們一步一步來操作。這樣有問題也可快速定位排查錯誤。

本文僅是針對部署過程中的一些錯誤信息進行總結梳理,並給予解決辦法,這些情況是在我的環境裏遇到的,併成功解決的,可能會因爲環境的不同而有所差異,僅供參考。

1、檢查服務是否正常:

  1. root@control:~# nova-manage service list  

  1. Binary           Host                                 Zone             Status     State Updated_At  

  1. nova-cert        control                              internal         enabled    :-)   2013-04-26 02:29:44  

  2. nova-conductor   control                             internal         enabled    :-)   2013-04-26 02:29:42  

  3. nova-consoleauth control                              internal         enabled    :-)   2013-04-26 02:29:44  

  4. nova-scheduler   control                              internal         enabled    :-)   2013-04-26 02:29:47  

  5. nova-compute     node-01                              nova             enabled    :-)   2013-04-26 02:29:46  

  6. nova-compute     node-02                              nova             enabled    :-)   2013-04-26 02:29:46  

  7. nova-compute     node-03                              nova             enabled    :-)   2013-04-26 02:29:42  


如果看到都是笑臉狀態,說明nova的服務屬於正常狀態,如果出現XXX,請查看該服務的相關日誌信息,在/var/log/nova/下查看,通過日誌一般可以分析出錯誤的原因。

2、libvirt錯誤

  1. python2.7/dist-packages/nova/virt/libvirt/connection.py”, line 338, in _connect  

  2. 2013-03-0917:05:42 TRACE nova return libvirt.openAuth(uri, auth, 0)  

  3. 2013-03-09 17:05:42 TRACE nova File “/usr/lib/python2.7/dist-packages/libvirt.py”, line 102, in openAuth  

  4. 2013-03-09 17:05:42 TRACE nova if ret is None:raise libvirtError(‘virConnectOpenAuth() failed’)  

  5. 2013-03-09 17:05:42 TRACE nova libvirtError: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock’: No such file or directory  

  6. 2013-03-09 22:05:41.909+0000: 12466: info : libvirt version: 0.9.8  

  7. 2013-03-09 22:05:41.909+0000: 12466: error : virNetServerMDNSStart:460 : internal error Failed to create mDNS client: Daemon not running  


解決方案:

出現這種錯誤首先要查看/var/log/libvirt/libvirtd.log日誌信息,日誌裏會顯示:libvirt-bin service will not start without dbus installed.

我們再查看ps –ea|grep dbus,確認dbus is running,然後執行apt-get install lxc

3、Failed to add p_w_picpath

  1. Error:  

  2. Failed to add p_w_picpath. Got error:
The request returned 500 Internal Server Error  


解決方案:

環境變量問題,配置環境變量,在/etc/profile文件中新增:

  1. OS_AUTH_KEY=”openstack”  

  2. OS_AUTH_URL=”http://localhost:5000/v2.0/”  

  3. OS_PASSWORD=”openstack”  

  4. OS_TENANT_NAME=”admin”  

  5. OS_USERNAME=”admin”  


然後執行source  /etc/profile即可!當然你也可以不在profile裏配置環境變量,但是隻能臨時生效,重啓服務器就很麻煩,所以建議你還是寫在profile裏,這樣會省很多麻煩。

4、殭屍實例的產生

殭屍實例一般是非法的關閉nova或者底層虛擬機,又或者在實例錯誤時刪除不了的錯誤,注意用virsh list檢查底層虛擬機是否還在運行,有的話停掉,然後直接進入數據庫刪除。

  1. Nova instance not found  

  2. Local file storage of the p_w_picpath files.  

  3. Error:  

  4. 2013-03-09 17:58:08 TRACE nova raise exception.InstanceNotFound(instance_id=instance_name)  

  5. 2013-03-09 17:58:08 TRACE nova InstanceNotFound: Instance instance-00000002 could not be found.  

  6. 2013-03-09 17:58:08 TRACE nova  

解決方案:

刪除數據庫中的殭屍實例或將數據庫刪除重新創建:

a、刪除數據庫:

  1. $mysql –u root –p  

  2. DROP DATABASE nova;  

  3. Recreate the DB:  

  4. CREATE DATABASE nova; (strip formatting if you copy and paste any of this)  

  5. GRANT ALL PRIVILEGES ON nova.* TO ‘novadbadmin’@'%’ IDENTIFIED BY ‘<password>’;  

  6. Quit  


  7. Resync DB  


b、刪除數據庫中的實例:

  1. #!/bin/bash  

  2. mysql -uroot -pmysql <<_ESXU_

  3. use nova;  

  4. DELETE a FROM nova.security_group_instance_association  

  5. AS a INNER JOIN nova.instances AS b  

  6. ON a.instance_uuid=b.id where b.uuid='$1';  

  7. DELETE FROM nova.instance_info_caches WHERE instance_uuid='$1';  

  8. DELETE FROM nova.instances WHERE uuid='$1';  

  9. _ESXU_  


將以上文件寫入delete_insrance.sh中,然後執行sh delete_instrance.sh insrance_id;

其中instrance_id可以通過nova list 查看。

5、Keystone NoHandlers

  1. Error  

  2. root@openstack-dev-r910:/home/brent/openstack# ./keystone_data.sh  

  3. No handlers could be found for logger “keystoneclient.client”  

  4. Unable to authorize user  

  5. No handlers could be found for logger “keystoneclient.client”  

  6. Unable to authorize user  

  7. No handlers could be found for logger “keystoneclient.client”  

  8. Unable to authorize user  


解決方案:

出現這種錯誤是大多數是由於keystone_data.sh有誤,其中

admin_token必須與/etc/keystone/keystone.conf中相同。然後確認keystone.conf中有如下配置:

driver = keystone.catalog.backends.templated.TemplatedCatalog template_file = /etc/keystone/default_catalog.templates

6、清空系統組件,重新安裝:

  1. #!/bin/bash  

  2. mysql -uroot -popenstack -e “drop database nova;”  

  3. mysql -uroot -popenstack -e “drop database glance;”  

  4. mysql -uroot -popenstack -e “drop database keystone;”  

  5. apt-get purge nova-api nova-cert nova-common nova-compute  

  6. nova-compute-kvm nova-doc nova-network nova-objectstore  

  7. nova-scheduler nova-vncproxy nova-volume python-nova python-novaclient  

  8. apt-get autoremove  

  9. rm -rf /var/lib/glance  

  10. rm -rf /var/lib/keystone/  

  11. rm -rf /var/lib/nova/  

  12. rm -rf /var/lib/mysql  


可通過執行上面的腳本,卸載已安裝的組件並清空數據庫。這樣可以省去重裝系統的麻煩!

7、Access denied for user ‘keystone@localhost(using password:YES’)

  1. # keystone-manage db_sync  

  2. File “/usr/lib/python2.7/dist-packages/MySQLdb/connections.py”, line 187, in __init__  

  3. super(Connection, self).__init__(*args, **kwargs2)  

  4. sqlalchemy.exc.OperationalError: (OperationalError) (1045, “Access denied for user ‘keystone’@'openstack1′ (using password: YES)”) None None  


解決方案:

查看keystone.conf配置文件鏈接數據庫是否有誤,正確如下:

  1. [sql]  

  2. connection = mysql://keystone:openstack@localhost:3306/keystone  


8、nova-compute掛掉與時間同步的關係

很多時候發現nova-compute掛掉,或者不正常了,通過nova-manage查看狀態是XXX了。

往往是nova-compute的主機時間和controller的主機時間不一致。 nova-compute是定時地往數據庫中services這個表update時間的,這個時間是nova-compute的主機時間。

controller校驗nova-compute的存活性是以controller的時間減去nova-compute的update時間,如果大於多少秒(具體數值代碼裏面有,好像是15秒)就判斷nova-compute異常。

這個時候你用nova-manage查看nova-compute狀態是XXX,如果創建虛擬機,查看nova-scheduler.log 就是提示找不到有效的host 其他服務節點類同,這是nova心跳機制問題。所以講nova環境中各節點時間同步很重要。一定要確保時間同步!!

如果在dashboard上看nova-compute狀態,可能一會兒變紅,一會兒變綠。那就嚴格同步時間,或者找到代碼,把上面的那個15秒改大一點。

9、noVNC不能連接到實例

novnc的問題比較多,網上也有關於這方面的很多配置介紹,其實配置不復雜,只有四個參數,配置正確基本上沒什麼大問題,但是裝的過程中還是遇到了不少的問題。

a、提示“Connection Refuesd”

可能是控制節點在收到vnc請求的時候,無法解析計算節點的主機名,從而無法和計算節點上的實例建立連接。

另外可能是,當前瀏覽器不支持或者不能訪問,將計算節點的ip和主機名的對應關係加入到控制節點的/etc/hosts文件中。

b、提示“failed connect to server

出現這種錯誤的情況比較多,有可能是配置文件的錯誤,我們的環境中遇到這個錯誤是因爲網絡源有更新,導致安裝版本不一致,使組件無法正常使用,解決方法就是使用本地源。另外需要特別說明的是使用novnc的功能需要瀏覽器支持Web Socket和HTML5.推薦使用谷歌。

10、cinder錯誤,無法登錄dashboard.

出現如下錯誤:

  1. TypeError at /admin/  

  2. hasattr(): attribute name must be string  

  3. Request Method:   GET  

  4. Request URL: http://192.168.80.21/horizon/admin/  

  5. Django Version:   1.4.5  

  6. Exception Type:   TypeError  

  7. Exception Value:  

  8. hasattr(): attribute name must be string  

  9. Exception Location: /usr/lib/python2.7/dist-packages/cinderclient/client.py in __init__, line 78  

  10. Python Executable:   /usr/bin/python  

  11. Python Version:   2.7.3  

  12. Python Path:  

  13. ['/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../..',  

  14. '/usr/lib/python2.7',  

  15. '/usr/lib/python2.7/plat-linux2',  

  16. '/usr/lib/python2.7/lib-tk',  

  17. '/usr/lib/python2.7/lib-old',  

  18. '/usr/lib/python2.7/lib-dynload',  

  19. '/usr/local/lib/python2.7/dist-packages',  

  20. '/usr/lib/python2.7/dist-packages',  

  21. '/usr/share/openstack-dashboard/',  

  22. '/usr/share/openstack-dashboard/openstack_dashboard']  

  23. Server time: Fri, 29 Mar 2013 12:51:09 +0000  


解決方案

查看 apache2 的 error 日誌,報如下錯誤:

  1. ERROR:django.request:Internal Server Error: /horizon/admin/  

  2. Traceback (most recent call last):  

  3.  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response  

  4. response = callback(request, *callback_args, **callback_kwargs)  

  5.  File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 38, in dec  

  6.    return view_func(request, *args, **kwargs)  

  7.  File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 86, in dec  

  8.    return view_func(request, *args, **kwargs)  

  9.  File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 54, in dec  

  10.    return view_func(request, *args, **kwargs)  

  11.  File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 38, in dec  

  12.    return view_func(request, *args, **kwargs)  

  13.  File "/usr/lib/python2.7/dist-packages/horizon/decorators.py", line 86, in dec  

  14.    return view_func(request, *args, **kwargs)  

  15.  File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 48, in view  

  16.    return self.dispatch(request, *args, **kwargs)  

  17.  File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 69, in dispatch  

  18.    return handler(request, *args, **kwargs)  

  19.  File "/usr/lib/python2.7/dist-packages/horizon/tables/views.py", line 155, in get  

  20. handled = self.construct_tables()  

  21.  File "/usr/lib/python2.7/dist-packages/horizon/tables/views.py", line 146, in construct_tables  

  22. handled = self.handle_table(table)  

  23.  File "/usr/lib/python2.7/dist-packages/horizon/tables/views.py", line 118, in handle_table  

  24. data = self._get_data_dict()  

  25.  File "/usr/lib/python2.7/dist-packages/horizon/tables/views.py", line 182, in _get_data_dict  

  26. self._data = {self.table_class._meta.name: self.get_data()}  

  27.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/admin/overview/views.py", line 41, in get_data  

  28. data = super(GlobalOverview, self).get_data()  

  29.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/views.py", line 34, in get_data  

  30.    self.usage.get_quotas()  

  31.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/base.py", line 115, in get_quotas  

  32.    _("Unable to retrieve quota information."))  

  33.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/base.py", line 112, in get_quotas  

  34. self.quotas = quotas.tenant_quota_usages(self.request)  

  35.  File "/usr/lib/python2.7/dist-packages/horizon/utils/memoized.py", line 33, in __call__  

  36. value = self.func(*args)  

  37.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/quotas.py", line 115, in tenant_quota_usages  

  38. disabled_quotas=disabled_quotas):  

  39.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/quotas.py", line 98, in ge_tenant_quota_data  

  40. tenant_id=tenant_id)  

  41.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/usage/quotas.py", line 80, in _get_quota_data  

  42.    quotasets.append(getattr(cinder, method_name)(request, tenant_id))  

  43.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/api/cinder.py", line 123, in tenant_quota_get  

  44. c_client = cinderclient(request)  

  45.  File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/api/cinder.py", line 59, in cinderclient  

  46. http_log_debug=settings.DEBUG)  

  47.  File "/usr/lib/python2.7/dist-packages/cinderclient/v1/client.py", line 69, in __init__  

  48. cacert=cacert)  

  49.  File "/usr/lib/python2.7/dist-packages/cinderclient/client.py", line 78, in __init__  

  50.    if hasattr(requests, logging):  

  51. TypeError: hasattr(): attribute name must be string  


錯誤信息中指出了 Cinderclient 的 client.py 中 78 行 hasattr() 方法的屬性必須是一個字符串。
修改代碼:

  1. # vim /usr/lib/python2.7/dist-packages/cinderclient/client.py  

  2. 78 if hasattr(requests, logging): # 改爲 : if hasattr(requests, 'logging'):  

  3. 79 requests.logging.getLogger(requests.__name__).addHandler(ch)  


重新啓動 apache2 :

/etc/init.d/apache2 restart

這次訪問 dashboard 沒有報錯,嘗試創建 volume 也沒有問題了。

11、Unable to attach cinder volume to VM

    在測試openstack中的volume服務時把lvm掛載到虛擬機實例時失敗,這其實不是cinder的錯誤,是iscsi掛載的問題。

以下是計算節點nova-compute.log 的錯誤日誌:

  1. 2012-07-24 14:33:08 TRACE nova.rpc.amqp ProcessExecutionError: Unexpected error while running command.  

  2. 2012-07-24 14:33:08 TRACE nova.rpc.amqp Command: sudo nova-rootwrap iscsiadm -m node -T iqn.2010-10.org.openstack:volume-00000011 -p 192.168.0.23:3260 –rescan  

  3. 2012-07-24 14:33:08 TRACE nova.rpc.amqp Exit code: 255  

  4. 2012-07-24 14:33:08 TRACE nova.rpc.amqp Stdout: ”  

  5. 2012-07-24 14:33:08 TRACE nova.rpc.amqp Stderr: ‘iscsiadm: No portal found.\n’  

以上錯誤是沒有找到iscsi服務端共享出的存儲,查找了很多openstack 資料說要添加以下兩個參數:

iscsi_ip_prefix=192.168.80 #openstack環境內網段

iscsi_ip_address=192.168.80.22 # volume機器內網IP

可是問題依然無法解決,後來發現只要在nova.conf配置文件中添加參數iscsi_helper=tgtadm 就掛載失敗。

根據這個情況進行了測試查看日誌才發現:如果使用參數 :iscsi_helper=tgtadm 時就必須使用 tgt 服務,反之使用iscsitarget服務再添加參數iscsi_helper=ietadm。

我測試環境的問題是tgt和iscsitarget服務都已安裝並運行着(在安裝nova-common時會把tgt服務也安裝上,這個不小心還真不會發現),在nova.conf配置中添加參數iscsi_helper=tgtadm ,查看端口3260 發現是iscsitarget服務佔用,所以導致掛載失敗,我們可以根據情況來使用哪個共享存儲服務!!將tgt 和iscsi_helper=tgtadm、iscsitarget和iscsi_helper=ietadm保留一個即可。

12、glance index報錯:

  1. Authorization Failed: Unable to communicate with identity service: {"error": {"message": "An unexpected error prevented the server from fulfilling your request. Command 'openssl' returned non-zero exit status 3", "code": 500, "title": "Internal Server Error"}}. (HTTP 500)  


在 Grizzly 版,我測試 glance index 時候報錯:

Authorization Failed: Unable to communicate with identity service: {"error": {"message": "An unexpected error prevented the server from fulfilling your request. Command 'openssl' returned non-zero exit status 3", "code": 500, "title": "Internal Server Error"}}. (HTTP 500)

錯誤信息指出:glance 沒有通過keystone驗證,查看了 keystone 日誌,報錯如下:

2677 2013-03-04 12:40:58    ERROR [keystone.common.cms] Signing error: Error opening signer certificate /etc/keystone/ssl/certs/signing_cert.pem
2678 139803495638688:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('/etc/keystone/ssl/certs/signing_cert.pem','r')
2679 139803495638688:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400:
2680 unable to load certificate
2682 2013-03-04 12:40:58    ERROR [root] Command 'openssl' returned non-zero exit status 3
2683 Traceback (most recent call last):
2684   File "/usr/lib/python2.7/dist-packages/keystone/common/wsgi.py", line 231, in __call__
2685     result = method(context, **params)
2686   File "/usr/lib/python2.7/dist-packages/keystone/token/controllers.py", line 118, in authenticate
2687     CONF.signing.keyfile)
2688   File "/usr/lib/python2.7/dist-packages/keystone/common/cms.py", line 140, in cms_sign_token
2689     output = cms_sign_text(text, signing_cert_file_name, signing_key_file_name)
2690   File "/usr/lib/python2.7/dist-packages/keystone/common/cms.py", line 135, in cms_sign_text
2691     raise subprocess.CalledProcessError(retcode, "openssl")
2692 CalledProcessError: Command 'openssl' returned non-zero exit status 3

在Grizzly 版中,keystone 默認驗證方式是 PKI , 需要簽名證書,之前的版本都是用的 UUID,改 keystone.conf:

token_format = UUID

在試一次就沒有錯誤了。

13、鏡像製作

這裏主要強調下windows的鏡像製作,因爲windows的涉及到加載驅動的問題,就比較麻煩。

下載virtio驅動,因爲win默認不支持virtio驅動,而通過openstack管理虛擬機是需要virtio驅動的。需要兩個virtio驅動,一個是硬盤的,一個是網卡的,即:virtio-win-0.1-30.iso和virtio-win-1.1.16.vfd。這裏主要強調兩個地方:

1、創建鏡像:

  1. kvm -m 512 -boot d –drive  

  2. ile=win2003server.img,cache=writeback,if=virtio,boot=on -fda virtio-win-1.1.16.vfd -cdrom windows2003_x64.iso -vnc:10                    


2、引導系統 :

  1. kvm -m 1024 –drive file=win2003server.img,if=virtio,  


  2. boot=on -cdrom virtio-win-0.1-30.iso -net nic,model=virtio -net user -boot c -nographic -vnc 8  


這裏需要注意的地方是if=virtio,boot=on –fda virtio-win-1.1.16.vfd和引導系統時使用的virtio-win-0.1-30.iso 這兩個驅動分別是硬盤和網卡驅動。如果不加載這兩個驅動安裝時會發現找不到硬盤,並且用製作好的鏡像生成實例也會發現網卡找不到驅動,所以在這裏安裝鏡像生成後需要重新引導鏡像安裝更新網卡驅動爲virtio。

14、刪除殭屍volume

如果cinder服務不正常,我們在創建volume時會產生一些殭屍volume,如果在horizon中無法刪除的話,我們需要到服務器上去手動刪除,

命令:lvremove /dev/nova-volumes/volume-000002

注意這裏一定要寫完整的路徑,不然無法刪除,如果刪除提示:

Can't remove open logical volume“ 可嘗試將相關服務stop掉,再嘗試刪除。刪除完還需到數據庫cinder的volumes表裏清除相關記錄。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章