Openstack I版 结合 Ceph 分布式存储 部署安装(九)

时间:2021-11-28 06:06:15

虚拟机热迁移配置

笔者的环境已经部署双计算及节点,并且同时使用ceph rbd作为后端存储.
双计算节点可以实现虚拟机的热迁移,注意迁移的主机资源必须足够.同时需要设置节点知之间libvirtd服务无密码互相访问
在两个计算节点上执行
vi /etc/libvirt/libvirtd.conf 添加以下配置

listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
listen_addr = "0.0.0.0"
auth_tcp = "none"

重启libvirtd,打开端口监听

service libvirtd stop
libvirtd -d -l
[root@compute01 ~]# netstat -anp | grep 16509
tcp 0 0 0.0.0.0:16509 0.0.0.0:* LISTEN 10042/libvirtd

迁移测试

在controller节点上执行,查看目前实例运行在compute01节点上

nova show cirros-vol | grep "hypervisor_hostname"

执行在线热迁移

nova live-migration cirros-vol compute02

再一次执行nova show cirros-vol 可以看到已经迁移到compute02上

部署配置Heat 业务流

Heat作为自动化的业务流系统,可以帮助用户以模板的形式去定义虚拟机的配置和应用,根据模板>文件可以指定某配置虚拟机的数量,可以配置某虚拟机上部署的应用系统比如MySQL,Apache等

在controller节点上执行

yum install openstack-heat-api openstack-heat-engine openstack-heat-api-cfn -y
mysql -u root -p
mysql> CREATE DATABASE heat;
mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' IDENTIFIED BY 'HEAT_DBPASS';
mysql> GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' IDENTIFIED BY 'HEAT_DBPASS';

创建HEAT角色

keystone user-create --name=heat --pass=HEAT_PASS --email=heat@example.com
keystone user-role-add --user=heat --tenant=service --role=admin
keystone user-list | awk '/heat/{print $2}'
832c4ffb26fd46c7b5a3d753ba1f5429

编辑配置文件 vi /etc/heat/heat.conf

[DEFAULT]
heat_metadata_server_url = http://10.0.0.11:8000
heat_waitcondition_server_url = http://10.0.0.11:8000/v1/waitcondition
stack_user_domain = 832c4ffb26fd46c7b5a3d753ba1f5429
stack_domain_admin = admin
stack_domain_admin_password = ADMIN_PASS
[auth_password]
[clients]
[clients_ceilometer]
[clients_cinder]
[clients_heat]
[clients_keystone]
[clients_neutron]
[clients_nova]
[clients_swift]
[clients_trove]
[database]
connection = mysql://heat:HEAT_DBPASS@controller/heat
[ec2authtoken]
auth_uri = http://controller:5000/v2.0
[heat_api]
[heat_api_cfn]
[heat_api_cloudwatch]
[keystone_authtoken]
auth_host = controller
auth_port = 35357
auth_protocol = http
auth_uri = http://controller:5000/v2.0
admin_tenant_name = service
admin_user = heat
admin_password = HEAT_PASS
[matchmaker_redis]
[matchmaker_ring]
[paste_deploy]
[revision]
heat_revision=2014.1.3-1.el6
[rpc_notifier2]
[ssl]

同步导入数据库表

su -s /bin/sh -c "heat-manage db_sync" heat

创建Heat服务端点


keystone service-create --name=heat --type=orchestration --description="Orchestration"
keystone endpoint-create --service-id=$(keystone service-list | awk '/ orchestration / {print$2}') \
--publicurl=http://controller:8004/v1/%\(tenant_id\)s \
--internalurl=http://controller:8004/v1/%\(tenant_id\)s \
--adminurl=http://controller:8004/v1/%\(tenant_id\)s
keystone service-create --name=heat-cfn --type=cloudformation --description="Orchestration Formation"
keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ cloudformation / {print$2}') \
--publicurl=http://controller:8000/v1 \
--internalurl=http://controller:8000/v1 \
--adminurl=http://controller:8000/v1

启动Heat服务

keystone role-create --name heat_stack_user
service openstack-heat-api start
service openstack-heat-api-cfn start
service openstack-heat-engine start
chkconfig openstack-heat-api on
chkconfig openstack-heat-api-cfn on
chkconfig openstack-heat-engine on

创建业务流模板

vi test-stack.yml

heat_template_version: 2013-05-23
description: Test Template
parameters:
ImageID:
type: string
description: Image use to boot a server
NetID:
type: string
description: Network ID for the server
resources:
server1:
type: OS::Nova::Server
properties:
name: "Test server"
image: { get_param : ImageID }
flavor: "m1.tiny"
networks:
- network: { get_param : NetID }
outputs:
server1_private_ip:
description: IP address of the server in the private network
value: { get_attr: [ server1, first_address ] }

通过模板创建虚拟机实例

image=$(glance image-list | awk '/cirros/{print $2}')
net=$(neutron net-list | awk '/demo-net/{print $2}')
heat stack-create -f test-stack.yml -P "ImageID=$image;NetID=$net" teststack
heat stack-list
nova list #查看到栈的情况,和通过模板创建的虚拟机情况