1、控制节点

1.1、数据库配置

  1. mysql -uroot -p123456
  2. CREATE DATABASE nova_api;
  3. CREATE DATABASE nova;
  4. CREATE DATABASE nova_cell0;
  5. GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
  6. GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';
  7. GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
  8. GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';
  9. GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
  10. GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';
  11. #验证
  12. mysql -uroot -p123456 -e "show databases;"

1.2、创建项目

  1. openstack user create --domain default --password nova nova
  2. openstack role add --project service --user nova admin
  3. openstack service create --name nova --description "OpenStack Compute" compute
  4. openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
  5. openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
  6. openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1

1.3、安装

  1. yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y
  2. cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
  3. sed -ri '/^[ \t]*(#|$)/d' /etc/nova/nova.conf

vim /etc/nova/nova.conf

  1. [DEFAULT]
  2. # ...
  3. enabled_apis = osapi_compute,metadata
  4. my_ip = 192.100.5.222
  5. transport_url = rabbit://openstack:openstack@controller:5672/
  6. use_neutron = true
  7. firewall_driver = nova.virt.firewall.NoopFirewallDriver
  8. [api_database]
  9. # ...
  10. connection = mysql+pymysql://nova:nova@controller/nova_api
  11. [database]
  12. # ...
  13. connection = mysql+pymysql://nova:nova@controller/nova
  14. [api]
  15. # ...
  16. auth_strategy = keystone
  17. [keystone_authtoken]
  18. # ...
  19. www_authenticate_uri = http://controller:5000/
  20. auth_url = http://controller:5000/
  21. memcached_servers = controller:11211
  22. auth_type = password
  23. project_domain_name = Default
  24. user_domain_name = Default
  25. project_name = service
  26. username = nova
  27. password = nova
  28. [vnc]
  29. enabled = true
  30. # ...
  31. server_listen = $my_ip
  32. server_proxyclient_address = $my_ip
  33. [glance]
  34. # ...
  35. api_servers = http://controller:9292
  36. [oslo_concurrency]
  37. # ...
  38. lock_path = /var/lib/nova/tmp
  39. [placement]
  40. # ...
  41. region_name = RegionOne
  42. project_domain_name = Default
  43. project_name = service
  44. auth_type = password
  45. user_domain_name = Default
  46. auth_url = http://controller:5000/v3
  47. username = placement
  48. password = placement

1.4、同步数据库

  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. su -s /bin/sh -c "nova-manage db sync" nova
  5. #验证
  6. su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova

1.5、启动

  1. systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
  2. systemctl restart openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
  3. systemctl status openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

2、计算节点

2.1、安装

  1. yum install openstack-nova-compute -y
  2. cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
  3. sed -ri '/^[ \t]*(#|$)/d' /etc/nova/nova.conf

vim /etc/nova/nova.conf

  1. [DEFAULT]
  2. # ...
  3. enabled_apis = osapi_compute,metadata
  4. transport_url = rabbit://openstack:openstack@controller
  5. my_ip = 192.100.5.223
  6. use_neutron = true
  7. firewall_driver = nova.virt.firewall.NoopFirewallDriver
  8. [api]
  9. # ...
  10. auth_strategy = keystone
  11. [keystone_authtoken]
  12. # ...
  13. www_authenticate_uri = http://controller:5000/
  14. auth_url = http://controller:5000/
  15. memcached_servers = controller:11211
  16. auth_type = password
  17. project_domain_name = Default
  18. user_domain_name = Default
  19. project_name = service
  20. username = nova
  21. password = nova
  22. [vnc]
  23. # ...
  24. enabled = true
  25. server_listen = 0.0.0.0
  26. server_proxyclient_address = $my_ip
  27. novncproxy_base_url = http://controller:6080/vnc_auto.html
  28. [glance]
  29. # ...
  30. api_servers = http://controller:9292
  31. [oslo_concurrency]
  32. # ...
  33. lock_path = /var/lib/nova/tmp
  34. [placement]
  35. # ...
  36. region_name = RegionOne
  37. project_domain_name = Default
  38. project_name = service
  39. auth_type = password
  40. user_domain_name = Default
  41. auth_url = http://controller:5000/v3
  42. username = placement
  43. password = placement

确定计算节点是否支持虚拟机的硬件加速

  1. egrep -c '(vmx|svm)' /proc/cpuinfo
  2. 返回0则不支持硬件加速,需要进行额外配置
  3. vim /etc/nova/nova.conf
  4. [libvirt]
  5. # ...
  6. virt_type = qemu

2.2、启动

  1. systemctl enable libvirtd.service openstack-nova-compute.service
  2. systemctl restart libvirtd.service openstack-nova-compute.service
  3. systemctl status libvirtd.service openstack-nova-compute.service

3、注册计算节点

  1. #在控制节点上执行
  2. openstack compute service list --service nova-compute
  3. su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
  4. #添加新计算节点时,必须在控制器节点上运行以注册这些新计算节点。或者,您可以在 中设置适当的间隔:nova-manage cell_v2 discover_hosts/etc/nova/nova.conf
  5. [scheduler]
  6. discover_hosts_in_cells_interval = 300

4、验证

  1. openstack compute service list
  2. openstack catalog list
  3. openstack image list
  4. nova-status upgrade check

5、问题

  1. tee -a /etc/httpd/conf.d/00-placement-api.conf <<-EOF
  2. <Directory /usr/bin>
  3. <IfVersion >= 2.4>
  4. Require all granted
  5. </IfVersion>
  6. <IfVersion < 2.4>
  7. Order allow,deny
  8. Allow from all
  9. </IfVersion>
  10. </Directory>
  11. EOF