OpenStack云计算(十)——OpenStack虚拟机实例管理,增加一个计算节点并进行实例冷迁移,增加一个计算节点的步骤,实例冷迁移的操作方法

项目实训一

本实训任务对实验环境要求较高,而且过程比较复杂,涉及的步骤非常多,有一定难度,可根据需要选做。可以考虑改为直接观看相关的微课视频

【实训题目】

增加一个计算节点并进行实例冷迁移

【实训目的】

熟悉增加一个计算节点的步骤。

熟悉实例冷迁移的操作方法。

【实训准备】

(1)复习使用Packstack安装器增加节点的基本方法。

(2)另外准备一台操作系统为CentOS 7的主机作为计算节点。

【实训内容】

(1)在实验1的基础上克隆一台虚拟机,将IP地址改为其他地址,确保跟openstack主机IP地址不一样。然后重启网卡。此为第2个节点虚拟机

cd /etc/sysconfig/network-scripts

修改IP地址:IPADDR=192.168.128.29(自己的IP段)

节点1:192.168.128.128

节点2:192.168.128.28

重启网卡

systemctl restart network

(2)修改主机名

建议第1个节点名为:node-a 第2个节点名为:node-b

vi /etc/hostname

修改之后退出重启虚拟机,在命令行前面就显示了

init 6

(3)如果需要修改原来的openstack主机名,则按照如下步骤实现,建议直接在原来的主机名基础上做,不用修改主机名

在单节点的RDO一体化OpenStack云平台的基础上使用Packstack安装器再增加计算节点,构建双节点的实验平台时,如果在部署RDO一体化OpenStack云平台时,/etc/hosts配置文件中保留了以下默认配置:

复制代码
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

那么,该节点的计算主机名会显示为localhost,这种情形在增加计算节点之前,为便于区分不同节点,最好将localhost改为明确的节点主机名(如node-a),只是操作有些复杂,下面给出操作步骤供参考(这可以作为修改计算节点名的通用方法)。

(3.1)停止相关的计算服务
复制代码
systemctl stop libvirtd.service openstack-nova-compute.service openstack-nova-scheduler.service   openstack-nova-conductor.service openstack-nova-novncproxy.service
(3.2)修改/etc/nova/nova.conf配置文件,将其中的host改为指定的节点主机名,将

#host=<current_hostname>

host=localhost

改为:

#host=<current_hostname>

host=node-a

(3.3)修改底层的数据库
复制代码
[root@node-a ~]# mysql -u root

Enter password:              #密码可以从Packstack安装自动产生的应答文件中查找。

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3402

Server version: 10.3.20-MariaDB MariaDB Server



Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.



Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



MariaDB [(none)]> use nova;                       #指定当前数据库

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A



Database changed

#更改计算节点名

MariaDB [nova]> update compute_nodes set host='node-a' where host='localhost';    

Query OK, 1 row affected (0.001 sec)

Rows matched: 1  Changed: 1  Warnings: 0



#更改现有虚拟机实例的计算节点名

MariaDB [nova]> update instances set host='node-a' where host='localhost';

 Query OK, 12 rows affected (0.005 sec)

Rows matched: 12  Changed: 12  Warnings: 0



#更改现有虚拟机实例的启动的计算节点名

MariaDB [nova]> update instances set launched_on='node-a' where launched_on='localhost';           

Query OK, 14 rows affected (0.002 sec)

Rows matched: 14  Changed: 14  Warnings: 0



#更改计算服务的节点主机名

MariaDB [nova]> update services set host='node-a' where host='localhost';

Query OK, 5 rows affected (0.001 sec)

Rows matched: 5  Changed: 5  Warnings: 0



MariaDB [(none)]> use nova_api; #指定当前数据库

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A



#更改主机映射的节点主机名

MariaDB [nova_api]> update host_mappings set host='node-a' where host='localhost';





MariaDB [nova]> flush privileges;

Query OK, 0 rows affected (0.001 sec)



MariaDB [nova]> quit;

Bye
(3.4)启动相关的计算服务

systemctl start libvirtd.service openstack-nova-compute.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

(4)修改/etc/hosts配置文件

(节点1、节点2都要改)

vi /etc/hosts

将节点1的文件改为:

节点2的文件改为

节点1:

节点2:

(5)在节点2,安装必要的软件

yum -y install centos-release-openstack-train

yum makecache

yum -y install openstack-packstack

(6)在节点1,编辑应答文件

将root文件夹下生成的应答文件复制一份:packstack-answers-addnode.txt

cp packstack-answers-20230922-094512.txt packstack-answers-addnode.txt

vi packstack-answers-addnode.txt

CONFIG_COMPUTE_HOSTS=192.168.233.128,192.168.233.28

CONFIG_PROVISION_DEMO_FLOATRANGE=192.168.233.0/24

CONFIG_KEYSTONE_ADMIN_PW=123456

CONFIG_KEYSTONE_DEMO_PW=123456

(7)在节点1执行,使用修改过的应答文件运行Packstack安装器

复制代码
packstack --answer-file=packstack-answers-addnode.txt
...
Installing:
Clean Up                                             [ DONE ]
Discovering ip protocol version                      [ DONE ]
root@192.168.199.32's password:                     #提供第2个节点root账户密码
Setting up ssh keys                                  [ DONE ]
Preparing servers                                    [ DONE ]
...
Copying Puppet modules and manifests                 [ DONE ]
Applying 192.168.199.31_controller.pp
192.168.199.31_controller.pp:                        [ DONE ]           
Applying 192.168.199.31_network.pp
192.168.199.31_network.pp:                           [ DONE ]        
Applying 192.168.199.31_compute.pp
Applying 192.168.199.32_compute.pp                     #应用第2个计算节点
192.168.199.31_compute.pp:                           [ DONE ]        
192.168.199.32_compute.pp:                           [ DONE ]        
Applying Puppet manifests                            [ DONE ]
Finalizing                                           [ DONE ]
(7.1)//在节点 2 处理错误,在节点 1继续执行安装命令

//错误1:leatherman_curl.so.1.3.0: cannot open shared object file

//处理:# yum downgrade -y leatherman

出现节点一错误:

------------------------------------------------------------------------------------------------------------------

//错误2:Error: Package: python2-qpid-proton-0.26.0-2.el7.x86_64 (centos-openstack-train)

//处理:# yum install -y python2-qpid-proton-0.26.0-2.el7.x86_64

------------------------------------------------------------------------------------------------------------------

//安装成功截图

//错误3:Could not set 'present' on ensure: undefined method `split' for nil:NilClass

(8)验证双节点部署

虚拟机管理器列表

计算主机列表

计算服务列表

网络代理列表

新创建测试用的虚拟机实例

新创建的虚拟机实例在node-b主机上运行

任务 3 迁移虚拟机实例

------------------------------------------------------------------------------------------------------------------

1)在计算节点之间配置SSH无密码访问

------------------------------------------------------------------------------------------------------------------

//配置ssh无密码访问(第4步,两个节点都要执行)

ls -l /var/lib/nova/.ssh

echo -e 'strictHostKeyChecking no' > /var/lib/nova/.ssh/config

节点1:

scp -r /var/lib/nova/.ssh/config ZHT-A:/var/lib/nova/.ssh/config

节点2:

scp -r /var/lib/nova/.ssh/config zht33:/var/lib/nova/.ssh/config

usermod -s /bin/bash nova

节点1:

节点2:

//测试

su - nova

ssh zht33

ssh ZHT-A

exit

//在两个节点都要重启nova服务

# systemctl restart libvirtd openstack-nova-compute

节点1:

节点2:

2)执行实例的冷迁移操作(Web界面操作)

------------------------------------------------------------------------------------------------------------------

//admin用户------管理员------计算------实例------迁移实例

相关推荐
AALoveTouch2 小时前
网球馆自动预约系统的反调试
javascript·网络
一个响当当的名号3 小时前
一些主要应用和NAT
运维·服务器·网络
@小博的博客3 小时前
【Linux探索学习】第二篇Linux的基本指令(2)——开启Linux学习第二篇
linux·运维·学习
洋葱圈儿6665 小时前
nat静态地址转化
网络·智能路由器
openHiTLS密码开源社区5 小时前
【密码学实战】openHiTLS passwd命令行:专业密码哈希生成工具
linux·密码学·哈希算法·ldap·密码策略·随机盐值
筵陌5 小时前
深入理解 Reactor 反应堆模式:高性能网络编程的核心
服务器
OPTree4125 小时前
H3C网络设备 实验三: 搭建两个局域网,使两个局域网相互通信(路由器,自动分配ip,DHCP协议)
网络·tcp/ip·智能路由器
WTCLLB5 小时前
netgear r6220 路由器,刷openwrt后,系统备份还原
linux·网络·智能路由器·openwrt
迎風吹頭髮6 小时前
UNIX下C语言编程与实践38-UNIX 信号操作:signal 函数与信号捕获函数的编写
linux·c语言·unix
做运维的阿瑞6 小时前
Linux系统性能监控与故障定位实战:CPU/内存/I/O/网络
linux·运维·网络