Openstack-Queens双节点模式·计算服务Nova

这是Openstack的第五堂课,主要讲解计算服务nova的配置过程。成功搭建Openstack后,所有虚拟机都运行在计算节点上,因此要求服务器性能必须有保障。

配置nova服务凭证

创建数据库

mysql -uroot -pMariadb123

create database nova_api;

create database nova;

create database nova_cell0;

grant all privileges on nova_api.* to 'nova'@'localhost' identified by 'Nova123';

grant all privileges on nova_api.* to 'nova'@'%' identified by 'Nova123';

grant all privileges on nova.* to 'nova'@'localhost' identified by 'Nova123';

grant all privileges on nova.* to 'nova'@'%' identified by 'Nova123';

grant all privileges on nova_cell0.* to 'nova'@'localhost' identified by 'Nova123';

grant all privileges on nova_cell0.* to 'nova'@'%' identified by 'Nova123';

flush privileges;

exit

创建nova服务凭证

#source /opt/scripts/admin

openstack user create \

--domain default \

--password-prompt nova

输入密码(Nova123)后继续

openstack role add \

--project service \

--user nova admin

openstack service create \

--name nova \

--description "Openstack Compute" compute

创建nova的endpoint

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服务凭证

openstack user create \

--domain default \

--password-prompt placement

输入密码(Placement123)后继续​

openstack role add \

--project service \

--user placement admin

openstack service create \

--name placement --description "Placement API" placement

创建placement的endpoint

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

vi /etc/nova/nova.conf

[DEFAULT]
my_ip = 10.10.100.150
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis = osapi_compute,metadata
osapi_compute_listen = $my_ip
osapi_compute_listen_port = 8774
metadata_listen = $my_ip
metadata_listen_port = 8775
transport_url=rabbit://openstack:Openstack123@controller:5672

[api]
auth_strategy = keystone

[api_database]
connection = mysql+pymysql://nova:Nova123@controller/nova_api

[cache]
backend = oslo_cache.memcache_pool
enabled = True
memcache_servers = controller:11211

[database]
connection = mysql+pymysql://nova:Nova123@controller/nova

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

[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 = Nova123

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

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

[vnc]
enabled = True
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
novncproxy_base_url=http://$my_ip:6080/vnc_auto.html
novncproxy_host=$my_ip
novncproxy_port=6080

配置httpd

软件包存在一个bug,解决方法就是在底部添加如下内容:

vi /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

同步数据

同步nova-api数据

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

同步cell0数据

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

创建cell1单元

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

以上过程有告警信息,忽略即可。

查看已安装的cells

nova-manage cell_v2 list_cells

启动应用

systemctl restart openstack-nova-api

systemctl enable openstack-nova-consoleauth openstack-nova-scheduler openstack-nova-conductor openstack-nova-novncproxy

systemctl start openstack-nova-consoleauth openstack-nova-scheduler openstack-nova-conductor openstack-nova-novncproxy

配置计算节点上的服务

配置compute

vi /etc/nova/nova.conf

[DEFAULT]
my_ip = 10.10.100.151
enabled_apis = osapi_compute,metadata
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
transport_url = rabbit://openstack:Openstack123@controller:5672

[api]
auth_strategy = keystone

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

[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 = Nova123

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

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

[vnc]
enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = $my_ip
novncproxy_base_url = http://$my_ip:6080/vnc_auto.html

启动应用

systemctl enable libvirtd openstack-nova-compute

systemctl start libvirtd openstack-nova-compute

如果启动失败,可以通过以下命令检查CPU是否支持虚拟化:

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

如果命令返回值等于0,表示不支持虚拟化,需要配置libvirt,用QEMU替代KVM。

vi /etc/nova/nova.conf

加入如下内容:

[libvirt]
virt_type = qemu

继续启动compute:

systemctl start openstack-nova-compute

添加计算节点到cell数据库

在控制节点查找并新增计算节点

确认有哪些计算节点主机在数据库:

openstack compute service list --service nova-compute

发现计算节点主机:

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

每添加一个新的计算节点时,需要在控制节点执行以上操作来注册该新计算节点,或者:

vi /etc/nova/nova.conf

[scheduler]
discover_hosts_in_cells_interval = 300

常用验证命令

openstack compute service list

openstack catalog list

openstack image list

nova-status upgrade check

赞 (0) 打赏

评论 0

评论前必须登录!

登陆 注册

感谢您的支持与帮助

支付宝扫一扫打赏

微信扫一扫打赏