zoukankan      html  css  js  c++  java
  • 4. 安装nova(控制节点)— OpenStack Queens 三节点部署

    本操作在控制节点上完成

    添加nova用户

    添加用户nova和placement

    root@controller ~(keystone)# openstack user create --domain default --project service --password root nova
    +---------------------+----------------------------------+
    | Field               | Value                            |
    +---------------------+----------------------------------+
    | default_project_id  | 2fae0cd7579441f88cab61f4291bfd17 |
    | domain_id           | default                          |
    | enabled             | True                             |
    | id                  | 4e97f0b2c83a4947bec7b83e5726f6b8 |
    | name                | nova                             |
    | options             | {}                               |
    | password_expires_at | None                             |
    +---------------------+----------------------------------+
    
    root@controller ~(keystone)# openstack user create --domain default --project service --password root placement
    +---------------------+----------------------------------+
    | Field               | Value                            |
    +---------------------+----------------------------------+
    | default_project_id  | 2fae0cd7579441f88cab61f4291bfd17 |
    | domain_id           | default                          |
    | enabled             | True                             |
    | id                  | 11897fb5b4ee4242aa8aecbc9d5507bd |
    | name                | placement                        |
    | options             | {}                               |
    | password_expires_at | None                             |
    +---------------------+----------------------------------+
    

    为两个用户添加管理员角色

    root@controller ~(keystone)# openstack role add --project service --user nova admin
    root@controller ~(keystone)# openstack role add --project service --user placement admin
    

    创建服务

    root@controller ~(keystone)# openstack service create --name nova --description "OpenStack Compute service" compute
    +-------------+----------------------------------+
    | Field       | Value                            |
    +-------------+----------------------------------+
    | description | OpenStack Compute service        |
    | enabled     | True                             |
    | id          | bffc78fabb9641828ab821a2256c932e |
    | name        | nova                             |
    | type        | compute                          |
    +-------------+----------------------------------+
    root@controller ~(keystone)# openstack service create --name placement --description "OpenStack Compute Placement service" placement
    +-------------+-------------------------------------+
    | Field       | Value                               |
    +-------------+-------------------------------------+
    | description | OpenStack Compute Placement service |
    | enabled     | True                                |
    | id          | ec08895d9c8a4b80a5114f57154671c2    |
    | name        | placement                           |
    | type        | placement                           |
    +-------------+-------------------------------------+
    

    创建nova服务endpoint(public,internal,admin)

    root@controller ~(keystone)# openstack endpoint create --region RegionOne compute public http://10.0.0.7:8774/v2.1/%(tenant_id)s
    +--------------+-----------------------------------------+
    | Field        | Value                                   |
    +--------------+-----------------------------------------+
    | enabled      | True                                    |
    | id           | fbdae26e0ef2468a9165a980a8dddde1        |
    | interface    | public                                  |
    | region       | RegionOne                               |
    | region_id    | RegionOne                               |
    | service_id   | bffc78fabb9641828ab821a2256c932e        |
    | service_name | nova                                    |
    | service_type | compute                                 |
    | url          | http://10.0.0.7:8774/v2.1/%(tenant_id)s |
    +--------------+-----------------------------------------+
    root@controller ~(keystone)# openstack endpoint create --region RegionOne compute internal http://10.0.0.7:8774/v2.1/%(tenant_id)s
    +--------------+-----------------------------------------+
    | Field        | Value                                   |
    +--------------+-----------------------------------------+
    | enabled      | True                                    |
    | id           | 8ef3ad37c8a642dfb97d07b37281a4bb        |
    | interface    | internal                                |
    | region       | RegionOne                               |
    | region_id    | RegionOne                               |
    | service_id   | bffc78fabb9641828ab821a2256c932e        |
    | service_name | nova                                    |
    | service_type | compute                                 |
    | url          | http://10.0.0.7:8774/v2.1/%(tenant_id)s |
    +--------------+-----------------------------------------+
    root@controller ~(keystone)# openstack endpoint create --region RegionOne compute admin http://10.0.0.7:8774/v2.1/%(tenant_id)s
    +--------------+-----------------------------------------+
    | Field        | Value                                   |
    +--------------+-----------------------------------------+
    | enabled      | True                                    |
    | id           | 616b11ee723c4715896e079801cb3d7f        |
    | interface    | admin                                   |
    | region       | RegionOne                               |
    | region_id    | RegionOne                               |
    | service_id   | bffc78fabb9641828ab821a2256c932e        |
    | service_name | nova                                    |
    | service_type | compute                                 |
    | url          | http://10.0.0.7:8774/v2.1/%(tenant_id)s |
    +--------------+-----------------------------------------+
    
    root@controller ~(keystone)# openstack endpoint create --region RegionOne placement public http://10.0.0.7:8778
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 5da1ee43641648c6a161ed39ffe2e84f |
    | interface    | public                           |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | ec08895d9c8a4b80a5114f57154671c2 |
    | service_name | placement                        |
    | service_type | placement                        |
    | url          | http://10.0.0.7:8778             |
    +--------------+----------------------------------+
    root@controller ~(keystone)# openstack endpoint create --region RegionOne placement internal http://10.0.0.7:8778
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 453f73d5a241472f89764084166afe4f |
    | interface    | internal                         |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | ec08895d9c8a4b80a5114f57154671c2 |
    | service_name | placement                        |
    | service_type | placement                        |
    | url          | http://10.0.0.7:8778             |
    +--------------+----------------------------------+
    root@controller ~(keystone)# openstack endpoint create --region RegionOne placement admin http://10.0.0.7:8778
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 03d6697290344054a0abb3b338544ffe |
    | interface    | admin                            |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | ec08895d9c8a4b80a5114f57154671c2 |
    | service_name | placement                        |
    | service_type | placement                        |
    | url          | http://10.0.0.7:8778             |
    +--------------+----------------------------------+
    

    为nova添加数据库

    root@controller ~(keystone)# mysql
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 78
    Server version: 10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
    
    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)]> create database nova;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova.* to nova@'localhost' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova.* to nova@'%' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> create database nova_api;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova_api.* to nova@'localhost' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova_api.* to nova@'%' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> create database nova_placement;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova_placement.* to nova@'localhost' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova_placement.* to nova@'%' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> create database nova_cell0;
    Query OK, 1 row affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova_cell0.* to nova@'localhost' identified by 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> grant all privileges on nova_cell0.* to nova@'%' identified by'root';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [(none)]> exit
    Bye
    

    安装配置nova

    安装nova服务软件包

    root@controller ~(keystone)# apt -y install nova-api nova-placement-api nova-conductor nova-consoleauth nova-scheduler nova-novncproxy python-novaclient
    

    配置nova,由于官方配置文件修改较为麻烦,这里直接创建一个新的配置文件

    root@controller ~(keystone)# mv /etc/nova/nova.conf /etc/nova/nova.conf.org
    root@controller ~(keystone)# vi /etc/nova/nova.conf
    
    # 添加以下内容,保存退出
    [DEFAULT]
    # 设置控制节点IP
    my_ip = 10.0.0.7
    state_path = /var/lib/nova
    enabled_apis = osapi_compute,metadata
    log_dir = /var/log/nova
    transport_url = rabbit://openstack:root@controller
    
    [api]
    auth_strategy = keystone
    
    [glance]
    api_servers = http://controller:9292
    
    [oslo_concurrency]
    lock_path = $state_path/tmp
    
    [api_database]
    connection = mysql+pymysql://nova:root@controller/nova_api
    
    [database]
    connection = mysql+pymysql://nova:root@controller/nova
    
    [keystone_authtoken]
    auth_uri = http://controller:5000
    auth_url = http://controller:5000
    memcached_servers = controller:11211
    auth_type = password
    project_domain_name = default
    user_domain_name = default
    project_name = service
    username = nova
    password = root
    
    [placement]
    auth_url = http://controller:5000
    os_region_name = RegionOne
    auth_type = password
    project_domain_name = default
    user_domain_name = default
    project_name = service
    username = placement
    password = root
    
    [placement_database]
    connection = mysql+pymysql://nova:root@controller/nova_placement
    
    [wsgi]
    api_paste_config = /etc/nova/api-paste.ini
    

    因为配置文件是新建的,这里把权限加回去

    root@controller ~(keystone)# chmod 640 /etc/nova/nova.conf
    root@controller ~(keystone)# chgrp nova /etc/nova/nova.conf
    

    初始化数据库

    可能耗时比较长

    root@controller:~(keystone)# su -s /bin/bash nova -c "nova-manage api_db sync"
    root@controller:~(keystone)# su -s /bin/bash nova -c "nova-manage cell_v2 map_cell0"
    root@controller:~(keystone)# su -s /bin/bash nova -c "nova-manage db sync"
    root@controller:~(keystone)# su -s /bin/bash nova -c "nova-manage cell_v2 create_cell --name cell1"
    

    重启apache2服务

    root@controller ~(keystone)# systemctl restart apache2
    

    重启nova相关服务

    root@controller ~(keystone)# systemctl restart nova-api
    root@controller ~(keystone)# systemctl restart nova-conductor
    root@controller ~(keystone)# systemctl restart nova-scheduler
    root@controller ~(keystone)# systemctl restart nova-consoleauth
    root@controller ~(keystone)# systemctl restart nova-novncproxy
    

    查看nova服务状态

    root@controller ~(keystone)# openstack compute service list
    +----+------------------+------------+----------+---------+-------+----------------------------+
    | ID | Binary           | Host       | Zone     | Status  | State | Updated At                 |
    +----+------------------+------------+----------+---------+-------+----------------------------+
    |  3 | nova-conductor   | controller | internal | enabled | up    | 2020-04-26T06:57:15.000000 |
    |  4 | nova-scheduler   | controller | internal | enabled | up    | 2020-04-26T06:57:16.000000 |
    |  5 | nova-consoleauth | controller | internal | enabled | up    | 2020-04-26T06:57:13.000000 |
    +----+------------------+------------+----------+---------+-------+----------------------------+
    

    参考

  • 相关阅读:
    多线程22:线程池
    多线程21:信号灯法
    多线程20:管程法
    多线程19:生产者消费者模式
    多线程18:Lock锁
    多线程17:死锁
    多线程16:CopyOnWriteArrayList
    多线程15:线程同步
    多线程14:三大不安全案例
    业余草 maven异常:Updating Maven Project 的统一解决方案
  • 原文地址:https://www.cnblogs.com/zhaoyixin96/p/openstack-queens-4.html
Copyright © 2011-2022 走看看