OpenStack(Queens)详细安装部署(四)-计算服务(nova)安装
OpenStack(Queens)详细安装部署(四)-计算服务(nova)安装 原创: 扶艾 码农这些事儿 5月1日 本文为扶艾原创文章,版权所有,禁止转载!
本篇文章是本系列的第四篇文章,将继续进行OpenStack计算服务的安装 五、安装计算服务
5.1 (控制节点)配置数据库 - 连接数据库
1# mysql -u root -pfuai123
创建nova相关数据库并设置访问权限
1MariaDB [(none)]> CREATE DATABASE nova_api; 2MariaDB [(none)]> CREATE DATABASE nova; 3MariaDB [(none)]> CREATE DATABASE nova_cell0; 4 5 6MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \ 7 IDENTIFIED BY 'fuai123'; 8MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \ 9 IDENTIFIED BY 'fuai123';
10 11MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \ 12 IDENTIFIED BY 'fuai123'; 13MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \ 14 IDENTIFIED BY 'fuai123'; 15 16MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \ 17 IDENTIFIED BY 'fuai123'; 18MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \ 19 IDENTIFIED BY 'fuai123';
5.2 (控制节点)创建nova认证相关信息 - 设置admin环境变量
1# . admin-openrc
创建nova用户
密码我设置的fuai123
1# openstack user create --domain default --password-prompt nova 2 3User Password: 4Repeat User Password: 5+---------------------+----------------------------------+ 6| Field | Value | 7+---------------------+----------------------------------+ 8| domain_id | default | 9| enabled | True |
10| id | 1cde1ce579c241a5906684adba106d93 | 11| name | nova | 12| options | {} | 13| password_expires_at | None | 14+---------------------+----------------------------------+
给nova用户添加admin角色
1# openstack role add --project service --user nova admin
创建nova服务
1# openstack service create --name nova \ 2 --description "OpenStack Compute" compute 3 4+-------------+----------------------------------+ 5| Field | Value | 6+-------------+----------------------------------+ 7| description | OpenStack Compute | 8| enabled | True | 9| id | 01ffdb12a467441a94d0f3aba7b85136 |
10| name | nova | 11| type | compute | 12+-------------+----------------------------------+
创建计算api端口
1# openstack endpoint create --region RegionOne \ 2 compute public http://controller:8774/v2.1 3 4+--------------+----------------------------------+ 5| Field | Value | 6+--------------+----------------------------------+ 7| enabled | True | 8| id | 88c9171ba5ee481c9031f59c18e72d8e | 9| interface | public |
10| region | RegionOne | 11| region_id | RegionOne | 12| service_id | 01ffdb12a467441a94d0f3aba7b85136 | 13| service_name | nova | 14| service_type | compute | 15| url | http://controller:8774/v2.1 | 16+--------------+----------------------------------+ 17 18# openstack endpoint create --region RegionOne \ 19 compute internal http://controller:8774/v2.1 20 21+--------------+----------------------------------+ 22| Field | Value | 23+--------------+----------------------------------+ 24| enabled | True | 25| id | 53121a04b0f14da69a13dcb8323c0304 | 26| interface | internal | 27| region | RegionOne | 28| region_id | RegionOne | 29| service_id | 01ffdb12a467441a94d0f3aba7b85136 | 30| service_name | nova | 31| service_type | compute | 32| url | http://controller:8774/v2.1 | 33+--------------+----------------------------------+ 34 35# openstack endpoint create --region RegionOne \ 36 compute admin http://controller:8774/v2.1 37 38+--------------+----------------------------------+ 39| Field | Value | 40+--------------+----------------------------------+ 41| enabled | True | 42| id | 31e7047e34104204aeddca406a534b81 | 43| interface | admin | 44| region | RegionOne | 45| region_id | RegionOne | 46| service_id | 01ffdb12a467441a94d0f3aba7b85136 | 47| service_name | nova | 48| service_type | compute | 49| url | http://controller:8774/v2.1 | 50+--------------+----------------------------------+ 51
创建placement服务用户
密码我设置的fuai123
1# openstack user create --domain default --password-prompt placement 2 3+---------------------+----------------------------------+ 4| Field | Value | 5+---------------------+----------------------------------+ 6| domain_id | default | 7| enabled | True | 8| id | cef9b0bd33a14f20b375f864f148822f | 9| name | placement |
10| options | {} | 11| password_expires_at | None | 12+---------------------+----------------------------------+
添加placement用户到服务项目
1# openstack role add --project service --user placement admin
创建placement api服务
1# openstack service create --name placement --description "Placement API" placement 2 3+-------------+----------------------------------+ 4| Field | Value | 5+-------------+----------------------------------+ 6| description | Placement API | 7| enabled | True | 8| id | 4822cd7e915a4470aeecbc24643a5ee8 | 9| name | placement |
10| type | placement | 11+-------------+----------------------------------+
创建placement api服务端口
1# openstack endpoint create --region RegionOne placement public http://controller:8778 2 3+--------------+----------------------------------+ 4| Field | Value | 5+--------------+----------------------------------+ 6| enabled | True | 7| id | 848bc5a3161a4de88cc3ac77964487ad | 8| interface | public | 9| region | RegionOne |
10| region_id | RegionOne | 11| service_id | 4822cd7e915a4470aeecbc24643a5ee8 | 12| service_name | placement | 13| service_type | placement | 14| url | http://controller:8778 | 15+--------------+----------------------------------+ 16 17# openstack endpoint create --region RegionOne placement internal http://controller:8778 18 19+--------------+----------------------------------+ 20| Field | Value | 21+--------------+----------------------------------+ 22| enabled | True | 23| id | fe72f5f0207840c6a05a836955179941 | 24| interface | internal | 25| region | RegionOne | 26| region_id | RegionOne | 27| service_id | 4822cd7e915a4470aeecbc24643a5ee8 | 28| service_name | placement | 29| service_type | placement | 30| url | http://controller:8778 | 31+--------------+----------------------------------+ 32 33# openstack endpoint create --region RegionOne placement admin http://controller:8778 34 35+--------------+----------------------------------+ 36| Field | Value | 37+--------------+----------------------------------+ 38| enabled | True | 39| id | 13fc18d3fe6a422c8e0008522ae9c617 | 40| interface | admin | 41| region | RegionOne | 42| region_id | RegionOne | 43| service_id | 4822cd7e915a4470aeecbc24643a5ee8 | 44| service_name | placement | 45| service_type | placement | 46| url | http://controller:8778 | 47+--------------+----------------------------------+ 48
5.3 (控制节点)安装软件包并配置组件
安装软件包
1# yum install openstack-nova-api openstack-nova-conductor \ 2 openstack-nova-console openstack-nova-novncproxy \ 3 openstack-nova-scheduler openstack-nova-placement-api -y
编辑/etc/nova/nova.conf文件并完成以下配置
1[DEFAULT] 2enabled_apis = osapi_compute,metadata 3transport_url = rabbit://openstack:fuai123@controller 4my_ip = 192.168.0.77 5use_neutron = True 6firewall_driver = nova.virt.firewall.NoopFirewallDriver 7... 8 9[api_database]
10connection = mysql+pymysql://nova:fuai123@controller/nova_api 11... 12 13[database] 14connection = mysql+pymysql://nova:fuai123@controller/nova 15... 16 17[api] 18auth_strategy = keystone 19... 20 21[keystone_authtoken] 22auth_uri = http://controller:5000 23auth_url = http://controller:35357 24memcached_servers = controller:11211 25auth_type = password 26project_domain_name = default 27user_domain_name = default 28project_name = service 29username = nova 30password = fuai123 31... 32 33[vnc] 34enabled = true 35server_listen = $my_ip 36server_proxyclient_address = $my_ip 37... 38 39[glance] 40api_servers = http://controller:9292 41... 42 43[oslo_concurrency] 44lock_path = /var/lib/nova/tmp 45... 46 47[placement] 48os_region_name = RegionOne 49project_domain_name = Default 50project_name = service 51auth_type = password 52user_domain_name = Default 53auth_url = http://controller:35357/v3 54username = placement 55password = fuai123 56...
因为软件包的bug,编辑/etc/httpd/conf.d/00-nova-placement-api.conf文件增加如下内容
1<Directory /usr/bin> 2 <IfVersion >= 2.4> 3 Require all granted 4 </IfVersion> 5 <IfVersion < 2.4> 6 Order allow,deny 7 Allow from all 8 </IfVersion> 9</Directory>
重启httpd服务
1# systemctl restart httpd
导入相关数据库表结构
1# su -s /bin/sh -c "nova-manage api_db sync" nova 2# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova 3# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova 4 5c354ac0-a088-4dbb-b106-e795ebeaec32 6 7# su -s /bin/sh -c "nova-manage db sync" nova
验证cell0和cell1是否成功注册
1list_cells
2
3+-------+--------------------------------------+------------------------------------+-------------------------------------------------+
4| 名称 | UUID | Transport URL | 数据库连接 |
5+-------+--------------------------------------+------------------------------------+-------------------------------------------------+
6| cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@controller/nova_cell0 |
7| cell1 | fc354ac0-a088-4dbb-b106-e795ebeaec32 | rabbit://openstack:****@controller | mysql+pymysql://nova:****@controller/nova |
8+-------+--------------------------------------+------------------------------------+-------------------------------------------------+
设置服务的开机自启动,并启动服务
1# systemctl enable openstack-nova-api.service \ 2 openstack-nova-consoleauth.service openstack-nova-scheduler.service \ 3 openstack-nova-conductor.service openstack-nova-novncproxy.service 4# systemctl start openstack-nova-api.service \ 5 openstack-nova-consoleauth.service openstack-nova-scheduler.service \ 6 openstack-nova-conductor.service openstack-nova-novncproxy.service
5.4 (计算节点)在计算节点安装计算服务
安装软件包
1# yum install openstack-nova-compute -y
编辑/etc/nova/nova.conf文件并设置如下内容
1[DEFAULT] 2enabled_apis = osapi_compute,metadata 3transport_url = rabbit://openstack:fuai123@controller 4my_ip = 192.168.0.78 5use_neutron = True 6firewall_driver = nova.virt.firewall.NoopFirewallDriver 7... 8 9[api]
10auth_strategy = keystone 11... 12 13[keystone_authtoken] 14auth_uri = http://controller:5000 15auth_url = http://controller:35357 16memcached_servers = controller:11211 17auth_type = password 18project_domain_name = default 19user_domain_name = default 20project_name = service 21username = nova 22password = fuai123 23... 24 25[vnc] 26enabled = True 27server_listen = 0.0.0.0 28server_proxyclient_address = $my_ip 29novncproxy_base_url = http://192.168.0.77:6080/vnc_auto.html 30... 31 32[glance] 33api_servers = http://controller:9292 34... 35 36[oslo_concurrency] 37lock_path = /var/lib/nova/tmp 38... 39 40[placement] 41os_region_name = RegionOne 42project_domain_name = Default 43project_name = service 44auth_type = password 45user_domain_name = Default 46auth_url = http://controller:35357/v3 47username = placement 48password = fuai123 49...
检测当前计算节点是否支持硬件虚拟化
我使用的虚拟机,这里返回0,明显我不支持硬件虚拟化
1# egrep -c '(vmx|svm)' /proc/cpuinfo 20
编辑/etc/nova/nova.conf文件设置qemu来提供软件虚拟化
1[libvirt] 2virt_type = qemu 3...
设置服务的开机自启动,并启动计算服务
1# systemctl enable libvirtd.service openstack-nova-compute.service 2# systemctl start libvirtd.service openstack-nova-compute.service
5.5 (控制节点)向cell数据库添加计算节点 - 添加admin环境变量
1# . admin-openrc
执行下面的命令,查看计算节点信息是否已经在数据库
1# openstack compute service list --service nova-compute 2 3+----+--------------+---------+------+---------+-------+----------------------------+ 4| ID | Binary | Host | Zone | Status | State | Updated At | 5+----+--------------+---------+------+---------+-------+----------------------------+ 6| 6 | nova-compute | compute | nova | enabled | up | 2018-04-26T12:00:40.000000 | 7+----+--------------+---------+------+---------+-------+----------------------------+
发现计算节点
1# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova 2 3Found 2 cell mappings. 4Skipping cell0 since it does not contain hosts. 5Getting computes from cell 'cell1': fc354ac0-a088-4dbb-b106-e795ebeaec32 6Checking host mapping for compute host 'compute': 47b0f376-fa1a-4fe8-9f2e-af1be125781a 7Creating host mapping for compute host 'compute': 47b0f376-fa1a-4fe8-9f2e-af1be125781a 8Found 1 unmapped computes in cell: fc354ac0-a088-4dbb-b106-e795ebeaec32
5.6 (控制节点)验证操作 - 添加admin环境变量
1# . admin-openrc
列出计算服务的运行状态
1# openstack compute service list 2 3+----+------------------+------------+----------+---------+-------+----------------------------+ 4| ID | Binary | Host | Zone | Status | State | Updated At | 5+----+------------------+------------+----------+---------+-------+----------------------------+ 6| 1 | nova-consoleauth | controller | internal | enabled | up | 2018-04-26T12:10:00.000000 | 7| 2 | nova-conductor | controller | internal | enabled | up | 2018-04-26T12:09:59.000000 | 8| 5 | nova-scheduler | controller | internal | enabled | up | 2018-04-26T12:10:00.000000 | 9| 6 | nova-compute | compute | nova | enabled | up | 2018-04-26T12:10:00.000000 |
10+----+------------------+------------+----------+---------+-------+----------------------------+
列出认证服务的端口
1# openstack catalog list 2 3+-----------+-----------+-----------------------------------------+ 4| Name | Type | Endpoints | 5+-----------+-----------+-----------------------------------------+ 6| nova | compute | RegionOne | 7| | | admin: http://controller:8774/v2.1 | 8| | | RegionOne | 9| | | internal: http://controller:8774/v2.1 |
10| | | RegionOne | 11| | | public: http://controller:8774/v2.1 | 12| | | | 13| placement | placement | RegionOne | 14| | | admin: http://controller:8778 | 15| | | RegionOne | 16| | | public: http://controller:8778 | 17| | | RegionOne | 18| | | internal: http://controller:8778 | 19| | | | 20| glance | image | RegionOne | 21| | | internal: http://controller:9292 | 22| | | RegionOne | 23| | | admin: http://controller:9292 | 24| | | RegionOne | 25| | | public: http://controller:9292 | 26| | | | 27| keystone | identity | RegionOne | 28| | | public: http://controller:5000/v3/ | 29| | | RegionOne | 30| | | admin: http://controller:35357/v3/ | 31| | | RegionOne | 32| | | internal: http://controller:5000/v3/ | 33| | | | 34+-----------+-----------+-----------------------------------------+
列出镜像信息,确认能访问镜像服务
1# openstack image list 2 3+--------------------------------------+--------+--------+ 4| ID | Name | Status | 5+--------------------------------------+--------+--------+ 6| 0466e837-7d0c-4ebd-a2a1-194e80635d98 | cirros | active | 7+--------------------------------------+--------+--------+
确认cells和placement api成功运行
1# nova-status upgrade check 2 3+--------------------------+ 4| 升级检查结果 | 5+--------------------------+ 6| 检查: Cells v2 | 7| 结果: 成功 | 8| 详情: None | 9+--------------------------+
10| 检查: Placement API | 11| 结果: 成功 | 12| 详情: None | 13+--------------------------+ 14| 检查: Resource Providers | 15| 结果: 成功 | 16| 详情: None | 17+--------------------------+
至此,OpenStack计算服务已经安装验证完成,下面将进行网络服务等组件的安装,具体请参见文章《OpenStack(Queens)详细安装部署(五)》
更多精彩内容,OpenStack干货请扫描下方二维码,关注我们微信公众号“扶艾”!
微信扫一扫
关注该公众号