四,openstack之nova服务的安装(控制节点)
目录
openstack之nova服务的安装(控制节点)
一,naval服务的组成简介
nova是openstack的核心服务,由naval服务来创建云主机
nova服务由一下几部分构成:
nova-api
服务:接收和响应来自最终用户的计算API请求,管理虚拟主机的生命周期。- nova-compute服务(多个):真正管理虚拟机实例的
- nova-scheduler服务:nova的调度器(挑选最合适的nava-compute来创建虚机)
- nova-conductor模块:帮助nava-compute代理修改数据库中虚拟机的状态
- nova-network模块:管理虚拟机网络的服务(当前已废弃,新版本为neutron)
nova-consoleauth
和nova-novncproxy
守护进程:web版的vnc来直接操作云主机nova-novncproxy
:web版的vnc客户端nova-api-metadata
服务:接受来自虚拟机发送的元数据请求。(配合neutron-metadata-agent,来实现虚拟机定制化)
二,nova服务的安装部署
控制节点主要安装nova-api(nova主服务)、nova-scheduler(nova调度服务)、nova-conductor(nova数据库服务,提供数据库访问)、nova-novncproxy(nova的vnc服务,提供实例的控制台)等服务;
1,openstack安装服务的通用步骤
1,创库授权
2,在keystone创建用户,关联角色
3,在keystone上创建服务,注册api
4,安装服务相关的软件包
5,修改配置
- 数据库的连接
- keystone的认证授权信息
- rabbitmq的连接信息
- 其他服务的连接配置
6,同步数据库,创建表
7,启动服务
2,创建naval数据库并授权:
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> CREATE DATABASE nova_cell0;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> exit;
3,创建nava服务和nova用户并角色授权
source admin-openrc
#注册nova服务
openstack user create --domain default --password NOVA_PASS nova
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 09b5d577e2624e62b0266e7cacdcbb8a |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
#向nova用户添加admin角色
openstack role add --project service --user nova admin
#创建nova服务实体
openstack service create --name nova --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | 7404b7bb8cb446198e6d7347ad2f374f |
| name | nova |
| type | compute |
+-------------+----------------------------------+
4,注册Compute 服务的API
#注册公共使用的API
openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | ee36c168ff544bc1af328ac8e65914ec |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7404b7bb8cb446198e6d7347ad2f374f |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
+--------------+----------------------------------+
#注册内部使用的API
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | e801c62e83cb4fb981b9d74eef41fd2e |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7404b7bb8cb446198e6d7347ad2f374f |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
+--------------+----------------------------------+
#注册管理员使用API
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 84629843047d41cea736b33282a7e719 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7404b7bb8cb446198e6d7347ad2f374f |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
+--------------+----------------------------------+
5,安装nova相关软件包
yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y
6,修改nova相关配置文件
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
grep -Ev '^$|#' /etc/nova/nova.conf.bak >/etc/nova/nova.conf #备份原始配置文件
vim /etc/nova/nova.conf
#在[DEFAULT]加入:
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:RABBIT_PASS@controller:5672/
my_ip = 172.27.1.243
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
#在[api_database]和[database]加入:
[api_database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api
[database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova
#在[api]和[keystone_authtoken]加入:
[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 = NOVA_PASS
#在[vnc]加入:
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
#在[glance]加入:
[glance]
api_servers = http://controller:9292
#在[oslo_concurrency]加入:
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
#在[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 = PLACEMENT_PASS
# ps:修改的地方较多,请细心修改。
7,填充nova-api数据库
su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
a479dc3e-3505-4421-905e-22ef3a0acf4a
su -s /bin/sh -c "nova-manage db sync" nova
#验证nova cell 0 和cell1是否正确注册:
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
| Name | UUID | Transport URL | Database Connection | Disabled |
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
| cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@controller/nova_cell0 | False |
| cell1 | a479dc3e-3505-4421-905e-22ef3a0acf4a | rabbit://openstack:****@controller:5672/ | mysql+pymysql://nova:****@controller/nova | False |
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
8,启动计算服务nova并将其配置为在系统启动时启动
#设置nova相关服务开机自动启动
systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
#启动nova相关服务
systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
#使用netstat -tnlup查看端口情况,如出现8774和8775端口则表示nova服务正常启动。
#通过curl http://controller:8774访问nova服务
[root@controller ~]# curl http://controller:8774
{"versions": [{"status": "SUPPORTED", "updated": "2011-01-21T11:33:21Z", "links": [{"href": "http://controller:8774/v2/", "rel": "self"}], "min_version": "", "version": "", "id": "v2.0"}, {"status": "CURRENT", "updated": "2013-07-23T11:33:21Z", "links": [{"href": "http://controller:8774/v2.1/", "rel": "self"}], "min_version": "2.1", "version": "2.79", "id": "v2.1"}]}