Openstack - QLGQ/learning-python GitHub Wiki
云计算的类型
1.IaaS(基础架构即服务),用户能从中申请到硬件或虚拟硬件,包括裸机或虚拟机,然后在上边安装操作系统或其他应用程序。
2.PaaS(平台即服务),用户能从中申请到一个安装了操作系统以及支撑应用程序运行所需要的运行库等软件的物理机或虚拟机,然后在上边安装其他应用程序,但不能修改已经预装好的操作系统和运行环境。
3.SaaS(软件即服务),用户可以通过网络以租赁的方式来使用一些软件,而不是购买,比较常见的模式是提供一组账号密码。
OpenStack简介
OpenStack就是一种IaaS。OpenStack目前共涵盖了七个核心组件,分别是计算(Compute)、对象存储(Object Storage)、认证(Identity)、用户界面(Dashboard)、块存储(Block Storage)、网络(Network)和镜像服务(Image Service)。每个组件都是多个服务的集合,一个服务意味着运行着的一个进程。
- Compute(Nova):Compute的项目代号是Nova,他根据需求提供虚拟机服务,比如创建虚拟机或对虚拟机做热迁移等。
- Object Storage(Swift):它允许存储或检索对象,也可以认为它允许存储或检索文件,它能以低成本的方式管理大量无结构数据。
- Identity(KeyStone):为所有OpenStack服务提供身份验证和授权,跟踪用户以及他们的权限,提供一个可用服务及API列表。
- DashBoard(Horizon):它为所有OpenStack的服务提供一个模块化的基于Django的界面,通过这个界面,不论是最终用户还是运维人员都可以完成大多数的操作,比如启动虚拟机,分配IP地址,动态迁移等。
- Block Storage(Cinder):提供块存储服务。
- Network(Neutron):用于提供网络连接服务,允许用户创建自己的虚拟网络并连接各种网络设备接口。
- ImageServie(Glance):提供一个虚拟机镜像的存储、查询和检索服务,通过提供一个虚拟磁盘映像的目录和存储库,为Nova虚拟机提供提供镜像服务。
实例
下面以创建虚拟机为例说明一下各个组件之间是如何相互配合完成工作的。
用户首先接触到的是界面,也就是Horizon。通过Horizon上的简单界面操作,一个创建虚拟机的请求被发送到OpenStack系统后端。既然要启动一个虚拟机,就必须指定虚拟机操作系统是什么类型,就必须下载启动镜像以供虚拟机启动使用,这件事情就由Glance来完成的,而此时Glance所管理的镜像是有可能存储在Swift上的,所以需要与Swift交互得到需要的镜像文件。在创建虚拟机的时候,自然而然地需要Cinder提供块服务和Neutron提供网络,以便该虚拟机有volume可以使用,能被分配到IP地址与外界网络连接,而且之后改虚拟机资源的访问要经过KeyStone的认证之后才可以继续。至此,OpenStack的所有核心组件都参与了这个创建虚拟机的操作。
Problems
[root@controller ~]# openstack image create "cirros" --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public
Discovering versions from the identity service failed when creating the password plugin. Attempting to determine version from URL.
Unable to establish connection to http://controller:35357/v3/auth/tokens: HTTPConnectionPool(host='controller', port=35357): Max retries exceeded with url: /v3/auth/tokens (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x2967ed0>: Failed to establish a new connection: [Errno 111] \xe6\x8b\x92\xe7\xbb\x9d\xe8\xbf\x9e\xe6\x8e\xa5',))
问题原因:httpd服务未正常启动!
解决办法:正常启动httpd服务!
http://192.168.7.247/dashboard
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
问题:登录不上dashboard界面
解决办法:编辑文件/etc/httpd/conf.d/openstack-dashboard.conf
在WSGISocketPrefix run/wsgi下面加一行代码:
WSGIApplicationGroup %{GLOBAL}
保存,重启httpd服务。
systemctl restart openstack-nova-compute.service
Failed to restart openstack-nova-compute.service: Unit not found.
问题:重启服务失败
解决办法:之所以重启失败是因为文件不存在,无意间卸载了相关文件,重新下载并配置,然后使其开机启动即可。
# systemctl enable openstack-nova-compute.service
# systemctl start openstack-nova-compute.service
[root@controller ~]# openstack server list
发生意外 API 错误。请在 http://bugs.launchpad.net/nova/ 处报告此错误,并且附上 Nova API 日志(如果可能)。
<class 'sqlalchemy.exc.OperationalError'> (HTTP 500) (Request-ID: req-800101d9-5813-4135-a3f7-2f1f16149c30)
问题:openstack中数据库连接太多
解决方法:https://www.cnblogs.com/yaohong/p/7679270.html
2018-03-01 14:30:24.100 32569 INFO cinder.scheduler.base_filter [req-bcd170fa-01e5-48a6-b04c-1e78cd71257f 25cadc5e05e6493a8a2512fd89dd79f3 b989306f30594776b1ee1861c1b850fe - default default] Filtering removed all hosts for the request with volume ID 'bedc4179-8206-4829-9227-ee751984fe25'. Filter results: AvailabilityZoneFilter: (start: 0, end: 0), CapacityFilter: (start: 0, end: 0), CapabilitiesFilter: (start: 0, end: 0)
2018-03-01 14:30:24.101 32569 WARNING cinder.scheduler.filter_scheduler [req-bcd170fa-01e5-48a6-b04c-1e78cd71257f 25cadc5e05e6493a8a2512fd89dd79f3 b989306f30594776b1ee1861c1b850fe - default default] No weighed backend found for volume with properties: None
2018-03-01 14:30:24.102 32569 INFO cinder.message.api [req-bcd170fa-01e5-48a6-b04c-1e78cd71257f 25cadc5e05e6493a8a2512fd89dd79f3 b989306f30594776b1ee1861c1b850fe - default default] Creating message record for request_id = req-bcd170fa-01e5-48a6-b04c-1e78cd71257f
2018-03-01 14:30:24.108 32569 ERROR cinder.scheduler.flows.create_volume [req-bcd170fa-01e5-48a6-b04c-1e78cd71257f 25cadc5e05e6493a8a2512fd89dd79f3 b989306f30594776b1ee1861c1b850fe - default default] Failed to run task cinder.scheduler.flows.create_volume.ScheduleCreateVolumeTask;volume:create: No valid backend was found. No weighed backends available.
问题描述:在块存储创建volume时,卷状态为error。
解决方法:仔细检查块存储节点配置文件/etc/cinder/cinder.conf。配置文件正确的话,问题就解决了。
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server [req-3cce9050-81a0-4c02-bd45-dce95c0caa9e 25cadc5e05e6493a8a2512fd89dd79f3 b989306f30594776b1ee1861c1b850fe - default default] Exception during message handling
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server Traceback (most recent call last):
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 155, in _process_incoming
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 222, in dispatch
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 192, in _do_dispatch
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server result = func(ctxt, **new_args)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/cinder/volume/manager.py", line 1494, in initialize_connection
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server volume, connector)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/lvm.py", line 839, in create_export
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server volume_path)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/cinder/volume/targets/iscsi.py", line 210, in create_export
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server **portals_config)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/cinder/utils.py", line 796, in _wrapper
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server return r.call(f, *args, **kwargs)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/retrying.py", line 223, in call
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server return attempt.get(self._wrap_exception)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/retrying.py", line 261, in get
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server six.reraise(self.value[0], self.value[1], self.value[2])
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/retrying.py", line 217, in call
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/cinder/volume/targets/tgt.py", line 138, in create_iscsi_target
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server run_as_root=True)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/cinder/utils.py", line 123, in execute
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server return processutils.execute(*cmd, **kwargs)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server File "/usr/lib/python2.7/site-packages/oslo_concurrency/processutils.py", line 400, in execute
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server cmd=sanitized_cmd)
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server ProcessExecutionError: Unexpected error while running command.
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server Command: sudo cinder-rootwrap /etc/cinder/rootwrap.conf tgtadm --lld iscsi --op show --mode target
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server Exit code: 96
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server Stdout: u''
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server Stderr: u'/usr/bin/cinder-rootwrap: Executable not found: tgtadm (filter match = tgtadm)\n'
2018-03-01 16:18:49.059 11532 ERROR oslo_messaging.rpc.server
2018-03-01 16:18:49.256 11532 INFO cinder.volume.manager [req-2d7cb87d-1bc9-46ab-abb7-ac9ab045bc9c 25cadc5e05e6493a8a2512fd89dd79f3 b989306f30594776b1ee1861c1b850fe - default default] Terminate volume connection completed successfully.
问题描述:块存储将新建的卷附加到实例上时出现问题。
解决方法:在块存储节点上安装sscsi-target-utils,详见(https://www.adamfei.com/1946/)(http://www.talkwithtrend.com/Question/226201)