[部署篇12]VMWare搭建Openstack——控制节点的heat的安装


部署编排 (Orchestration):Heat。提供了一种通过模板定义的协同部署方式,实现云基础设施软件运行环境(计算、存储和网络资源)的自动化部署。自Havana版本集成到项目中。

Heat是OpenStack的负责编排计划的主要项目。它可以基于模板来实现云环境中资源的初始化,依赖关系处理,部署等基本操作,也可以解决自动收缩,负载均衡等高级特性。目前Heat自身的模板格式(HOT)正在不停的改进,同时也支持AWS CloudFormation 模板(CFN),HOT的目标是在不远的将来可以完全的替代CFN。

Heat提供了一个OpenStack的原生REST API和CloudFormation兼容的查询API。


Heat的工作原理



Heat主要是基于模板文件对应用进行管理,在模板文件中可以定义应用需要的资源,资源可以包括多种类型(CFN以及HOT支持的资源类型可能会存在一定的差别)例如IP,网络,镜像,用户,实例等。定义资源的同时也可以指定资源之间的依赖关系,例如使用云硬盘创建创建一个实例时,可以指定在创建实例时必须要创建云硬盘。


编辑完模板文件后,可以使用该模板文件创建Stack,创建的过程中Heat引擎会根据模板文件中定义的资源,调用对应的资源插件创建资源。创建完Stack之后,Heat可以管理Stack中所有资源的生命周期,例如可以删除资源,也可以通过更新模板的方式来更新Stack中资源的定义。


安装步骤


  •  库名: heat
  •  账户: heat
  •  密码: heat4smtest


1、安装软件包

sudo apt-get install heat-api heat-api-cfn heat-engine



2、修改heat配置文件

sudo vi /etc/heat/heat.conf

[database]
# The SQLAlchemy connection string used to connect to the database
connection = mysql://heat:[email protected]/heat



3、sudo rm /var/lib/heat/heat.sqlite


4、创建数据库、账户并配置权限

sudo mysql -uroot -p#db4smtest# -e 'CREATE DATABASE heat;'   
sudo mysql -uroot -p#db4smtest# -e 'CREATE USER heat;'   
sudo mysql -uroot -p#db4smtest# -e "GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' IDENTIFIED BY 'heat4smtest';"
sudo mysql -uroot -p#db4smtest# -e "GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' IDENTIFIED BY 'heat4smtest';"
sudo mysql -uroot -p#db4smtest# -e "SET PASSWORD FOR 'heat'@'%' = PASSWORD('heat4smtest');"


5、创建heat数据表,可能会出现错误,但是无需理会
sudo heat-manage db_sync
sm@controller:~$ sudo heat-manage db_sync
No handlers could be found for logger "heat.common.config"
2015-05-17 01:53:41.853 24843 WARNING heat.openstack.common.db.sqlalchemy.session [-] This application has not enabled MySQL traditional mode, which means silent data corruption may occur. Please encourage the application developers to enable this mode./usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py:324: Warning: Specified key was too long; max key length is 767 bytes cursor.execute(statement, parameters)


查看是否创建了表
mysql> use heat
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> show tables;
+---------------------+
| Tables_in_heat      |
+---------------------+
| event               |
| migrate_version     |
| raw_template        |
| resource            |
| resource_data       |
| software_config     |
| software_deployment |
| stack               |
| stack_lock          |
| user_creds          |
| watch_data          |
| watch_rule          |
+---------------------+
12 rows in set (0.00 sec)


6、编辑heat配置文件
sudo vi /etc/heat/heat.conf
[DEFAULT]
verbose = True
log_dir=/var/log/heat


rabbit_host = 192.168.3.180
rabbit_password = mq4smtest


# URL of the Heat metadata server. (string value)
heat_metadata_server_url = http://192.168.3.180:8000
# URL of the Heat waitcondition server. (string value)
heat_waitcondition_server_url = http://192.168.3.180:8000/v1/waitcondition




[keystone_authtoken]
auth_host = 192.168.3.180
auth_port = 35357
auth_protocol = http
auth_uri = http://192.168.3.180:5000/v2.0
admin_tenant_name = service
admin_user = heat
admin_password = heat4smtest
[ec2authtoken]
auth_uri = http://192.168.3.180:5000/v2.0


7、keystone注册用户
keystone user-create --name=heat --pass=heat4smtest [email protected]
sm@controller:~$ keystone user-create --name=heat --pass=heat4smtest [email protected]
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |           [email protected]           |
| enabled  |               True               |
|    id    | 356986370fa0486d972b0ff84f068a02 |
|   name   |               heat               |
| username |               heat               |
+----------+----------------------------------+

keystone注册用户角色
keystone user-role-add --user=heat --tenant=service --role=admin


8、keystone创建heat服务

keystone service-create --name=heat --type=orchestration --description="Orchestration"
sm@controller:~$ keystone service-create --name=heat --type=orchestration --description="Orchestration"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |          Orchestration           |
|   enabled   |               True               |
|      id     | 1ae32b5423a5430692c771de198eca84 |
|     name    |               heat               |
|     type    |          orchestration           |
+-------------+----------------------------------+

keystone创建接入点
keystone endpoint-create --service-id=$(keystone service-list | awk '/ orchestration / {print$2}') --publicurl=http://192.168.3.180:8004/v1/%\(tenant_id\)s --internalurl=http://192.168.3.180:8004/v1/%\(tenant_id\)s --adminurl=http://192.168.3.180:8004/v1/%\(tenant_id\)s
sm@controller:~$ keystone endpoint-create --service-id=$(keystone service-list | awk '/ orchestration / {print$2}') --publicurl=http://192.168.3.180:8004/v1/%\(tenant_id\)s --internalurl=http://192.168.3.180:8004/v1/%\(tenant_id\)s --adminurl=http://192.168.3.180:8004/v1/%\(tenant_id\)s
+-------------+--------------------------------------------+
|   Property  |                   Value                    |
+-------------+--------------------------------------------+
|   adminurl  | http://192.168.3.180:8004/v1/%(tenant_id)s |
|      id     |      fbe1486bd14d4ef4852b40ac3c0ce6a5      |
| internalurl | http://192.168.3.180:8004/v1/%(tenant_id)s |
|  publicurl  | http://192.168.3.180:8004/v1/%(tenant_id)s |
|    region   |                 regionOne                  |
|  service_id |      1ae32b5423a5430692c771de198eca84      |
+-------------+--------------------------------------------+

keystone创建heat-cfn服务
keystone service-create --name=heat-cfn --type=cloudformation --description="Orchestration CloudFormation"
sm@controller:~$ keystone service-create --name=heat-cfn --type=cloudformation --description="Orchestration CloudFormation"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |   Orchestration CloudFormation   |
|   enabled   |               True               |
|      id     | 5764a2c064f5435c8f43f38c3ddb455d |
|     name    |             heat-cfn             |
|     type    |          cloudformation          |
+-------------+----------------------------------+

keystone创建接入点

keystone endpoint-create --service-id=$(keystone service-list | awk '/ cloudformation / {print$2}') --publicurl=http://192.168.3.180:8000/v1 --internalurl=http://192.168.3.180:8000/v1 --adminurl=http://192.168.3.180:8000/v1
sm@controller:~$ keystone endpoint-create --service-id=$(keystone service-list | awk '/ cloudformation / {print$2}') --publicurl=http://192.168.3.180:8000/v1 --internalurl=http://192.168.3.180:8000/v1 --adminurl=http://192.168.3.180:8000/v1
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |   http://192.168.3.180:8000/v1   |
|      id     | 6805a36f6cc740c298b8571b0bb367c7 |
| internalurl |   http://192.168.3.180:8000/v1   |
|  publicurl  |   http://192.168.3.180:8000/v1   |
|    region   |            regionOne             |
|  service_id | 5764a2c064f5435c8f43f38c3ddb455d |
+-------------+----------------------------------+


9、keystone创建角色
keystone role-create --name heat_stack_user
sm@controller:~$ keystone role-create --name heat_stack_user
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|    id    | 5ae818372ea24d2589e5c19b299c2e6a |
|   name   |         heat_stack_user          |
+----------+----------------------------------+

10、启动服务

sudo service heat-api restart
sudo service heat-api-cfn restart

sudo service heat-engine restart


测试

1、模板文件

这是帮助给的一个模板文件,创建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 ] }

2、该模板文件目的就是创建一个VM实例,需要获得镜像信息和网络信息

sm@controller:~$ neutron net-list
+--------------------------------------+------------+-----------------------------------------------------+
| id                                   | name       | subnets                                             |
+--------------------------------------+------------+-----------------------------------------------------+
| 1dfa9da1-43fd-4128-b9a0-2ca76a664933 | sharednet1 | db1aad02-3890-44d4-93c4-c933c2c818a5 192.168.3.0/24 |
+--------------------------------------+------------+-----------------------------------------------------+

执行该模板,输入条件信息

sm@controller:~$ heat stack-create -f /home/sm/test-stack.yml -P "ImageID=cirros-0.3.2-x86_64;NetID=1dfa9da1-43fd-4128-b9a0-2ca76a664933" testStack
+--------------------------------------+------------+--------------------+----------------------+
| id                                   | stack_name | stack_status       | creation_time        |
+--------------------------------------+------------+--------------------+----------------------+
| 52be000d-4046-40e9-9bab-d11375162080 | testStack  | CREATE_IN_PROGRESS | 2015-05-16T19:17:21Z |
+--------------------------------------+------------+--------------------+----------------------+

查看heat栈信息

sm@controller:~$  heat stack-list
+--------------------------------------+------------+-----------------+----------------------+
| id                                   | stack_name | stack_status    | creation_time        |
+--------------------------------------+------------+-----------------+----------------------+
| 52be000d-4046-40e9-9bab-d11375162080 | testStack  | CREATE_COMPLETE | 2015-05-16T19:17:21Z |
+--------------------------------------+------------+-----------------+----------------------+

我们进入horzion查看信息

我们看到项目,增加了一个编配栏,里面包含一个栈,就是我们刚才创建的testStack。



点击该信息

[部署篇12]VMWare搭建Openstack——控制节点的heat的安装_第1张图片

我们可以看到,创建的明细,新生成了一个192.168.3.125的VM实例

我们再查看实例

[部署篇12]VMWare搭建Openstack——控制节点的heat的安装_第2张图片



你可能感兴趣的:([部署篇12]VMWare搭建Openstack——控制节点的heat的安装)