## Ⅰ、在controller节点上配置nova #### 1.创建nova服务凭据 ``` #先使用脚本登陆admin [root@controller ~]# . admin-openstack.sh ``` ①创建nova user > openstack user create --domain default --password-prompt nova ![](https://s4.51cto.com/images/blog/201809/05/57e9df98b4745b130f9b1c4f10d06e7b.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ②关联 > openstack role add --project service --user nova admin ③创建nova service > openstack service create --name nova --description "OpenStack Compute" compute ![](https://s4.51cto.com/images/blog/201809/05/a7782319204b7b70c1f73da8e00c15e4.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ④创建服务API > openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1 openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1 openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1 ![](https://s4.51cto.com/images/blog/201809/05/c25f003d8e01b2e19c2d0eff8944c55b.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) #### 2.创建placement服务凭据 ``` [root@controller ~]# . admin-openstack.sh ``` ①创建placement user > openstack user create --domain default --password-prompt placement ![](https://s4.51cto.com/images/blog/201809/05/ba960f908500dd162f6ace9b3babaa59.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ②关联 > openstack role add --project service --user placement admin ③创建placement service > openstack service create --name placement --description "Placement API" placement ![](https://s4.51cto.com/images/blog/201809/05/2dba1976aa9d5c652dfc2501caef5d50.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ④创建API > openstack endpoint create --region RegionOne placement public http://controller:8778 openstack endpoint create --region RegionOne placement internal http://controller:8778 openstack endpoint create --region RegionOne placement admin http://controller:8778 ![](https://s4.51cto.com/images/blog/201809/05/8f1d88e0e82d1a648e1c2fb822406d93.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) #### 3.安装nova相关软件 ``` [root@controller ~]# yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api -y ``` #### 4.配置nova.conf ``` [root@controller ~]# cp /etc/nova/nova.conf /etc/nova/nova.conf.bak ``` ``` [root@controller ~]# cat /etc/nova/nova.conf # [DEFAULT] enabled_apis = osapi_compute,metadata transport_url = rabbit://openstack:openstack@controller my_ip = 20.0.20.21 use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver [api_database] connection = mysql+pymysql://nova:nova@controller/nova_api [database] connection = mysql+pymysql://nova:nova@controller/nova [api] auth_strategy = keystone [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 = nova [vnc] enabled = true vncserver_listen = $my_ip vncserver_proxyclient_address = $my_ip [glance] api_servers = http://controller:9292 [oslo_concurrency] lock_path = /var/lib/nova/tmp [placement] os_region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:35357/v3 username = placement password = placement [scheduler] discover_hosts_in_cells_interval = 300 ``` #### 5.配置00-nova-placement-api.conf ``` [root@controller ~]# vim /etc/httpd/conf.d/00-nova-placement-api.conf ``` ``` #在文件末尾添加 = 2.4> Require all granted Order allow,deny Allow from all ``` #### 6.重启httpd ``` [root@controller ~]# systemctl restart httpd ``` #### 7.填充数据库 >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 su -s /bin/sh -c "nova-manage db sync" nova ![](https://s4.51cto.com/images/blog/201809/05/31c34c613276f01e4698b796b5bfcc53.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) #### 8.检测数据 > nova-manage cell_v2 list_cells ![](https://s4.51cto.com/images/blog/201809/05/55663b8019c8654f254a2b7f2eae2801.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) > mysql -h controller -u nova -pnova -e "use nova_api;show tables;" mysql -h controller -u nova -pnova -e "use nova;show tables;" mysql -h controller -u nova -pnova -e "use nova_cell0;show tables;" #### 9.启动服务 ``` 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 ``` ----- ## Ⅱ、在compute节点配置nova #### 1.安装nova ``` [root@compute ~]# yum install openstack-nova-compute -y ``` #### 2.配置nova.conf ``` [root@compute ~]# cp /etc/nova/nova.conf /etc/nova/nova.conf.bak ``` ``` [root@compute ~]# cat /etc/nova/nova.conf # [DEFAULT] enabled_apis = osapi_compute,metadata transport_url = rabbit://openstack:openstack@controller my_ip = 20.0.20.22 use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver [api] auth_strategy = keystone [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 = nova [vnc] enabled = true vncserver_listen = 0.0.0.0 vncserver_proxyclient_address = $my_ip novncproxy_base_url = http://controller:6080/vnc_auto.html [glance] api_servers = http://controller:9292 [oslo_concurrency] lock_path = /var/lib/nova/tmp [placement] os_region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:35357/v3 username = placement password = placement ``` #### 3.查看计算节点是否支持硬件加速 ``` [root@compute ~]# egrep -c '(vmx|svm)' /proc/cpuinfo 0 #如果返回值为0,则不支持硬件加速,需要配置nova.conf中[libvirt] 部分 [root@compute ~]# vim /etc/nova/nova.conf [libvirt] virt_type = qemu ``` #### 4.启动服务 ``` [root@compute ~]# systemctl enable libvirtd.service openstack-nova-compute.service [root@compute ~]# systemctl start libvirtd.service openstack-nova-compute.service ``` . ## Ⅲ、在controller上添加compute到cell数据库 #### 1.查看计算节点 ``` [root@controller ~]# . admin-openstack.sh ``` > openstack compute service list --service nova-compute ![](https://s4.51cto.com/images/blog/201809/07/347bae2230bbac0507aee56e4d0c4a51.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) #### 2.自动注册compute节点 ``` [root@controller ~]#vim /etc/chrony.conf [scheduler] discover_hosts_in_cells_interval = 300 ``` #### 3.验证 > openstack compute service list ![](https://s4.51cto.com/images/blog/201809/07/e164068a7a1820d7006cca77dc068cea.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) > openstack catalog list ![](https://s4.51cto.com/images/blog/201809/07/012d884fb29fb5b1d3e6378cdd49a713.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) > openstack image list ![](https://s4.51cto.com/images/blog/201809/07/495bc1e47ef5f085ac6ff13d2ca4eb86.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) > nova-status upgrade check ![](https://s4.51cto.com/images/blog/201809/07/ae37978f14d59a558bbdf674587c6460.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)