首页 > 代码库 > 云计算之openstack-newton版搭建(五)

云计算之openstack-newton版搭建(五)

本章讲解以下计算服务(nova)的安装及配置。

一、安装和配置控制器节点

1.配置数据库

# mysql -u root -p123456
mysql> CREATE DATABASE nova_api;
mysql> CREATE DATABASE nova;
mysql> GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova‘@‘localhost‘   IDENTIFIED BY ‘NOVA_DBPASS‘;
mysql> GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova‘@‘%‘   IDENTIFIED BY ‘NOVA_DBPASS‘;
mysql> GRANT ALL PRIVILEGES ON nova.* TO ‘nova‘@‘localhost‘   IDENTIFIED BY ‘NOVA_DBPASS‘;
mysql> GRANT ALL PRIVILEGES ON nova.* TO ‘nova‘@‘%‘   IDENTIFIED BY ‘NOVA_DBPASS‘;

2.获取admin权限

# . admin-openrc

3.创建服务

 创建nova用户

# openstack user create --domain default   --password-prompt nova
[root@controller ~]# openstack user create --domain default >   --password-prompt nova
User Password:123456
Repeat User Password:123456
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 95fafc9a5ef04d4b8a479ff14e03434e |
| name                | nova                             |
| password_expires_at | None                             |
+---------------------+----------------------------------+

 将admin角色添加到nova用户

# openstack role add --project service --user nova admin
[root@controller ~]# openstack role add --project service --user nova admin
此命令没有输出

 创建nova服务实体

# openstack service create --name nova   --description "OpenStack Compute" compute
[root@controller ~]# openstack service create --name nova >   --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled     | True                             |
| id          | 86d7334a360b49d2a02d50f17e38dd96 |
| name        | nova                             |
| type        | compute                          |
+-------------+----------------------------------+

4.创建API

# openstack endpoint create --region RegionOne \ 
 compute public http://controller:8774/v2.1/%\(tenant_id\)s
# openstack endpoint create --region RegionOne   compute public http://controller:8774/v2.1/%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne >   compute public http://controller:8774/v2.1/%\(tenant_id\)s
+--------------+-------------------------------------------+
| Field        | Value                                     |
+--------------+-------------------------------------------+
| enabled      | True                                      |
| id           | 0e70c90b242e40758adb76e92c6154f4          |
| interface    | public                                    |
| region       | RegionOne                                 |
| region_id    | RegionOne                                 |
| service_id   | 86d7334a360b49d2a02d50f17e38dd96          |
| service_name | nova                                      |
| service_type | compute                                   |
| url          | http://controller:8774/v2.1/%(tenant_id)s |
+--------------+-------------------------------------------+
# openstack endpoint create --region RegionOne   compute internal http://controller:8774/v2.1/%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne >   compute internal http://controller:8774/v2.1/%\(tenant_id\)s
+--------------+-------------------------------------------+
| Field        | Value                                     |
+--------------+-------------------------------------------+
| enabled      | True                                      |
| id           | 04c55a4055754c19855235b8e6f3fab3          |
| interface    | internal                                  |
| region       | RegionOne                                 |
| region_id    | RegionOne                                 |
| service_id   | 86d7334a360b49d2a02d50f17e38dd96          |
| service_name | nova                                      |
| service_type | compute                                   |
| url          | http://controller:8774/v2.1/%(tenant_id)s |
+--------------+-------------------------------------------+
# openstack endpoint create --region RegionOne   compute admin http://controller:8774/v2.1/%\(tenant_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne >   compute admin http://controller:8774/v2.1/%\(tenant_id\)s
+--------------+-------------------------------------------+
| Field        | Value                                     |
+--------------+-------------------------------------------+
| enabled      | True                                      |
| id           | 3f289ddab3d540dc8be4e6b918f605f1          |
| interface    | admin                                     |
| region       | RegionOne                                 |
| region_id    | RegionOne                                 |
| service_id   | 86d7334a360b49d2a02d50f17e38dd96          |
| service_name | nova                                      |
| service_type | compute                                   |
| url          | http://controller:8774/v2.1/%(tenant_id)s |
+--------------+-------------------------------------------+

5.安装软件包

# yum install openstack-nova-api openstack-nova-conductor   openstack-nova-console openstack-nova-novncproxy   openstack-nova-scheduler -y

6.编辑/etc/nova/nova.conf

[root@controller ~]# cd /etc/nova/
[root@controller nova]# cp nova.conf nova.conf.bak
[root@controller nova]# egrep -v "^$|^#" nova.conf.bak > nova.conf
[root@controller nova]# vim nova.conf
添加如下内容
[DEFAULT]
...
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
my_ip = 192.168.23.98
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
...
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api

[database]
...
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = 123456
[vnc]
...
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
[glance]
...
api_servers = http://controller:9292
[oslo_concurrency]
...
lock_path = /var/lib/nova/tmp

7.导入数据库

# su -s /bin/sh -c "nova-manage api_db sync" nova
# su -s /bin/sh -c "nova-manage db sync" nova
忽略此输出的任何弃用消息

8.开启服务

# systemctl enable openstack-nova-api.service   openstack-nova-consoleauth.service openstack-nova-scheduler.service \  
  openstack-nova-conductor.service openstack-nova-novncproxy.service
# systemctl start openstack-nova-api.service   openstack-nova-consoleauth.service openstack-nova-scheduler.service \  
  openstack-nova-conductor.service openstack-nova-novncproxy.service

8.验证

[root@controller ~]# nova service-list
+----+------------------+----------------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary           | Host                 | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+----+------------------+----------------------+----------+---------+-------+----------------------------+-----------------+
| 1  | nova-conductor   | controller.novalocal | internal | enabled | up    | 2017-01-12T02:41:48.000000 | -               |
| 2  | nova-consoleauth | controller.novalocal | internal | enabled | up    | 2017-01-12T02:41:48.000000 | -               |
| 3  | nova-scheduler   | controller.novalocal | internal | enabled | up    | 2017-01-12T02:41:48.000000 | -               |
+----+------------------+----------------------+----------+---------+-------+----------------------------+-----------------+
[root@controller ~]#


本文出自 “linux运维” 博客,请务必保留此出处http://lijiawang.blog.51cto.com/10156897/1891266

云计算之openstack-newton版搭建(五)