Unable to establish connection to http://controller:8774/v2.1/os-services?binary=nova-compute

一、問題背景

1.1、準備環境

在VMware Workstation 14 Pro,安裝如下配置虛擬機,然後在虛擬式搭建OpenStack Stein版本

主機名 IP 配置 節點名稱
controller 10.0.0.11 1vcpu 2GB內存 50GB磁盤 控制節點
compute 10.0.0.12 1vcpu 2GB內存 50GB磁盤 計算節點

1.2、問題出現

當我已經安裝好控制節點和計算節點的nova後,在控制節點上添加計算節點時出現該錯誤如下:

[root@controller ~]# openstack compute service list --service nova-compute
Unable to establish connection to http://controller:8774/v2.1/os-services?binary=nova-compute: HTTPConnectionPool(host='controller', port=8774): Max retries exceeded with url: /v2.1/os-services?binary=nova-compute (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f04f4f026d0>: Failed to establish a new connection: [Errno 111] Connection refused',))

二、排查問題並解決

2.1、排查問題

通過su - nova -s /bin/bashnova-api --config-file /etc/nova/nova.conf來查看錯誤,操作如下:

[root@controller ~]# su - nova -s /bin/bash  # 切換身份
login: Fri Sep 27 10:05:14 CST 2019 on pts/0
-bash-4.2$ nova-api --config-file /etc/nova/nova.conf  #測試nova-api 
2019-09-27 10:31:46.532 70191 WARNING nova.service [-] Running nova-osapi_compute using eventlet is deprecated. Deploy with a WSGI server such as uwsgi or mod_wsgi.
/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py:22: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  return pkg_resources.EntryPoint.parse("x=" + s).load(False)
2019-09-27 10:31:48.913 70191 WARNING oslo_config.cfg [-] Deprecated: Option "use_neutron" from group "DEFAULT" is deprecated for removal (
nova-network is deprecated, as are any related configuration options.
).  Its value may be silently ignored in the future.
2019-09-27 10:31:50.584 70191 WARNING keystonemiddleware.auth_token [-] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2019-09-27 10:31:50.603 70191 WARNING keystonemiddleware.auth_token [-] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2019-09-27 10:31:51.109 70191 WARNING keystonemiddleware.auth_token [-] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set   is to True.
2019-09-27 10:31:51.113 70191 WARNING keystonemiddleware.auth_token [-] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2019-09-27 10:31:51.176 70191 INFO nova.wsgi [-] osapi_compute listening on 0.0.0.0:8774
2019-09-27 10:31:51.178 70191 INFO oslo_service.service [-] Starting 1 workers
2019-09-27 10:31:51.182 70191 WARNING nova.service [-] Running nova-metadata using eventlet is deprecated. Deploy with a WSGI server such as uwsgi or mod_wsgi.
2019-09-27 10:31:51.323 70191 INFO nova.wsgi [-] metadata listening on 0.0.0.0:8775
2019-09-27 10:31:51.325 70191 INFO oslo_service.service [-] Starting 1 workers
2019-09-27 10:31:51.366 70191 WARNING oslo_config.cfg [-] Deprecated: Option "firewall_driver" from group "DEFAULT" is deprecated for removal (
nova-network is deprecated, as are any related configuration options.
).  Its value may be silently ignored in the future.
2019-09-27 10:31:52.598 70239 INFO nova.metadata.wsgi.server [req-f276ad52-d446-408a-9de9-3169a87e0d80 - - - - -] (70239) wsgi starting up on http://0.0.0.0:8775
2019-09-27 10:31:52.773 70238 INFO nova.osapi_compute.wsgi.server [req-60836c58-fd81-4a64-b53f-4a2d7b347082 - - - - -] (70238) wsgi starting up on http://0.0.0.0:8774
2019-09-27 10:31:55.685 70191 INFO oslo_service.service [-] Child 70239 killed by signal 9
2019-09-27 10:31:55.725 70191 CRITICAL nova [-] Unhandled error: OSError: [Errno 12] Cannot allocate memory
2019-09-27 10:31:55.725 70191 ERROR nova Traceback (most recent call last):
2019-09-27 10:31:55.725 70191 ERROR nova   File "/bin/nova-api", line 10, in <module>
2019-09-27 10:31:55.725 70191 ERROR nova     sys.exit(main())
2019-09-27 10:31:55.725 70191 ERROR nova   File "/usr/lib/python2.7/site-packages/nova/cmd/api.py", line 69, in main
2019-09-27 10:31:55.725 70191 ERROR nova     launcher.wait()
2019-09-27 10:31:55.725 70191 ERROR nova   File "/usr/lib/python2.7/site-packages/oslo_service/service.py", line 661, in wait
2019-09-27 10:31:55.725 70191 ERROR nova     self._respawn_children()
2019-09-27 10:31:55.725 70191 ERROR nova   File "/usr/lib/python2.7/site-packages/oslo_service/service.py", line 648, in _respawn_children
2019-09-27 10:31:55.725 70191 ERROR nova     self._start_child(wrap)
2019-09-27 10:31:55.725 70191 ERROR nova   File "/usr/lib/python2.7/site-packages/oslo_service/service.py", line 567, in _start_child
2019-09-27 10:31:55.725 70191 ERROR nova     pid = os.fork()
2019-09-27 10:31:55.725 70191 ERROR nova OSError: [Errno 12] Cannot allocate memory  # 不能分配內存,說明內存不足。
2019-09-27 10:31:55.725 70191 ERROR nova 
-bash-4.2$ exit  # 退出

2.2、查看內存

[root@controller ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           1819        1664          69           9          85          16
Swap:             0           0           0

發現內存內存確實不多了。

2.3、添加內存

關閉虛擬機後添加內存,然後開啓虛擬機,查看看內存

[root@controller ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3771        1892        1569          11         309        1606
Swap:             0           0           0

2.4、測試nova-api

[root@controller ~]# su - nova -s /bin/bash
-bash-4.2$ nova-api --config-file /etc/nova/nova.conf 
2019-09-27 11:00:27.503 11397 WARNING nova.service [-] Running nova-osapi_compute using eventlet is deprecated. Deploy with a WSGI server such as uwsgi or mod_wsgi.
/usr/lib/python2.7/site-packages/paste/deploy/loadwsgi.py:22: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  return pkg_resources.EntryPoint.parse("x=" + s).load(False)
2019-09-27 11:00:28.540 11397 WARNING oslo_config.cfg [-] Deprecated: Option "use_neutron" from group "DEFAULT" is deprecated for removal (
nova-network is deprecated, as are any related configuration options.
).  Its value may be silently ignored in the future.
2019-09-27 11:00:28.907 11397 WARNING keystonemiddleware.auth_token [-] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2019-09-27 11:00:28.913 11397 WARNING keystonemiddleware.auth_token [-] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2019-09-27 11:00:29.387 11397 WARNING keystonemiddleware.auth_token [-] AuthToken middleware is set with keystone_authtoken.service_token_roles_required set to False. This is backwards compatible but deprecated behaviour. Please set this to True.
2019-09-27 11:00:29.392 11397 WARNING keystonemiddleware.auth_token [-] Configuring www_authenticate_uri to point to the public identity endpoint is required; clients may not be able to authenticate against an admin endpoint
2019-09-27 11:00:29.437 11397 INFO nova.wsgi [-] osapi_compute listening on 0.0.0.0:8774
2019-09-27 11:00:29.438 11397 INFO oslo_service.service [-] Starting 2 workers
2019-09-27 11:00:29.450 11397 WARNING nova.service [-] Running nova-metadata using eventlet is deprecated. Deploy with a WSGI server such as uwsgi or mod_wsgi.
2019-09-27 11:00:29.734 11397 INFO nova.wsgi [-] metadata listening on 0.0.0.0:8775
2019-09-27 11:00:29.735 11397 INFO oslo_service.service [-] Starting 2 workers
2019-09-27 11:00:29.893 11397 WARNING oslo_config.cfg [-] Deprecated: Option "firewall_driver" from group "DEFAULT" is deprecated for removal (
nova-network is deprecated, as are any related configuration options.
).  Its value may be silently ignored in the future.
2019-09-27 11:00:30.847 11410 INFO nova.osapi_compute.wsgi.server [req-832b4ada-9a5e-44b3-a290-f3e4d2166a00 - - - - -] (11410) wsgi starting up on http://0.0.0.0:8774
2019-09-27 11:00:31.110 11411 INFO nova.osapi_compute.wsgi.server [req-41feee3d-0a8f-40f9-bb4f-7fe4801144aa - - - - -] (11411) wsgi starting up on http://0.0.0.0:8774
2019-09-27 11:00:31.140 11414 INFO nova.metadata.wsgi.server [req-52e38269-17d8-4558-9621-f349d7f52722 - - - - -] (11414) wsgi starting up on http://0.0.0.0:8775
2019-09-27 11:00:31.336 11413 INFO nova.metadata.wsgi.server [req-85f6acba-dd94-429b-a2f6-cf9e0ebd5b15 - - - - -] (11413) wsgi starting up on http://0.0.0.0:8775

沒有報錯了,說明剛剛內存問題已經解決。

2.5、重新獲取計算節點

[root@controller ~]# openstack compute service list --service nova-compute
+----+--------------+---------+------+---------+-------+----------------------------+
| ID | Binary       | Host    | Zone | Status  | State | Updated At                 |
+----+--------------+---------+------+---------+-------+----------------------------+
|  5 | nova-compute | compute | nova | enabled | up    | 2019-09-27T03:06:48.000000 |
+----+--------------+---------+------+---------+-------+----------------------------+

已經獲取了計算節點,問題已經解決啦

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