目录

 

一.OenStack常用服务查看命令

OpenStack节点的开启与关闭

openstack查看命令

查看Nova计算服务的状态

查看Neutron网络服务的状态

查看glance镜像服务的状态

查看cinder块存储状态

 

二.OpenStack应用案例

创建项目租户账户

创建公用网络和租户网络

在租户处创建路由器

创建实例

实例的调试,配置安全组

远程连接实例

创建卷、挂载卷


一.OenStack常用服务查看命令

OpenStack节点的开启与关闭

  • 对于OpenStack各个来说当我们开启时,按照控制节点--网络节点---计算节点依次开启
  • 关闭OpenStack平台时,按照计算节点---网络节点---控制节点

openstack查看命令

  • 列出所有用户
[root@control ~(keystone_admin)]# openstack user list
+----------------------------------+------------+
| ID                               | Name       |
+----------------------------------+------------+
| 2ec8bfa9d5ae4bf0a685c76d13bc5c55 | cinder     |
| 6272383e96784f0d905dd8588d9e0137 | glance     |
| 6fe57873a03448a68a2c1035222c261d | placement  |
| 8e30ed231a6c44f7a369f83b665bc157 | admin      |
| 97b4623212204cdab381ce766c8fcd77 | neutron    |
| b2e53eae032048b0a78bd00155b96e8f | ceilometer |
| cc6e4ad1e14e49739f308fa999e78e50 | nova       |
| d6cf53f4c93f46c49f0568d3beb4bb75 | gnocchi    |
+----------------------------------+------------+
[root@control ~(keystone_admin)]#
  • 列出认证服务的目录
[root@control ~(keystone_admin)]# openstack catalog list
+------------+-----------+------------------------------------------------------------------------------+
| Name       | Type      | Endpoints                                                                    |
+------------+-----------+------------------------------------------------------------------------------+
| cinderv2   | volumev2  | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8776/v2/e162e666e0284d38b7dacdccaf09bd89     |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8776/v2/e162e666e0284d38b7dacdccaf09bd89      |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8776/v2/e162e666e0284d38b7dacdccaf09bd89   |
|            |           |                                                                              |
| neutron    | network   | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:9696                                          |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:9696                                       |
|            |           | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:9696                                         |
|            |           |                                                                              |
| keystone   | identity  | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:5000/v3                                      |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:5000/v3                                    |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:35357/v3                                      |
|            |           |                                                                              |
| gnocchi    | metric    | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8041                                       |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8041                                          |
|            |           | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8041                                         |
|            |           |                                                                              |
| cinderv3   | volumev3  | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8776/v3/e162e666e0284d38b7dacdccaf09bd89      |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8776/v3/e162e666e0284d38b7dacdccaf09bd89   |
|            |           | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8776/v3/e162e666e0284d38b7dacdccaf09bd89     |
|            |           |                                                                              |
| ceilometer | metering  | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8777                                       |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8777                                          |
|            |           | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8777                                         |
|            |           |                                                                              |
| placement  | placement | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8778/placement                             |
|            |           | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8778/placement                               |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8778/placement                                |
|            |           |                                                                              |
| nova       | compute   | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8774/v2.1/e162e666e0284d38b7dacdccaf09bd89   |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8774/v2.1/e162e666e0284d38b7dacdccaf09bd89 |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8774/v2.1/e162e666e0284d38b7dacdccaf09bd89    |
|            |           |                                                                              |
| glance     | image     | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:9292                                          |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:9292                                       |
|            |           | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:9292                                         |
|            |           |                                                                              |
| cinder     | volume    | RegionOne                                                                    |
|            |           |   public: http://192.168.100.10:8776/v1/e162e666e0284d38b7dacdccaf09bd89     |
|            |           | RegionOne                                                                    |
|            |           |   internal: http://192.168.100.10:8776/v1/e162e666e0284d38b7dacdccaf09bd89   |
|            |           | RegionOne                                                                    |
|            |           |   admin: http://192.168.100.10:8776/v1/e162e666e0284d38b7dacdccaf09bd89      |
|            |           |                                                                              |
+------------+-----------+------------------------------------------------------------------------------+
  • 列出所有的服务模块
[root@control ~(keystone_admin)]# openstack service list
+----------------------------------+------------+-----------+
| ID                               | Name       | Type      |
+----------------------------------+------------+-----------+
| 152b0a13a1f6443ba35785529ad6224f | cinderv2   | volumev2  |
| 270d59d9c6074a3fbe1ac1c853cbd536 | neutron    | network   |
| 4098c109756a4ca997befb382bbb26b3 | keystone   | identity  |
| 54223fd0080f4374b4a880140395bfd2 | gnocchi    | metric    |
| 72a129087e4e46238f43acb7204a8056 | cinderv3   | volumev3  |
| 88a17b45d5e1479fa9d31f903ce3d9de | ceilometer | metering  |
| 9ad6e8e9cf6541bebc855a0e27668f8b | placement  | placement |
| a696bed718b3490ba47f376c94da600b | nova       | compute   |
| ab25f3321f7b4dc8be8f70a734f1348b | glance     | image     |
| f47ac51cf885462e8b52e2d66694c077 | cinder     | volume    |
+----------------------------------+------------+-----------+
[root@control ~(keystone_admin)]#
  • 列出所有的域列表
[root@control ~(keystone_admin)]# openstack domain list
+---------+---------+---------+--------------------+
| ID      | Name    | Enabled | Description        |
+---------+---------+---------+--------------------+
| default | Default | True    | The default domain |
+---------+---------+---------+--------------------+
  • 列出所有节点
[root@control ~(keystone_admin)]# openstack host list
+-----------+-------------+----------+
| Host Name | Service     | Zone     |
+-----------+-------------+----------+
| control   | conductor   | internal |
| control   | scheduler   | internal |
| control   | consoleauth | internal |
| compute1  | compute     | nova     |
| compute2  | compute     | nova     |
+-----------+-------------+----------+
[root@control ~(keystone_admin)]#

查看Nova计算服务的状态

  • 通过命令查看具体nova服务状态,保证state在up状态
[root@control ~]# source keystonerc_admin 
您在 /var/spool/mail/root 中有新邮件
[root@control ~(keystone_admin)]# nova service-list
+--------------------------------------+------------------+----------+----------+---------+-------+----------------------------+-----------------+-------------+
| Id                                   | Binary           | Host     | Zone     | Status  | State | Updated_at                 | Disabled Reason | Forced down |
+--------------------------------------+------------------+----------+----------+---------+-------+----------------------------+-----------------+-------------+
| 6ed21f56-4dec-4549-b9a2-8ec08544df8d | nova-conductor   | control  | internal | enabled | up    | 2020-03-02T06:35:01.000000 | -               | False       |
| 745195aa-0316-4cc7-bf50-129ecf531a64 | nova-scheduler   | control  | internal | enabled | up    | 2020-03-02T06:35:05.000000 | -               | False       |
| 8840b835-dbfa-4805-b5e5-315e69141410 | nova-consoleauth | control  | internal | enabled | up    | 2020-03-02T06:35:01.000000 | -               | False       |
| 5e4dd4e7-abdb-4af1-a635-d14cf91fd28f | nova-compute     | compute1 | nova     | enabled | up    | 2020-03-02T06:35:04.000000 | -               | False       |
| 4f561ca9-69f2-42e3-b5fd-6a554245b602 | nova-compute     | compute2 | nova     | enabled | up    | 2020-03-02T06:35:04.000000 | -               | False       |
+--------------------------------------+------------------+----------+----------+---------+-------+----------------------------+-----------------+-------------+
[root@control ~(keystone_admin)]#

查看Neutron网络服务的状态

  • 查看所有节点的网络状态,保证alive在笑脸的状态
[root@control ~(keystone_admin)]# neutron agent-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+----------------------+----------+-------------------+-------+----------------+---------------------------+
| id                                   | agent_type           | host     | availability_zone | alive | admin_state_up | binary                    |
+--------------------------------------+----------------------+----------+-------------------+-------+----------------+---------------------------+
| 1f1d783b-36d9-4c9f-9ee0-84bec26fa940 | DHCP agent           | control  | nova              | :-)   | True           | neutron-dhcp-agent        |
| 3adadae5-d11e-4739-84d7-6288df62aa10 | Open vSwitch agent   | compute2 |                   | xxx   | True           | neutron-openvswitch-agent |
| 989fab33-11a3-4c9c-81d8-1161de4389a2 | Metering agent       | control  |                   | :-)   | True           | neutron-metering-agent    |
| 98c65413-5feb-484c-b932-35a9afe8fffa | Open vSwitch agent   | compute1 |                   | xxx   | True           | neutron-openvswitch-agent |
| c2eaf89f-e4d9-4490-9dc4-d2959c3b1275 | Open vSwitch agent   | control  |                   | xxx   | True           | neutron-openvswitch-agent |
| d0dfd994-3145-4427-b493-efa750959226 | Loadbalancerv2 agent | control  |                   | :-)   | True           | neutron-lbaasv2-agent     |
| eb0343c6-def1-46d3-b6db-64f7936141ea | Metadata agent       | control  |                   | :-)   | True           | neutron-metadata-agent    |
+--------------------------------------+----------------------+----------+-------------------+-------+----------------+---------------------------+
[root@control ~(keystone_admin)]#
  • 由于控制节点、计算节点的neutron-openvswitch-agent服务都没有开启起来
  • 所以我们分别在控制节点以及计算节点执行:systemctl start neutron-openvswitch-agent
[root@control ~(keystone_admin)]# neutron agent-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+----------------------+----------+-------------------+-------+----------------+---------------------------+
| id                                   | agent_type           | host     | availability_zone | alive | admin_state_up | binary                    |
+--------------------------------------+----------------------+----------+-------------------+-------+----------------+---------------------------+
| 1f1d783b-36d9-4c9f-9ee0-84bec26fa940 | DHCP agent           | control  | nova              | :-)   | True           | neutron-dhcp-agent        |
| 3adadae5-d11e-4739-84d7-6288df62aa10 | Open vSwitch agent   | compute2 |                   | :-)   | True           | neutron-openvswitch-agent |
| 989fab33-11a3-4c9c-81d8-1161de4389a2 | Metering agent       | control  |                   | :-)   | True           | neutron-metering-agent    |
| 98c65413-5feb-484c-b932-35a9afe8fffa | Open vSwitch agent   | compute1 |                   | :-)   | True           | neutron-openvswitch-agent |
| c2eaf89f-e4d9-4490-9dc4-d2959c3b1275 | Open vSwitch agent   | control  |                   | :-)   | True           | neutron-openvswitch-agent |
| d0dfd994-3145-4427-b493-efa750959226 | Loadbalancerv2 agent | control  |                   | :-)   | True           | neutron-lbaasv2-agent     |
| eb0343c6-def1-46d3-b6db-64f7936141ea | Metadata agent       | control  |                   | :-)   | True           | neutron-metadata-agent    |
+--------------------------------------+----------------------+----------+-------------------+-------+----------------+---------------------------+
[root@control ~(keystone_admin)]#

注:有可能服务会起不来,可以尝试重启节点,但是要等控制节点完全启动

查看glance镜像服务的状态

  • 查看镜像列表
[root@control ~(keystone_admin)]# glance image-list
+----+------+
| ID | Name |
+----+------+
+----+------+
[root@control ~(keystone_admin)]#

由于笔者没有上传镜像,所以列表没有

查看cinder块存储状态

  • 列出块存储的状态
[root@control ~(keystone_admin)]# cinder service-list
+------------------+-------------+------+---------+-------+----------------------------+-----------------+
| Binary           | Host        | Zone | Status  | State | Updated_at                 | Disabled Reason |
+------------------+-------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | control     | nova | enabled | up    | 2020-03-02T07:20:26.000000 | -               |
| cinder-volume    | control@lvm | nova | enabled | up    | 2020-03-02T07:20:29.000000 | -               |
+------------------+-------------+------+---------+-------+----------------------------+-----------------+
[root@control ~(keystone_admin)]#

二.OpenStack应用案例

创建项目租户账户

  • 一般在生产环境中用web界面创建用户,当然也可以使用命令创建用户

ip openstack 查询floating openstack查看服务命令_d3

ip openstack 查询floating openstack查看服务命令_3c_02

 

ip openstack 查询floating openstack查看服务命令_3c_03

  • 登录创建的租户

ip openstack 查询floating openstack查看服务命令_d3_04

创建公用网络和租户网络

  • 在管理员处创建公共网络

ip openstack 查询floating openstack查看服务命令_bc_05

ip openstack 查询floating openstack查看服务命令_3c_06

ip openstack 查询floating openstack查看服务命令_d3_07

ip openstack 查询floating openstack查看服务命令_d3_08

 

  • 在租户处创建租户网络

ip openstack 查询floating openstack查看服务命令_bc_09

ip openstack 查询floating openstack查看服务命令_d3_10

ip openstack 查询floating openstack查看服务命令_d3_11

ip openstack 查询floating openstack查看服务命令_bc_12

 

在租户处创建路由器

  • 创建路由器连接外网

ip openstack 查询floating openstack查看服务命令_bc_13

ip openstack 查询floating openstack查看服务命令_bc_14

  • 创建接口

ip openstack 查询floating openstack查看服务命令_3c_15

注:发生接口处一直处于down状态时,systemctl restart neutron-l3-agent

 

创建实例

  • 在管理员账户中添加镜像

ip openstack 查询floating openstack查看服务命令_bc_16

ip openstack 查询floating openstack查看服务命令_bc_17

##镜像文件可以在control节点中查看
[root@control ~(keystone_admin)]# cd /var/lib/glance/images
[root@control images(keystone_admin)]# ls
c10f83ec-7f9e-41f3-92ea-e27c20170d2e
[root@control images(keystone_admin)]#
  • 在管理员账户中创建实例类型

ip openstack 查询floating openstack查看服务命令_3c_18

ip openstack 查询floating openstack查看服务命令_bc_19


  • 在租户里创建实例

ip openstack 查询floating openstack查看服务命令_3c_20

ip openstack 查询floating openstack查看服务命令_3c_21

ip openstack 查询floating openstack查看服务命令_3c_22

  • 绑定浮动IP地址

ip openstack 查询floating openstack查看服务命令_d3_23

ip openstack 查询floating openstack查看服务命令_bc_24

 

实例的调试,配置安全组

  • 在租户账户里添加规则

ip openstack 查询floating openstack查看服务命令_bc_25

注:主机无法ping通浮动IP地址,解决重启neutron service

  • 修改实例文件,使之能够识别域名
$sudo passwd root
输入两次密码

$su - root

输入密码


#vi /etc/resolv.conf
nameserver 8.8.8.8

 

远程连接实例

  • 添加ssh规则

ip openstack 查询floating openstack查看服务命令_bc_26

 

创建卷、挂载卷

  • 在openstack界面创建卷

ip openstack 查询floating openstack查看服务命令_d3_27

ip openstack 查询floating openstack查看服务命令_3c_28

ip openstack 查询floating openstack查看服务命令_3c_29

  • 在命令界面挂载卷

ip openstack 查询floating openstack查看服务命令_d3_30

 

ip openstack 查询floating openstack查看服务命令_bc_31

ip openstack 查询floating openstack查看服务命令_d3_32

ip openstack 查询floating openstack查看服务命令_bc_33