本文为《建立HA Openstack云》第六篇。第一篇:《建立高可用OpenStack云(一):安装集群》,第二篇:《建立高可用OpenStack云(二):安装Mysql》,第三篇:《建立HA Openstack云(三):安装RabbitMQ》,第四篇:《建立HA Openstack云 (四):安装Keystone》,第五篇:《建立HA Openstack云(五):安装Glance》。
在MySQL, RabbitMQ, Keystone和Glance之后,我们要来安装要用Pacemaker管理的Nova服务,并让它们高度可用。
和其他教程一样,当编辑/etc/nova/api-paste.ini,还要改动服务主机:
service_protocol=http
service_host = clusterkeystone
service_port = 5000
auth_host = clusterkeystone
auth_port = 35357
auth_protocol = http
auth_uri = http://clusterkeystone:5000/
admin_tenant_name = service
admin_user = nova
admin_password = nova
还有,在做nova-manage db sync之前,一定要设置SQL主机为“clustermysql”,我这里这样设置/etc/nova/nova.conf:
[DEFAULT]
dhcpbridge_flagfile=/etc/nova/nova.conf
dhcpbridge=/usr/bin/nova-dhcpbridge
logdir=/var/log/nova
state_path=/var/lib/nova
lock_path=/run/lock/nova
allow_admin_api=true
use_deprecated_auth=false
auth_strategy=keystone
scheduler_driver=nova.scheduler.simple.SimpleScheduler
s3_host=clusterglance
ec2_host=clusterec2
ec2_dmz_host=clusterec2
rabbit_host=clusterrabbit
cc_host=clusterec2
nova_url=http://clusternova:8774/v1.1/
glance_api_servers=clusterglance:9292
image_service=nova.image.glance.GlanceImageService
iscsi_ip_prefix=192.168.4
sql_connection=mysql://novadbadmin:password@clustermysql/nova
ec2_url=http://clusterec2:8773/services/Cloud
keystone_ec2_url=http://clusterkeystone:5000/v2.0/ec2tokens
api_paste_config=/etc/nova/api-paste.ini
libvirt_type=kvm
libvirt_use_virtio_for_bridges=true
start_guests_on_host_boot=true
resume_guests_state_on_host_boot=true
novnc_enabled=true
novncproxy_base_url=http://5.9.x.x:6080/vnc_auto.html
vncserver_proxyclient_address=10.8.0.1
vncserver_listen=0.0.0.0
network_manager=nova.network.manager.FlatDHCPManager
public_interface=eth0
flat_interface=eth2
flat_network_bridge=br100
flat_injected=False
force_dhcp_release=true
iscsi_helper=tgtadm
connection_type=libvirt
root_helper=sudo nova-rootwrap
verbose=True
debug=True
multi_host=true
enabled_apis=ec2,osapi_compute,osapi_volume,metadata
再次检查你的/etc/hosts,确保你已经把“clustermysql”,“clusterglance”这样的虚拟IP声明成你在Keystone安装(在终端配置里)和MySQL认证时设定的那样。
现在你可以官方教程里的db_sync部分了。
我们必须停止服务并让它们由Pacemaker管理:
service nova-api stop
service nova-cert stop
service nova-compute stop
service nova-consoleauth stop
service nova-network stop
service nova-objectstore stop
service nova-scheduler stop
service nova-volume stop
service novnc stop
echo "manual" > /etc/init/nova-api.override
echo "manual" > /etc/init/nova-cert.override
echo "manual" > /etc/init/nova-compute.override
echo "manual" > /etc/init/nova-consoleauth.override
echo "manual" > /etc/init/nova-network.override
echo "manual" > /etc/init/nova-objectstore.override
echo "manual" > /etc/init/nova-scheduler.override
echo "manual" > /etc/init/nova-volume.override
echo "manual" > /etc/init/novnc.override
为服务下载资源代理:
cd /usr/lib/ocf/resource.d/openstack/
wget https://raw.github.com/leseb/OpenStack-ra/master/nova-api-ra
wget https://raw.github.com/leseb/OpenStack-ra/master/nova-cert-ra
wget https://raw.github.com/leseb/OpenStack-ra/master/nova-consoleauth-ra
wget https://raw.github.com/leseb/OpenStack-ra/master/nova-scheduler-ra
wget https://raw.github.com/leseb/OpenStack-ra/master/nova-vnc-ra
wget https://raw.github.com/alex88/nova-network-ra/master/nova-network-ra
wget https://raw.github.com/alex88/nova-compute-ra/master/nova-compute-ra
wget https://raw.github.com/alex88/nova-objectstore-ra/master/nova-objectstore-ra
wget https://raw.github.com/alex88/nova-volume-ra/master/nova-volume-ra
chmod +x *
设置服务随Pacemaker启动:
crm configure primitive novaApiService ocf:openstack:nova-api-ra
params config="/etc/nova/nova.conf"
op monitor interval="5s" timeout="5s"
crm configure primitive novaCertService ocf:openstack:nova-cert-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaConsoleauthService ocf:openstack:nova-consoleauth-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaSchedulerService ocf:openstack:nova-scheduler-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaVncService ocf:openstack:nova-vnc-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaNetworkService ocf:openstack:nova-network-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaComputeService ocf:openstack:nova-compute-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaObjectstoreService ocf:openstack:nova-objectstore-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure primitive novaVolumeService ocf:openstack:nova-volume-ra
params config="/etc/nova/nova.conf"
op monitor interval="30s" timeout="30s"
crm configure clone novaVolume novaVolumeService
meta clone-max="2" clone-node-max="1"
crm configure clone novaNetwork novaNetworkService
meta clone-max="2" clone-node-max="1"
crm configure clone novaCompute novaComputeService
meta clone-max="2" clone-node-max="1"
crm configure clone novaApi novaApiService
meta clone-max="2" clone-node-max="1"
crm configure clone novaVnc novaVncService
meta clone-max="2" clone-node-max="1"
crm configure group novaServices novaConsoleauthService novaCertService novaSchedulerService
crm configure order novaServices_after_keystone inf: Keystone novaServices
注意:一定根据你的需要的用处来使用clone指令,其实我在Api and Network上使用clone,因为我运行的是multi_host openstack。
我的nova.conf里面说s3_host是glance ip,一定要编辑group Glance来包括nova-objectstore服务,所以要进行crm configure edit并确保有这一行:
group Glance glanceIP novaObjectstoreService glanceApiService glanceRegistryService
现在你就能查看OpenStack集群的状态了:
Binary Host Zone Status State Updated_At
nova-compute server1 nova enabled 🙂 2012-07-31 10:00:27
nova-compute server2 nova enabled 🙂 2012-07-31 10:00:19
nova-network server2 nova enabled 🙂 2012-07-31 10:00:26
nova-network server1 nova enabled 🙂 2012-07-31 10:00:26
nova-scheduler server2 nova enabled 🙂 2012-07-31 10:00:26
nova-consoleauth server2 nova enabled 🙂 2012-07-31 10:00:26
nova-cert server2 nova enabled 🙂 2012-07-31 10:00:26
nova-volume server1 nova enabled 🙂 2012-07-31 10:00:26
nova-volume server2 nova enabled 🙂 2012-07-31 10:00:26
好了,现在你已经有了所有Corosync+Pacemaker管理的Openstack组件了。Openstack的虚拟机高可用性特性仍在开发,敬请期待这方面的更新。