C语言学习网

kilo版openstack如何调整云主机大小

发表于:2022-10-04 作者:安全数据网编辑
编辑最后更新 2022年10月04日,这篇文章主要介绍了kilo版openstack如何调整云主机大小,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。一、背景kilo版本,d

这篇文章主要介绍了kilo版openstack如何调整云主机大小,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

一、背景

kilo版本,dashboard页面在线调整云主机大小,点击后无变化,需要修改配置。

二、配置修改

所有节点修改nova配置文件/etc/nova/nova.conf


# vi /etc/nova/nova.conf[DEFAULT]...scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilterallow_resize_to_same_host=true

三、重启服务

控制节点

# systemctl restart openstack-nova-api openstack-nova-cert openstack-nova-compute openstack-nova-scheduler openstack-nova-conductor

计算节点

# systemctl restart openstack-nova-compute

四、配置nova用户互信

按照官方文档安装的kilo版本openstack的nova用户并不是自己手动创建的,需要修改nova用户的配置才可以配置互信

配置互信是为了避免出现调整云主机大小时出现以下类似报错

2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher Traceback (most recent call last):2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 142, in _dispatch_and_reply2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     executor_callback))2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 186, in _dispatch2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     executor_callback)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 130, in _do_dispatch2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     result = func(ctxt, **new_args)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 6890, in resize_instance2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     clean_shutdown=clean_shutdown)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/exception.py", line 88, in wrapped2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     payload)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/exception.py", line 71, in wrapped2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     return f(self, context, *args, **kw)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 333, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     LOG.warning(msg, e, instance_uuid=instance_uuid)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 304, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 383, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 292, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     migration.instance_uuid, exc_info=True)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 269, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 361, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     kwargs['instance'], e, sys.exc_info())2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     six.reraise(self.type_, self.value, self.tb)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 349, in decorated_function2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     return function(self, context, *args, **kwargs)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 4078, in resize_instance2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     self.instance_events.clear_events_for_instance(instance)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     self.gen.throw(type, value, traceback)2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 6479, in _error_out_instance_on_exception2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher     raise error.inner_exception2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher ResizeError: Resize error: not able to execute ssh command: Unexpected error while running command.2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher Command: ssh 192.168.8.218 mkdir -p /var/lib/nova/instances/2907c778-3e30-4012-ab2c-ab43dcca1ea02016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher Exit code: 2552016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher Stdout: u''2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher Stderr: u'Host key verification failed.\r\n'2016-07-29 14:03:13.933 33877 TRACE oslo_messaging.rpc.dispatcher

4.1 修改nova用户密码

# passwd novaChanging password for user nova.New password: BAD PASSWORD: The password is shorter than 8 charactersRetype new password: passwd: all authentication tokens updated successfully.

4.2 修改/etc/passwd

# vi /etc/passwd将nova:x:162:162:OpenStack Nova Daemons:/var/lib/nova:/sbin/nologin修改为nova:x:162:162:OpenStack Nova Daemons:/var/lib/nova:/bin/bash

4.3 配置互信

此时可以切换至nova用户,bdc217上操作

nova之间不仅仅是要无密码,还必须得是不需要验证,节点少的情况下所以最好手动节点之间互相先ssh连接一下。

-bash-4.2$ ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/var/lib/nova/.ssh/id_rsa): Created directory '/var/lib/nova/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /var/lib/nova/.ssh/id_rsa.Your public key has been saved in /var/lib/nova/.ssh/id_rsa.pub.The key fingerprint is:35:b2:62:61:cb:1e:fb:a9:03:19:5b:a8:38:e7:70:54 nova@bdc212The key's randomart image is:+--[ RSA 2048]----+|                 ||    E            ||   . .o .. o     ||  . oo.o + .     || o . =* S        ||+ + +o +         || *   .o          ||  .   .. .       ||      .oo        |+-----------------+ -bash-4.2$ ssh-copy-id localhost-bash-4.2$ scp -r .ssh/ bdc218:~/-bash-4.2$ scp -r .ssh/ bdc216:~/-bash-4.2$ ssh bdc218Last login: Fri Jul 29 16:13:20 2016 from 192.168.13.217-bash-4.2$ uname -nbdc218

成功无密码连接到bdc218的nova用户

4.4 登录dashboard

4.4.1 调整大小前截图留念

4.4.2 调整云主机大小

4.4.3 把其它的几台云主机也调整了

4.4.4 此外不仅可以调大,开弓也有回头箭,还可以调小

五、总结

OpenStack的云主机配置类型的修改,其实相当于做了一个云主机在不同宿主机的迁移,所以需要在相关迁移云主机进行无密码访问,由于OpenStack是由Nova组件来管理云主机,所以需要对Nova用户进行无密码访问。

但是,云主机之间的迁移可以通过virsh 的qemu+tcp的方式进行迁移,不用配置nova的互信也可以进行。

kilo版openstack云主机动态热迁移


六、注意

1、 在迁移或者调整云主机大小的过程中,虚拟机会有 downtime,运行的服务也会down掉,所以最好事先关闭正在运行的服务。

2、nova之间不仅仅是要无密码,还必须得是不需要验证,节点少的情况下所以最好手动节点之间互相先ssh连接一下。

感谢你能够认真阅读完这篇文章,希望小编分享的"kilo版openstack如何调整云主机大小"这篇文章对大家有帮助,同时也希望大家多多支持,关注行业资讯频道,更多相关知识等着你来学习!

0