• 容器部署的openstack进入数据库流程、查看install目录流程、容器部署使用virsh命令流程【查看计算节点上的虚拟机信息】


    说明

    • 何为容器部署,无需多说吧?
      如下 计算节点的容器
      在这里插入图片描述

    进入数据库方法【控制节点】

    获取nova密码

    首先获取nova数据库的密码
    控制节点执行:grep mysql /etc/kolla/nova-api/nova.conf 【目录不是固定的,可以通过find命令查找nova.conf文件查看】,如下,1Gr2qFT0LmZ46v0GrFUJmXEFTTBHWVWzofxkxLAn就是密码

    [root@controller01 ~]# grep mysql /etc/kolla/nova-api/nova.conf
    connection = mysql+pymysql://nova:1Gr2qFT0LmZ46v0GrFUJmXEFTTBHWVWzofxkxLAn@1.2.101.240:3306/nova
    connection = mysql+pymysql://nova_api:Msgi5FFcPqlkT26lDaH7wcceAE1cQNbsyzQ6TbzQ@1.2.101.240:3306/nova_api
    [root@controller01 ~]# 
    
    • 1
    • 2
    • 3
    • 4

    查看数据库容器

    肯定会有一个数据库容器的,如我这是mariadb

    [root@controller01 ~]# docker ps 
    CONTAINER ID        IMAGE                                                                          COMMAND                  CREATED             STATUS              PORTS               NAMES                              openvswitch_vswitchd
    ...
    0e12fe84c1d1        1.2.101.32:9980/kolla/centos-binary-iscsid:5.0.6.6                          "kolla_start"            2 years ago         Up 2 years                              iscsid
    fcaf8d58d941        1.2.101.32:9980/kolla/centos-binary-mariadb:5.0.6.6                         "kolla_start"            2 years ago         Up 23 months                            mariadb
    85cb175184b1        1.2.101.32:9980/kolla/centos-binary-memcached:5.0.6.6                       "kolla_start"            2 years ago         Up 23 months                            memcached
    ...
    [root@controller01 ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    进入容器

    [root@controller01 ~]#  docker exec -it mariadb /bin/bash
    (mariadb)[mysql@controller01 /]$ mysql -unova -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 170661721
    Server version: 10.0.38-MariaDB-wsrep MariaDB Server, wsrep_25.25.rc3fc46e
    
    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)]> 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    容器内登录数据库

    (mariadb)[mysql@controller01 /]$ mysql -unova -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 170666994
    Server version: 10.0.38-MariaDB-wsrep MariaDB Server, wsrep_25.25.rc3fc46e
    
    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)]> 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    查看测试

    MariaDB [(none)]> 
    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]> 
    MariaDB [nova]> select * from instances where uuid= '19ec09a5-151b-4111-a4bd-636d10794912' \G
    *************************** 1. row ***************************
                  created_at: 2022-01-18 14:15:33
                  updated_at: 2023-10-12 01:33:59
                  deleted_at: NULL
                          id: 3237
                 internal_id: NULL
                     user_id: cd7e88be84f14196a468f443b345288c
                  project_id: 22fce3ac5d094a32a652555584dd47fb
                   image_ref: 
                   kernel_id: 
                  ramdisk_id: 
                launch_index: 0
                    key_name: NULL
                    key_data: NULL
                 power_state: 0
                    vm_state: active
                   memory_mb: 65536
                       vcpus: 16
                    hostname: rms-database2
                        host: compute30
                   user_data: I2Nsb3VkLWNvbmZpZw0KZGlzYWJsZV9yb290OiBGYWxzZQ0KcGFzc3dvcmQ6IGlSbVNEYXRhQmFzZTNKIyEha2UmaiheXikNCmNocGFzc3dkOg0KICAgIGxpc3Q6IHwNCiAgICAgICAgICByb290OmlSbVNEYXRhQmFzZTNKIyEha2UmaiheXikNCiAgICBleHBpcmU6IEZhbHNlDQpzc2hfcHdhdXRoOiBUcnVl
              reservation_id: r-zvgjpx0l
                 launched_at: 2022-01-18 14:16:02
               terminated_at: NULL
                display_name: rms-database2
         display_description: rms-database2
           availability_zone: core
                      locked: 0
                     os_type: NULL
                 launched_on: compute30
            instance_type_id: 70
                     vm_mode: NULL
                        uuid: 19ec09a5-151b-4111-a4bd-636d10794912
                architecture: NULL
            root_device_name: /dev/vda
                access_ip_v4: NULL
                access_ip_v6: NULL
                config_drive: True
                  task_state: NULL
    default_ephemeral_device: NULL
         default_swap_device: NULL
                    progress: 0
            auto_disk_config: 0
          shutdown_terminate: 0
           disable_terminate: 0
                     root_gb: 200
                ephemeral_gb: 0
                   cell_name: NULL
                        node: compute30
                     deleted: 0
                   locked_by: NULL
                     cleaned: 0
          ephemeral_key_uuid: NULL
    1 row in set (0.00 sec)
    
    MariaDB [nova]>     
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64

    查看install目录流程【计算节点】

    查看容器

    • nova_compute 和nova_libvirt 这2个容器都是可以查看实例目录的,进任意一个都行
    [root@compute30 ~]# docker ps
    CONTAINER ID        IMAGE                                                                      COMMAND                  CREATED             STATUS              PORTS               NAMES
    0f14cdcf6f90        1.2.101.32:9980/kolla/centos-binary-neutron-openvswitch-agent:5.0.6.6   "kolla_start"            2 years ago         Up 2 years                              neutron_openvswitch_agent
    733b936d9a69        1.2.101.32:9980/kolla/centos-binary-openvswitch-vswitchd:5.0.6.6        "kolla_start"            2 years ago         Up 2 years                              openvswitch_vswitchd
    d3dfc7bd9741        1.2.101.32:9980/kolla/centos-binary-openvswitch-db-server:5.0.6.6       "kolla_start"            2 years ago         Up 2 years                              openvswitch_db
    cc979a6d2dc3        1.2.101.32:9980/kolla/centos-binary-nova-compute:5.0.6.6                "kolla_start"            2 years ago         Up 4 months                             nova_compute
    2fd8430c10fc        1.2.101.32:9980/kolla/centos-binary-nova-libvirt:5.0.6.6                "kolla_start"            2 years ago         Up 2 years                              nova_libvirt
    5317fd6f9dc4        1.2.101.32:9980/kolla/centos-binary-nova-ssh:5.0.6.6                    "kolla_start"            2 years ago         Up 2 years                              nova_ssh
    63dc84cd0a08        1.2.101.32:9980/kolla/centos-binary-chrony:5.0.6.6                      "kolla_start"            2 years ago         Up 13 months                            chrony
    c502dcb7f5d1        1.2.101.32:9980/kolla/centos-binary-cron:5.0.6.6                        "kolla_start"            2 years ago         Up 2 years                              cron
    37f17293ad92        1.2.101.32:9980/kolla/centos-binary-kolla-toolbox:5.0.6.6               "kolla_start"            2 years ago         Up 2 years                              kolla_toolbox
    aa0a7798f731        1.2.101.32:9980/kolla/centos-binary-fluentd:5.0.6.6                     "dumb-init --single-…"   2 years ago         Up 2 years                              fluentd
    [root@compute30 ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    进入容器

    • 进入nova_libvirt查看
      我这的实例目录是/var/lib/nova/instances/【你的如果不是就用find搜索instances即可】
    [root@compute30 ~]# docker exec -it nova_libvirt bash
    (nova-libvirt)[root@compute30 /]# cd /var/lib/nova/instances/
    (nova-libvirt)[root@compute30 instances]# ls
    19ec09a5-151b-4111-a4bd-636d10794912  b0cc2a24-1c9c-46d3-bd3b-ef90b78c871c  b7a9b013-d364-4588-b8ae-f6cbd4ba704f  _base          daaf62bf-ed53-4a16-892a-798ac427254b  f8a41b8e-c989-4645-9f18-fdeee075c8d9
    4fad6565-b24b-4617-bb8e-4110ebd43026  b3b091ee-fcbc-4a2a-8a09-7250ee144f3c  b99dc9e3-0d6b-4b3b-965a-d4e10791c4f0  compute_nodes  f76744d4-afbc-4d92-80e0-cbdb7b30be15  locks
    (nova-libvirt)[root@compute30 instances]# cd 19ec09a5-151b-4111-a4bd-636d10794912/
    (nova-libvirt)[root@compute30 19ec09a5-151b-4111-a4bd-636d10794912]# ls
    console.log
    (nova-libvirt)[root@compute30 19ec09a5-151b-4111-a4bd-636d10794912]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 进入nova_compute查看
      可以看到显示内容和nova_libvrit一样的
    [root@compute30 ~]# docker exec -it nova_compute bash
    (nova-compute)[nova@compute30 /]$ cd /var/lib/nova/instances/
    (nova-compute)[nova@compute30 /var/lib/nova/instances]$ ls
    19ec09a5-151b-4111-a4bd-636d10794912  _base                                 b3b091ee-fcbc-4a2a-8a09-7250ee144f3c  b99dc9e3-0d6b-4b3b-965a-d4e10791c4f0  daaf62bf-ed53-4a16-892a-798ac427254b  f8a41b8e-c989-4645-9f18-fdeee075c8d9
    4fad6565-b24b-4617-bb8e-4110ebd43026  b0cc2a24-1c9c-46d3-bd3b-ef90b78c871c  b7a9b013-d364-4588-b8ae-f6cbd4ba704f  compute_nodes                         f76744d4-afbc-4d92-80e0-cbdb7b30be15  locks
    (nova-compute)[nova@compute30 /var/lib/nova/instances]$ cd 19ec09a5-151b-4111-a4bd-636d10794912/
    (nova-compute)[nova@compute30 /var/lib/nova/instances/19ec09a5-151b-4111-a4bd-636d10794912]$ ls
    console.log
    (nova-compute)[nova@compute30 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    使用virsh命令流程【计算节点】

    查看容器

    • virsh命令是基于libvirt服务的,所以我们这需要进入nova_libvirt容器
    [root@compute30 ~]# docker ps
    CONTAINER ID        IMAGE                                                                      COMMAND                  CREATED             STATUS              PORTS               NAMES
    0f14cdcf6f90        1.2.101.32:9980/kolla/centos-binary-neutron-openvswitch-agent:5.0.6.6   "kolla_start"            2 years ago         Up 2 years                              neutron_openvswitch_agent
    733b936d9a69        1.2.101.32:9980/kolla/centos-binary-openvswitch-vswitchd:5.0.6.6        "kolla_start"            2 years ago         Up 2 years                              openvswitch_vswitchd
    d3dfc7bd9741        1.2.101.32:9980/kolla/centos-binary-openvswitch-db-server:5.0.6.6       "kolla_start"            2 years ago         Up 2 years                              openvswitch_db
    cc979a6d2dc3        1.2.101.32:9980/kolla/centos-binary-nova-compute:5.0.6.6                "kolla_start"            2 years ago         Up 4 months                             nova_compute
    2fd8430c10fc        1.2.101.32:9980/kolla/centos-binary-nova-libvirt:5.0.6.6                "kolla_start"            2 years ago         Up 2 years                              nova_libvirt
    5317fd6f9dc4        1.2.101.32:9980/kolla/centos-binary-nova-ssh:5.0.6.6                    "kolla_start"            2 years ago         Up 2 years                              nova_ssh
    63dc84cd0a08        1.2.101.32:9980/kolla/centos-binary-chrony:5.0.6.6                      "kolla_start"            2 years ago         Up 13 months                            chrony
    c502dcb7f5d1        1.2.101.32:9980/kolla/centos-binary-cron:5.0.6.6                        "kolla_start"            2 years ago         Up 2 years                              cron
    37f17293ad92        1.2.101.32:9980/kolla/centos-binary-kolla-toolbox:5.0.6.6               "kolla_start"            2 years ago         Up 2 years                              kolla_toolbox
    aa0a7798f731        1.2.101.32:9980/kolla/centos-binary-fluentd:5.0.6.6                     "dumb-init --single-…"   2 years ago         Up 2 years                              fluentd
    [root@compute30 ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    进入容器执行命令查看虚拟机和其uuid

    [root@compute30 ~]# docker exec -it nova_libvirt bash
    (nova-libvirt)[root@compute30 /]# 
    (nova-libvirt)[root@compute30 /]# virsh list --all
     Id    Name                           State
    ----------------------------------------------------
     27    instance-00000c37              running
     33    instance-00000cf0              running
     41    instance-00000e08              running
     45    instance-0000144d              running
     52    instance-00000c5a              running
     54    instance-00000c0a              running
     60    instance-00000d0e              running
    
    (nova-libvirt)[root@compute30 /]# 
    (nova-libvirt)[root@compute30 /]# virsh domuuid 27
    b99dc9e3-0d6b-4b3b-965a-d4e10791c4f0
    
    (nova-libvirt)[root@compute30 /]# 
    (nova-libvirt)[root@compute30 /]# virsh domuuid 33
    b0cc2a24-1c9c-46d3-bd3b-ef90b78c871c
    
    (nova-libvirt)[root@compute30 /]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    不进入容器执行命令查看虚拟机和其uuid

    • 命令:docker exec NAMES 命令【docker ps 查看NAMES】
    [root@compute30 ~]# docker exec nova_libvirt  virsh list --all
     Id    Name                           State
    ----------------------------------------------------
     27    instance-00000c37              running
     33    instance-00000cf0              running
     41    instance-00000e08              running
     45    instance-0000144d              running
     54    instance-00000c0a              running
     79    instance-00000ca5              running
    
    [root@compute30 ~]#
    [root@compute30 ~]# docker exec nova_libvirt  virsh domuuid 27
    b99dc9e3-0d6b-4b3b-965a-d4e10791c4f0
    
    [root@compute30 ~]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 换一个容器查看时间继续测试
    [root@compute30 ~]# docker exec nova_compute date
    Thu Oct 12 17:40:38 CST 2023
    [root@compute30 ~]# 
    
    • 1
    • 2
    • 3
  • 相关阅读:
    【有问必答】搭建uniapp项目流程手把手教学
    从上帝视角认识SpringMVC预览
    C_9练习题
    c++实现dijskstra算法
    给浏览器开挂,超好用的全平台快捷指令工具推荐
    Spring02之面向切面【进阶版】
    C++基础(01)
    分布式雪花算法
    KubeEdge-Ianvs v0.2 发布:终身学习支持非结构化场景
    Appium+python+unittest搭建UI自动化框架
  • 原文地址:https://blog.csdn.net/cuichongxin/article/details/133795638