• 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配置文件中保留了以下默认配置:

    1. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    2. ::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=

    host=localhost

    改为:

    #host=

    host=node-a

    (3.3)修改底层的数据库
    1. [root@node-a ~]# mysql -u root
    2. Enter password:              #密码可以从Packstack安装自动产生的应答文件中查找。
    3. Welcome to the MariaDB monitor.  Commands end with ; or \g.
    4. Your MariaDB connection id is 3402
    5. Server version: 10.3.20-MariaDB MariaDB Server
    6. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    7. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    8. MariaDB [(none)]> use nova;                       #指定当前数据库
    9. Reading table information for completion of table and column names
    10. You can turn off this feature to get a quicker startup with -A
    11. Database changed
    12. #更改计算节点名
    13. MariaDB [nova]> update compute_nodes set host='node-a' where host='localhost';    
    14. Query OK, 1 row affected (0.001 sec)
    15. Rows matched: 1  Changed: 1  Warnings: 0
    16. #更改现有虚拟机实例的计算节点名
    17. MariaDB [nova]> update instances set host='node-a' where host='localhost';
    18.  Query OK, 12 rows affected (0.005 sec)
    19. Rows matched: 12  Changed: 12  Warnings: 0
    20. #更改现有虚拟机实例的启动的计算节点名
    21. MariaDB [nova]> update instances set launched_on='node-a' where launched_on='localhost';           
    22. Query OK, 14 rows affected (0.002 sec)
    23. Rows matched: 14  Changed: 14  Warnings: 0
    24. #更改计算服务的节点主机名
    25. MariaDB [nova]> update services set host='node-a' where host='localhost';
    26. Query OK, 5 rows affected (0.001 sec)
    27. Rows matched: 5  Changed: 5  Warnings: 0
    28. MariaDB [(none)]> use nova_api; #指定当前数据库
    29. Reading table information for completion of table and column names
    30. You can turn off this feature to get a quicker startup with -A
    31. #更改主机映射的节点主机名
    32. MariaDB [nova_api]> update host_mappings set host='node-a' where host='localhost';
    33. MariaDB [nova]> flush privileges;
    34. Query OK, 0 rows affected (0.001 sec)
    35. MariaDB [nova]> quit;
    36. 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安装器

    1. packstack --answer-file=packstack-answers-addnode.txt
    2. Installing:
    3. Clean Up [ DONE ]
    4. Discovering ip protocol version [ DONE ]
    5. root@192.168.199.32's password: #提供第2个节点root账户密码
    6. Setting up ssh keys [ DONE ]
    7. Preparing servers [ DONE ]
    8. Copying Puppet modules and manifests [ DONE ]
    9. Applying 192.168.199.31_controller.pp
    10. 192.168.199.31_controller.pp: [ DONE ]
    11. Applying 192.168.199.31_network.pp
    12. 192.168.199.31_network.pp: [ DONE ]
    13. Applying 192.168.199.31_compute.pp
    14. Applying 192.168.199.32_compute.pp #应用第2个计算节点
    15. 192.168.199.31_compute.pp: [ DONE ]
    16. 192.168.199.32_compute.pp: [ DONE ]
    17. Applying Puppet manifests [ DONE ]
    18. 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用户——管理员——计算——实例——迁移实例

  • 相关阅读:
    windows中超详细深度学习环境配置之安装显卡驱动、cuda、cudnn、pytorch、torchvision、pycharm
    如何选择合适的 AWS 区域对网站性能和成本?
    大学生网页作业成品——基于HTML网上书城项目的设计与实现
    Dubbo 接口测试原理及多种方法
    FPGA高端项目:图像采集+GTP+UDP架构,高速接口以太网视频传输,提供2套工程源码加QT上位机源码和技术支持
    计算机毕业设计Javaweb家庭财务管理系统(源码+系统+mysql数据库+lw文档)
    Linux的常用指令用法
    C++ Reference: Standard C++ Library reference: C Library: cstdlib: EXIT_SUCCESS
    贝叶斯定理~~概率分布
    【英雄哥六月集训】第 29天: 分而治之
  • 原文地址:https://blog.csdn.net/WZY22502701/article/details/138092622