安装nova

在控制节点上执行


controllerHost='controller'
controllerIP='172.31.240.49'
MYSQL_PASSWD='m4r!adbOP'
RABBIT_PASSWD='0penstackRMQ'
NOVA_PASSWD='nova1234!'
PLACEMENT_PASSWD='placement1234!'

1.创建数据库


mysql -uroot -p${MYSQL_PASSWD} << EOF
     DROP DATABASE IF EXISTS nova;
     CREATE DATABASE nova;
     DROP DATABASE IF EXISTS nova_api;
     CREATE DATABASE nova_api;
     DROP DATABASE IF EXISTS nova_cell0;
     CREATE DATABASE nova_cell0;
     DROP DATABASE IF EXISTS placement;
     CREATE DATABASE placement;
     GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '${NOVA_PASSWD}';
     GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '${NOVA_PASSWD}';
     GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY '${NOVA_PASSWD}';
     GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY '${NOVA_PASSWD}';
     GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY '${NOVA_PASSWD}';
     GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY '${NOVA_PASSWD}';
     GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY '${PLACEMENT_PASSWD}';
     GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY '${PLACEMENT_PASSWD}';
EOF

2.创建认证用户并授权


openstack user create --domain default --password ${NOVA_PASSWD} nova
openstack role add --project service --user nova admin

openstack user create --domain default --password ${PLACEMENT_PASSWD} placement
openstack role add --project service --user placement admin

3.创建服务实体和端点


openstack service create --name nova  --description "OpenStack Compute" compute
openstack endpoint create --region RegionOne compute public http://${controllerHost}:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://${controllerHost}:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://${controllerHost}:8774/v2.1

openstack service create --name placement --description "Placement API" placement
openstack endpoint create --region RegionOne placement public http://${controllerHost}:8778
openstack endpoint create --region RegionOne placement internal http://${controllerHost}:8778
openstack endpoint create --region RegionOne placement admin http://${controllerHost}:8778

4.安装nova组件


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

5.配置nova服务访问数据库


openstack-config --set  /etc/nova/nova.conf  api_database  connection  mysql+pymysql://nova:${NOVA_PASSWD}@${controllerHost}/nova_api
openstack-config --set  /etc/nova/nova.conf  database connection  mysql+pymysql://nova:${NOVA_PASSWD}@${controllerHost}/nova
openstack-config --set  /etc/nova/nova.conf  placement_database connection  mysql+pymysql://placement:${PLACEMENT_PASSWD}@${controllerHost}/placement

6.配置nova服务访问memcached服务


openstack-config --set  /etc/nova/nova.conf  cache backend oslo_cache.memcache_pool
openstack-config --set  /etc/nova/nova.conf  cache enabled True
openstack-config --set  /etc/nova/nova.conf  cache memcache_servers  ${controllerHost}:11211

7.配置nova服务访问rabbitmq服务


openstack-config --set  /etc/nova/nova.conf  DEFAULT transport_url rabbit://openstack:${RABBIT_PASSWD}@${controllerHost}:5672

8.配置nova访问glance服务


openstack-config --set  /etc/nova/nova.conf  glance api_servers  http://${controllerHost}:9292

9.配置nova服务访问认证服务


openstack-config --set  /etc/nova/nova.conf  api auth_strategy  keystone
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken auth_url  http://${controllerHost}:5000/v3
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken auth_type  password
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken project_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken user_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken project_name  service
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken username  nova
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken password  ${NOVA_PASSWD}

10.配置统一资源管理placement服务访问认证服务


openstack-config --set  /etc/nova/nova.conf  placement auth_url  http://${controllerHost}:5000/v3
openstack-config --set  /etc/nova/nova.conf  placement region_name  RegionOne
openstack-config --set  /etc/nova/nova.conf  placement auth_type  password
openstack-config --set  /etc/nova/nova.conf  placement project_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  placement user_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  placement project_name  service
openstack-config --set  /etc/nova/nova.conf  placement username  placement
openstack-config --set  /etc/nova/nova.conf  placement password  ${PLACEMENT_PASSWD}

11.配置nova开启计算和元数据API服务


openstack-config --set  /etc/nova/nova.conf  DEFAULT enabled_apis  osapi_compute,metadata

12.配置计算和元数据API服务的监听IP和端口


openstack-config --set  /etc/nova/nova.conf  DEFAULT osapi_compute_listen ${controllerIP}
openstack-config --set  /etc/nova/nova.conf  DEFAULT osapi_compute_listen_port 8774
openstack-config --set  /etc/nova/nova.conf  DEFAULT metadata_listen ${controllerIP}
openstack-config --set  /etc/nova/nova.conf  DEFAULT metadata_listen_port 8775

13.配置nova开启VNC代理服务


openstack-config --set  /etc/nova/nova.conf  vnc enabled true
openstack-config --set  /etc/nova/nova.conf  vnc server_listen ${controllerIP}
openstack-config --set  /etc/nova/nova.conf  vnc server_proxyclient_address ${controllerIP}
openstack-config --set  /etc/nova/nova.conf  vnc novncproxy_base_url http://${controllerIP}:6080/vnc_auto.html
openstack-config --set  /etc/nova/nova.conf  vnc novncproxy_host ${controllerIP}
openstack-config --set  /etc/nova/nova.conf  vnc novncproxy_port 6080

14.配置nova加载防火墙驱动程序


openstack-config --set  /etc/nova/nova.conf  DEFAULT firewall_driver  nova.virt.firewall.NoopFirewallDriver

15.配置nova允许动态调整实例大小


openstack-config --set  /etc/nova/nova.conf  DEFAULT allow_resize_to_same_host True

16.配置nova使能自动发现并添加nova-compute服务到数据库cell中


#时间间隔单位是秒
openstack-config --set  /etc/nova/nova.conf  scheduler discover_hosts_in_cells_interval  300

17.配置nova中oslo库的锁定路径


openstack-config --set  /etc/nova/nova.conf  oslo_concurrency lock_path  /var/lib/nova/tmp

18.配置placement服务的监听IP


sed -i "s/Listen 8778/Listen 0.0.0.0:8778/g"  /etc/httpd/conf.d/00-nova-placement-api.conf
sed -i "s/*:8778/0.0.0.0:8778/g"  /etc/httpd/conf.d/00-nova-placement-api.conf

19.解决placement启动配置中的bug


sed -i "/ErrorLogFormat/a\<Directory /usr/bin>\n\t<IfVersion >= 2.4>\n\t\tRequire all granted\n\t</IfVersion>\n\t<IfVersion < 2.4>\n\t\tOrder allow,deny\n\t\tAllow from all\n\t</IfVersion>\n</Directory>"   /etc/httpd/conf.d/00-nova-placement-api.conf

20.同步数据库


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 cell_v2 list_cells" nova
su -s /bin/sh -c "nova-manage db sync" nova

21.启动nova服务


systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service openstack-nova-consoleauth.service
systemctl restart openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service openstack-nova-consoleauth.service
systemctl status openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service openstack-nova-consoleauth.service
systemctl restart httpd
systemctl status httpd

22.校验nova服务正常性


source ~/admin-openrc
openstack compute service list
openstack catalog list
openstack image list
nova-status upgrade check

23.创建flavor实例类型


openstack flavor create --id 1 --vcpus 2 --ram 4096 --disk 40 small.flavor
openstack flavor create --id 2 --vcpus 4 --ram 4096 --disk 40 medium.flavor
openstack flavor create --id 3 --vcpus 8 --ram 8192 --disk 40 large.flavor

24.手动发现并添加新加入的计算节点到数据库cell中


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

 

在计算节点上执行


controllerHost='controller'
controllerVIP='172.31.240.49'
computeIP='172.31.240.45'
RABBIT_PASSWD='0penstackRMQ'
NOVA_PASSWD='nova1234!'
PLACEMENT_PASSWD='placement1234!'

1.安装nova组件


yum -y install openstack-nova-compute

2.配置nova访问memcached服务


openstack-config --set  /etc/nova/nova.conf  cache backend oslo_cache.memcache_pool
openstack-config --set  /etc/nova/nova.conf  cache enabled True
openstack-config --set  /etc/nova/nova.conf  cache memcache_servers  ${controllerHost}:11211

3.配置nova访问rabbitmq服务


openstack-config --set  /etc/nova/nova.conf  DEFAULT transport_url rabbit://openstack:${RABBIT_PASSWD}@${controllerHost}:5672

4.配置nova访问glance服务


openstack-config --set  /etc/nova/nova.conf  glance api_servers  http://${controllerHost}:9292

5.配置nova服务访问认证服务


openstack-config --set  /etc/nova/nova.conf  api auth_strategy  keystone
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken auth_url  http://${controllerHost}:5000/v3
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken auth_type  password
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken project_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken user_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken project_name  service
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken username  nova
openstack-config --set  /etc/nova/nova.conf  keystone_authtoken password  ${NOVA_PASSWD}

6.配置统一资源管理placement服务访问认证服务


openstack-config --set  /etc/nova/nova.conf  placement auth_url  http://${controllerHost}:5000/v3
openstack-config --set  /etc/nova/nova.conf  placement region_name  RegionOne
openstack-config --set  /etc/nova/nova.conf  placement auth_type  password
openstack-config --set  /etc/nova/nova.conf  placement project_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  placement user_domain_name  Default
openstack-config --set  /etc/nova/nova.conf  placement project_name  service
openstack-config --set  /etc/nova/nova.conf  placement username  placement
openstack-config --set  /etc/nova/nova.conf  placement password  ${PLACEMENT_PASSWD}

7.配置nova访问计算和元数据API服务


openstack-config --set  /etc/nova/nova.conf  DEFAULT enabled_apis  osapi_compute,metadata

8.配置nova开启VNC服务


openstack-config --set  /etc/nova/nova.conf  vnc enabled true
openstack-config --set  /etc/nova/nova.conf  vnc server_listen ${computeIP}
openstack-config --set  /etc/nova/nova.conf  vnc server_proxyclient_address ${computeIP}
openstack-config --set  /etc/nova/nova.conf  vnc novncproxy_base_url  http://${controllerVIP}:6080/vnc_auto.html

9.配置nova加载防火墙驱动程序


openstack-config --set  /etc/nova/nova.conf  DEFAULT firewall_driver  nova.virt.firewall.NoopFirewallDriver

10.配置nova允许动态调整实例大小


openstack-config --set  /etc/nova/nova.conf  DEFAULT allow_resize_to_same_host True

11.配置nova服务克隆物理CPU的特征标记


openstack-config --set  /etc/nova/nova.conf  libvirt cpu_mode host-model

openstack官网对cpu_mode配置信息的描述:
(StrOpt) Set to "host-model" to clone the host CPU feature flags;
to "host-passthrough" to use the host CPU model exactly;
to "custom" to use a named CPU model;
to "none" to not set any CPU model.
If virt_type="kvm|qemu", it will default to "host-model",
otherwise it will default to "none"

(StrOpt) Set to a named libvirt CPU model
(see names listed in /usr/share/libvirt/cpu_map.xml).
Only has effect if cpu_mode="custom" and virt_type="kvm|qemu"

12.配置nova服务使能KVM虚拟机(只有物理主机支持虚拟化才可以使能KVM,默认为QEMU)


openstack-config --set  /etc/nova/nova.conf  libvirt virt_type kvm


13.配置nova中oslo库的锁定路径


openstack-config --set  /etc/nova/nova.conf  oslo_concurrency lock_path  /var/lib/nova/tmp

14.解决network-vif-plugged事件超时对虚机创建的影响


openstack-config --set  /etc/nova/nova.conf  DEFAULT vif_plugging_is_fatal  False
openstack-config --set  /etc/nova/nova.conf  DEFAULT vif_plugging_timeout  0

详情请分析这篇文章:http://www.mamicode.com/info-detail-2317620.html

15.启动nova服务


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

posted @ 2019-07-18 21:27  小白的日常  阅读(359)  评论(0编辑  收藏  举报