本文主要是介绍容器部署的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@10.241.101.240:3306/nova
connection = mysql+pymysql://nova_api:Msgi5FFcPqlkT26lDaH7wcceAE1cQNbsyzQ6TbzQ@10.241.101.240:3306/nova_api
[root@controller01 ~]#
查看数据库容器
肯定会有一个数据库容器的,如我这是mariadb
[root@controller01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES openvswitch_vswitchd
...
0e12fe84c1d1 10.241.101.32:9980/kolla/centos-binary-iscsid:5.0.6.6 "kolla_start" 2 years ago Up 2 years iscsid
fcaf8d58d941 10.241.101.32:9980/kolla/centos-binary-mariadb:5.0.6.6 "kolla_start" 2 years ago Up 23 months mariadb
85cb175184b1 10.241.101.32:9980/kolla/centos-binary-memcached:5.0.6.6 "kolla_start" 2 years ago Up 23 months memcached
...
[root@controller01 ~]#
进入容器
[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.rc3fc46eCopyright (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)]>
容器内登录数据库
(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.rc3fc46eCopyright (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)]>
查看测试
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 -ADatabase 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:33updated_at: 2023-10-12 01:33:59deleted_at: NULLid: 3237internal_id: NULLuser_id: cd7e88be84f14196a468f443b345288cproject_id: 22fce3ac5d094a32a652555584dd47fbimage_ref: kernel_id: ramdisk_id: launch_index: 0key_name: NULLkey_data: NULLpower_state: 0vm_state: activememory_mb: 65536vcpus: 16hostname: rms-database2host: compute30user_data: I2Nsb3VkLWNvbmZpZw0KZGlzYWJsZV9yb290OiBGYWxzZQ0KcGFzc3dvcmQ6IGlSbVNEYXRhQmFzZTNKIyEha2UmaiheXikNCmNocGFzc3dkOg0KICAgIGxpc3Q6IHwNCiAgICAgICAgICByb290OmlSbVNEYXRhQmFzZTNKIyEha2UmaiheXikNCiAgICBleHBpcmU6IEZhbHNlDQpzc2hfcHdhdXRoOiBUcnVlreservation_id: r-zvgjpx0llaunched_at: 2022-01-18 14:16:02terminated_at: NULLdisplay_name: rms-database2display_description: rms-database2availability_zone: corelocked: 0os_type: NULLlaunched_on: compute30instance_type_id: 70vm_mode: NULLuuid: 19ec09a5-151b-4111-a4bd-636d10794912architecture: NULLroot_device_name: /dev/vdaaccess_ip_v4: NULLaccess_ip_v6: NULLconfig_drive: Truetask_state: NULL
default_ephemeral_device: NULLdefault_swap_device: NULLprogress: 0auto_disk_config: 0shutdown_terminate: 0disable_terminate: 0root_gb: 200ephemeral_gb: 0cell_name: NULLnode: compute30deleted: 0locked_by: NULLcleaned: 0ephemeral_key_uuid: NULL
1 row in set (0.00 sec)MariaDB [nova]>
查看install目录流程【计算节点】
查看容器
- nova_compute 和nova_libvirt 这2个容器都是可以查看实例目录的,进任意一个都行
[root@compute30 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f14cdcf6f90 10.241.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 10.241.101.32:9980/kolla/centos-binary-openvswitch-vswitchd:5.0.6.6 "kolla_start" 2 years ago Up 2 years openvswitch_vswitchd
d3dfc7bd9741 10.241.101.32:9980/kolla/centos-binary-openvswitch-db-server:5.0.6.6 "kolla_start" 2 years ago Up 2 years openvswitch_db
cc979a6d2dc3 10.241.101.32:9980/kolla/centos-binary-nova-compute:5.0.6.6 "kolla_start" 2 years ago Up 4 months nova_compute
2fd8430c10fc 10.241.101.32:9980/kolla/centos-binary-nova-libvirt:5.0.6.6 "kolla_start" 2 years ago Up 2 years nova_libvirt
5317fd6f9dc4 10.241.101.32:9980/kolla/centos-binary-nova-ssh:5.0.6.6 "kolla_start" 2 years ago Up 2 years nova_ssh
63dc84cd0a08 10.241.101.32:9980/kolla/centos-binary-chrony:5.0.6.6 "kolla_start" 2 years ago Up 13 months chrony
c502dcb7f5d1 10.241.101.32:9980/kolla/centos-binary-cron:5.0.6.6 "kolla_start" 2 years ago Up 2 years cron
37f17293ad92 10.241.101.32:9980/kolla/centos-binary-kolla-toolbox:5.0.6.6 "kolla_start" 2 years ago Up 2 years kolla_toolbox
aa0a7798f731 10.241.101.32:9980/kolla/centos-binary-fluentd:5.0.6.6 "dumb-init --single-…" 2 years ago Up 2 years fluentd
[root@compute30 ~]#
进入容器
- 进入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]#
- 进入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
使用virsh命令流程【计算节点】
查看容器
- virsh命令是基于libvirt服务的,所以我们这需要进入nova_libvirt容器
[root@compute30 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f14cdcf6f90 10.241.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 10.241.101.32:9980/kolla/centos-binary-openvswitch-vswitchd:5.0.6.6 "kolla_start" 2 years ago Up 2 years openvswitch_vswitchd
d3dfc7bd9741 10.241.101.32:9980/kolla/centos-binary-openvswitch-db-server:5.0.6.6 "kolla_start" 2 years ago Up 2 years openvswitch_db
cc979a6d2dc3 10.241.101.32:9980/kolla/centos-binary-nova-compute:5.0.6.6 "kolla_start" 2 years ago Up 4 months nova_compute
2fd8430c10fc 10.241.101.32:9980/kolla/centos-binary-nova-libvirt:5.0.6.6 "kolla_start" 2 years ago Up 2 years nova_libvirt
5317fd6f9dc4 10.241.101.32:9980/kolla/centos-binary-nova-ssh:5.0.6.6 "kolla_start" 2 years ago Up 2 years nova_ssh
63dc84cd0a08 10.241.101.32:9980/kolla/centos-binary-chrony:5.0.6.6 "kolla_start" 2 years ago Up 13 months chrony
c502dcb7f5d1 10.241.101.32:9980/kolla/centos-binary-cron:5.0.6.6 "kolla_start" 2 years ago Up 2 years cron
37f17293ad92 10.241.101.32:9980/kolla/centos-binary-kolla-toolbox:5.0.6.6 "kolla_start" 2 years ago Up 2 years kolla_toolbox
aa0a7798f731 10.241.101.32:9980/kolla/centos-binary-fluentd:5.0.6.6 "dumb-init --single-…" 2 years ago Up 2 years fluentd
[root@compute30 ~]#
进入容器执行命令查看虚拟机和其uuid
[root@compute30 ~]# docker exec -it nova_libvirt bash
(nova-libvirt)[root@compute30 /]#
(nova-libvirt)[root@compute30 /]# virsh list --allId Name State
----------------------------------------------------27 instance-00000c37 running33 instance-00000cf0 running41 instance-00000e08 running45 instance-0000144d running52 instance-00000c5a running54 instance-00000c0a running60 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 /]#
不进入容器执行命令查看虚拟机和其uuid
- 命令:
docker exec NAMES 命令
【docker ps 查看NAMES】
[root@compute30 ~]# docker exec nova_libvirt virsh list --allId Name State
----------------------------------------------------27 instance-00000c37 running33 instance-00000cf0 running41 instance-00000e08 running45 instance-0000144d running54 instance-00000c0a running79 instance-00000ca5 running[root@compute30 ~]#
[root@compute30 ~]# docker exec nova_libvirt virsh domuuid 27
b99dc9e3-0d6b-4b3b-965a-d4e10791c4f0[root@compute30 ~]#
- 换一个容器查看时间继续测试
[root@compute30 ~]# docker exec nova_compute date
Thu Oct 12 17:40:38 CST 2023
[root@compute30 ~]#
这篇关于容器部署的openstack进入数据库流程、查看install目录流程、容器部署使用virsh命令流程【查看计算节点上的虚拟机信息】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!