openstack部署nova

Posted daisyyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack部署nova相关的知识,希望对你有一定的参考价值。

controller

一、创建nova数据库,并设置权限及远程登录

  mysql -u root -p

  CREATE DATABASE nova_api;

  CREATE DATABASE nova;

  CREATE DATABASE nova_cell0;

  GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova‘@‘localhost‘ \ IDENTIFIED BY ‘NOVA_DBPASS‘;

  GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova‘@‘%‘ \ IDENTIFIED BY ‘NOVA_DBPASS‘;

  GRANT ALL PRIVILEGES ON nova.* TO ‘nova‘@‘localhost‘ \ IDENTIFIED BY ‘NOVA_DBPASS‘;

  GRANT ALL PRIVILEGES ON nova.* TO ‘nova‘@‘%‘ \ IDENTIFIED BY ‘NOVA_DBPASS‘;

  GRANT ALL PRIVILEGES ON nova_cell0.* TO ‘nova‘@‘localhost‘ \ IDENTIFIED BY ‘NOVA_DBPASS‘;

  GRANT ALL PRIVILEGES ON nova_cell0.* TO ‘nova‘@‘%‘ \ IDENTIFIED BY ‘NOVA_DBPASS‘;

二、创建nova用户

  ①创建nova用户

  source openrc

  openstack user create --domain default --password=nova nova

  ②将default项目中的nova用户设置成admin角色 

  openstack role add --project service --user nova admin

  ③创建nova服务

  openstack service create --name nova \ --description "OpenStack Compute" compute

  ④创建nova服务端点

  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

三、创建placement用户(起到统计资源使用的功能)

  ①创建placement用户

  openstack user create --domain default --password=placement placement

  ②将service项目中的placement用户设置成admin角色

  openstack role add --project service --user placement admin

  ③创建服务

  openstack service create --name placement --description "Placement API" placement

  ④创建服务端点

  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

四、安装nova

  ①安装nova服务包

  yum install openstack-nova-api openstack-nova-conductor  openstack-nova-console openstack-nova-novncproxy  openstack-nova-scheduler openstack-nova-placement-api

  ②修改nova配置文件

  cp /etc/nova/nova.conf /etc/nova/nova.conf.bak 

技术图片
[DEFAULT]
my_ip=192.168.42.120  #控制节点ip
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver         #防火墙驱动
enabled_apis=osapi_compute,metadata
transport_url = rabbit://openstack:[email protected]       #rabbitmq的连接方式

[api]
auth_strategy = keystone

[api_database]
connection = mysql+pymysql://nova:[email protected]/nova_api

[barbican]

[cache]

[cells]

[cinder]
#os_region_name = RegionOne

[cloudpipe]

[conductor]

[console]

[consoleauth]

[cors]

[cors.subdomain]

[crypto]

[database]
connection = mysql+pymysql://nova:[email protected]/nova

[ephemeral_storage_encryption]

[filter_scheduler]

[glance]
api_servers = http://controller:9292

[guestfs]

[healthcheck]

[hyperv]

[image_file_url]

[ironic]

[key_manager]

[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

[libvirt]
#virt_type=qemu

[matchmaker_redis]

[metrics]

[mks]

[neutron]
#url = http://controller:9696
#auth_url = http://controller:35357
#auth_type = password
#project_domain_name = default
#user_domain_name = default
#region_name = RegionOne
#project_name = service
#username = neutron
#password = neutron
#service_metadata_proxy = true
#metadata_proxy_shared_secret = METADATA_SECRET

[notifications]

[osapi_v21]

[oslo_concurrency]
lock_path=/var/lib/nova/tmp         #临时文件保存位置

[oslo_messaging_amqp]

[oslo_messaging_kafka]

[oslo_messaging_notifications]

[oslo_messaging_rabbit]

[oslo_messaging_zmq]

[oslo_middleware]

[oslo_policy]

[pci]
[placement]
os_region_name = RegionOne
auth_type = password
auth_url = http://controller:35357/v3      #认证的地址
project_name = service
project_domain_name = Default
username = placement
password = placement
user_domain_name = Default

[quota]

[rdp]

[remote_debug]

[scheduler]

[serial_console]

[service_user]

[spice]

[ssl]

[trusted_computing]

[upgrade_levels]

[vendordata_dynamic_auth]

[vmware]

[vnc]   #可以连接虚拟机
enabled=true
vncserver_listen=$my_ip      #监听ip地址
vncserver_proxyclient_address=$my_ip    #vnc代理服务监听地址
#novncproxy_base_url = http://172.16.254.63:6080/vnc_auto.html

[workarounds]

[wsgi]

[xenserver]

[xvp]
vim /etc/noa/nova.conf

  ③创建一个服务追踪的配置文件(补充到文件的末尾)

vim /etc/httpd/conf.d/00-nova-placement-api.conf
<Directory /usr/bin> <IfVersion >= 2.4> Require all granted </IfVersion> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion> </Directory>

  ④重启httpd服务

  systemctl restart httpd

  ⑤同步api、cell0数据库

  su -s /bin/sh -c "nova-manage api_db sync" nova

  su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova

  ⑥创建cell证书的id

  su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova 

  ⑦同步nova数据库

  su -s /bin/sh -c "nova-manage db sync" nova

  ⑧列示cell证书列表

  nova-manage cell_v2 list_cells

  ⑨重启并设置开机自启

  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  

openstack的库都建立在控制节点上,其他节点不需要建库

  ①安装nova包(先解决依赖)yum安装

  qemu-img-ev-2.9.0-16.el7_4.8.1.x86_64.rpm         qemu-kvm-ev-2.9.0-16.el7_4.8.1.x86_64.rpm         qemu-kvm-common-ev-2.9.0-16.el7_4.8.1.x86_64.rpm
  
yum install openstack-nova-compute

  ②编辑nova配置文件

  cp /etc/nova/nova.conf /etc/nova/nova.conf.bak

技术图片
[DEFAULT]
my_ip=192.168.42.121      #管理网卡的ip地址
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
transport_url = rabbit://openstack:[email protected]

[api]
#auth_strategy = keystone

[api_database]
#connection = mysql+pymysql://nova:[email protected]/nova_api

[barbican]

[cache]

[cells]

[cinder]
#os_region_name = RegionOne

[cloudpipe]

[conductor]

[console]

[consoleauth]

[cors]

[cors.subdomain]

[crypto]

[database]
#connection = mysql+pymysql://nova:[email protected]/nova

[ephemeral_storage_encryption]

[filter_scheduler]

[glance]
api_servers = http://controller:9292

[guestfs]

[healthcheck]

[hyperv]

[image_file_url]

[ironic]

[key_manager]

[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

[libvirt]
virt_type=qemu   #调用后台虚拟化

[matchmaker_redis]

[metrics]

[mks]

[neutron]
#url = http://controller:9696
#auth_url = http://controller:35357
#auth_type = password
#project_domain_name = default
#user_domain_name = default
#region_name = RegionOne
#project_name = service
#username = neutron
#password = neutron
#service_metadata_proxy = true
#metadata_proxy_shared_secret = METADATA_SECRET

[notifications]

[osapi_v21]

[oslo_concurrency]
lock_path=/var/lib/nova/tmp

[oslo_messaging_amqp]

[oslo_messaging_kafka]

[oslo_messaging_notifications]

[oslo_messaging_rabbit]

[oslo_messaging_zmq]

[oslo_middleware]

[oslo_policy]

[pci]
[placement]
os_region_name = RegionOne
auth_type = password
auth_url = http://controller:35357/v3
project_name = service
project_domain_name = Default
username = placement
password = placement
user_domain_name = Default

[quota]

[rdp]

[remote_debug]

[scheduler]

[serial_console]

[service_user]

[spice]

[ssl]

[trusted_computing]

[upgrade_levels]

[vendordata_dynamic_auth]

[vmware]

[vnc]
enabled=true
vncserver_listen=0.0.0.0
vncserver_proxyclient_address=$my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html     #控制节点地址

[workarounds]

[wsgi]

[xenserver]

[xvp]
vim /etc/nova/nova.conf

  ③过滤计算节点是否开启虚拟化

  egrep -c ‘(vmx|svm)‘ /proc/cpuinfo

  ④重启并设置开启自启

  systemctl enable libvirtd.service openstack-nova-compute.service

·   systemctl start libvirtd.service openstack-nova-compute.service          #启不来查看日志,具体错误具体解决

  ⑤列示openstack管理虚拟化类型

  openstack hypervisor list

  ⑥数据库同步计算接节点

  su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova

  ⑦在控制节点查看计算服务的工作状态

    openstack compute service list(enable表示开启,up运行)

    openstack catalog list (查看服务列表)

    openstack image list  (查看镜像列表)

    nova-status upgrade check  (nova状态服务检测)

      显示都成功即可

  

以上是关于openstack部署nova的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack部署之Nova项目(7-5)

OpenStack部署之Nova项目(7-5)

OpenStack 运维 - 部署Nova组件

OpenStack 计算服务 Nova部署

OpenStack 运维 - 部署Nova组件 [T版]

OpenStack 运维 - 部署Nova组件 [T版]