openstack计算服务
一、安装配置控制节点
基础配置: 控制节点 controller 192.168.197.154
计算节点 compute01 192.168.197.155
所有密码 设为:Ccu2021
先决条件
在安装和配置放置服务之前,您必须创建数据库、服务凭据和 API 端点。
创建数据库
1、要创建数据库,需要完成以下步骤:
-
使用数据库访问客户端作为用户连接到数据库服务器:
root
$ mysql -u root -p
-
创建和数据库:
nova_api``nova``nova_cell0``placement
CREATE DATABASE nova_api; CREATE DATABASE nova; CREATE DATABASE nova_cell0; CREATE DATABASE placement;
-
允许正确访问数据库:
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'Ccu2021'; GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'Ccu2021';
-
查看创建的数据库:
SHOW DATABASES;
结果: MariaDB [(none)]> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | glance | | information_schema | | keystone | | mysql | | nova | | nova_api | | nova_ce110 | | performance_schema | | placement | | test | +--------------------+
2、source 执行 admin-openrc.sh 文件
$ source admin-openrc.sh
3、创建计算服务凭证:
-
创建用户:nova
$ openstack user create --domain default --password-prompt nova
结果: User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | e7f23c16e6254c788f83adce314be503 | | name | nova | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
-
创建用户:placement
$ openstack user create --domain default --password-prompt placement
结果: User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 397e5fe2feff4326a5c06092842c1a31 | | name | placement | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
-
将 nova 用户添加到具有 admin 角色的服务项目
$ openstack role add --project service --user nova admin
-
将 placement 用户添加到具有 admin 角色的服务项目
$ openstack role add --project service --user placement admin
-
创建服务实体:nova
$ openstack service create --name nova --description "OpenStack Compute" compute
-
创建服务实体:placement
$ openstack service create --name placement --description "Placement API" placement
4、创建Compute API 服务端点:
$ openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
结果: +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 32c855bb7cbe46b3adfd7219bb9b2f8c | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | cfd6d2d8976b468a839311e638638c24 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+
$ openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
结果: +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 50a2a2e9256f48008b7a11890f3cfe5b | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | cfd6d2d8976b468a839311e638638c24 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+
$ openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1
结果: +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 80698907f9f1432b8a3f70bc8e7ae7d2 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | cfd6d2d8976b468a839311e638638c24 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+
5、创建Placement API 服务端点:
$ openstack endpoint create --region RegionOne placement public http://controller:8778
结果: +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 4890b36b5e144a779d341851bf9ca68f | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 653620ddad074e7bb7a9af698ac6a945 | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+
$ openstack endpoint create --region RegionOne placement internal http://controller:8778
结果: +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 114bf7945bbe422185de7132bad761bf | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 653620ddad074e7bb7a9af698ac6a945 | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+
$ openstack endpoint create --region RegionOne placement admin http://controller:8778
结果: +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | af3e8acc247d42ce93356d2721bfec36 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 653620ddad074e7bb7a9af698ac6a945 | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+
安装和配置组件
1、安装包
$ yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y $ yum install openstack-placement-api -y
2、编辑文件并完成以下操作:/etc/nova/nova.conf
-
在该节中,仅启用计算和元数据 API:[DEFAULT]
[DEFAULT] enabled_apis = osapi_compute,metadata
-
在[api_database]和[database]部分,配置数据库访问:
[api_database] connection = mysql+pymysql://nova:Ccu2021@controller/nova_api ....... [database] connection = mysql+pymysql://nova:Ccu2021@controller/nova
-
在该[DEFAULT]部分,配置RabbitMQ消息队列访问:
[DEFAULT] ........ transport_url = rabbit://openstack:Ccu2021@controller:5672/
-
在[api_database]和[database]部分,配置数据库访问:
[api] auth_strategy = keystone ....... [keystone_authtoken] www_authenticate_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 = Ccu2021
-
在该[DEFAULT]部分中,配置my_ip选项以使用控制器节点的管理接口 IP 地址:
[DEFAULT] ....... my_ip = 127.0.0.1
-
在该[vnc]部分中,将 VNC 代理配置为使用控制器节点的管理接口 IP 地址:
[vnc] enabled = true server_listen = $my_ip server_proxyclient_address = $my_ip
-
在该[glance]部分中,配置 Image 服务 API 的位置:
[glance] api_servers = http://controller:9292
-
在该[oslo_concurrency]部分中,配置lock_path:
[oslo_concurrency] lock_path = /var/lib/nova/tmp
-
在[placement]部分中,配置对 Placement 服务的访问:
[placement] region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:5000/v3 username = placement password = Ccu2021
3、编辑/etc/placement/placement.conf文件并完成以下操作:
-
在该[placement_database]部分中,配置数据库访问:
[placement_database] connection = mysql+pymysql://placement:Ccu2021@controller/placement
-
在[api]和[keystone_authtoken]部分,配置身份服务访问:
[api] auth_strategy = keystone ....... [keystone_authtoken] auth_url = http://controller:5000/v3 memcached_servers = controller:11211 auth_type = password project_domain_name = Default user_domain_name = Default project_name = service username = placement password = Ccu2021
4、填充nova-api数据库:
$ /bin/sh -c "placement-manage db sync" placement
....................................忽略输出信息...................................... ***可复制标签查看日志查看进度......... $ tail -f /var/log/nova-manage.log
5、填充placement数据库:
$ /bin/sh -c "placement-manage db sync" placement
6、注册cell0数据库:
$ /bin/sh -c "nova-manage cell_v2 map_cell0" nova
7、创建cell1单元格:
$ /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
8、填充 nova 数据库:
$ /bin/sh -c "nova-manage db sync" nova
9、验证 nova cell0 和 cell1 是否正确注册:
$ /bin/sh -c "nova-manage cell_v2 list_cells" nova
完成安装
-
重启httpd服务:
$ systemctl restart httpd
-
启动 Compute 服务并将它们配置为在系统启动时启动:
$ systemctl enable \ openstack-nova-api.service \ openstack-nova-scheduler.service \ openstack-nova-conductor.service \ openstack-nova-novncproxy.service $ systemctl start \ openstack-nova-api.service \ openstack-nova-scheduler.service \ openstack-nova-conductor.service \ openstack-nova-novncproxy.service