4.2 界面Dashboard使用
在Dashboard上的操作:
? 进入“栈”菜单项,选择“启动栈”,支持三种方式(直接输入、url、
文件)加载模板,这里选择直接输入,将模板写入的文本框中,如下图:
? 点击“下一步”,输入栈名和密码后,创建栈;
? 创建完成后
陕西省信息化工程研究院软件研发部第16页/ 共21页
由于栈的资源为一台虚拟机,所以可以在“云主机”中查看创建的虚拟机:
4.3 实例:Wordpress应用部署
heat模板文件:
heat_template_version: 2013-05-23 description: > Heat WordPress template deployment using a localMySQL database to store the data. parameters: key_name: type: string default: heat_key description : Name of a KeyPair to enable SSH access to the instance instance_type: type: string description: Instance type for WordPress server default: m1.small constraints: - allowed_values: [m1.small, m1.medium, m1.large] description: instance_type must be one of m1.small, m1.medium or m1.large image_id: type: string description: ID of the image to use for the WordPress server default: ubuntu12.04.final.img db_name: type: string description: WordPress database name default: wordpress constraints: - length: { min: 1, max: 64 } description: db_name must be between 1 and 64 characters - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*' description: > db_name must begin with a letter and contain only alphanumeric characters db_username: 陕西省信息化工程研究院软件研发部第17页/ 共21页
type: string description: The WordPress database admin account username default: root hidden: true constraints: - length: { min: 1, max: 16 } description: db_username must be between 1 and 64 characters - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*' description: > db_username must begin with a letter and contain only alphanumeric characters db_password: type: string description: The WordPress database admin account password default: admin hidden: true constraints: - length: { min: 1, max: 41 } description: db_username must be between 1 and 64 characters - allowed_pattern: '[a-zA-Z0-9]*' description: db_password must contain only alphanumeric characters db_root_password: type: string description: Root password for MySQL default: admin hidden: true constraints: - length: { min: 1, max: 41 } description: db_username must be between 1 and 64 characters - allowed_pattern: '[a-zA-Z0-9]*' description: db_password must contain only alphanumeric characters secgroup_id: type: string description : Id of the security groupe default: default public_net: type: string description: public network id default: 004df4b2-3050-4646-958f-f0f2621df687 private_net: type: string description: private network id 陕西省信息化工程研究院软件研发部第18页/ 共21页
default: 7e83541b-3bb9-4649-b307-9d3fbcd9e998 private_subnet: type: string description: private_subnet id default: b20dfcde-55f0-40c6-b645-2eae7d116ee2 resources: wordpress_port: type: OS::Neutron::Port properties: network_id: { get_param: private_net } security_groups: { get_param: secgroup_id } fixed_ips: - subnet_id: { get_param: private_subnet } wordpress_floating_ip: type: OS::Neutron::FloatingIP properties: floating_network_id: { get_param: public_net } port_id: { get_resource: wordpress_port } wordpress_instance: type: OS::Nova::Server properties: image: { get_param: image_id } flavor: { get_param: instance_type } key_name: { get_param: key_name } networks: - port: { get_resource: wordpress_port } user_data: str_replace: template: | #!/bin/bash -v apt-get install -y apache2 libapache2-mod-php5 php5 php5-mysql mysql-server-5.5 mysql-server mysql-client wget -c http://wordpress.org/latest.tar.gz tar xvzf wordpress.tar.gz cp -rf wordpress /var/www cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php # Setup MySQL root password and create a user mysql -u root password db_root_password 陕西省信息化工程研究院软件研发部第19页/ 共21页
cat << EOF | mysql -u root --password=db_rootpassword CREATE DATABASE db_name; FLUSH PRIVILEGES; EXIT EOF sed -i s/database_name_here/db_name/ /var/www/wordpress/wp-config.php sed -i s/username_here/db_user/ /var/www/wordpress/wp-config.php sed -i s/password_here/db_password/ /var/www/wordpress/wp-config.php params: db_rootpassword: { get_param: db_root_password } db_name: { get_param: db_name } db_user: { get_param: db_username } db_password: { get_param: db_password } outputs: WebsiteURL: description: URL for Wordpress wiki value: str_replace: template: http://host/wordpress params: host: { get_attr: [wordpress_floating_ip, floating_ip_address] } 执行模板后,会创建一台部署有Wordpress应用的云主机,stack中“概况”用访问的应用地址:
5. 参考文献:
(1) 陈沙克(安装heat,包含实例)
http://www.chenshake.com/openstack-heat-installation-guide/ 陕西省信息化工程研究院软件研发部第20页/ 共21页
(2) OpenStack Heat总结之:Icehouse中通过Heat+Ceilometer实现Autoscaling
http://www.iyunv.com/thread-24495-1-1.html
(3) 臭蛋Openstack Heat 学习
http://www.choudan.net/2014/02/04/Openstack-Heat-?-|?1?.html (4) OpenStack Heat模板学习二之LBaaS(负载均衡即服务) http://www.aboutyun.com/thread-9439-1-1.html (5) 创建一个负载均衡 Apache 网站
http://docs.aws.amazon.com/zh_cn/AWSCloudFormation/latest/UserGuide/example-templates-elb-with-apache.html http://docs.aws.amazon.com/zh_cn/AWSCloudFormation/latest/UserGuide/example-templates-autoscaling.html
陕西省信息化工程研究院软件研发部第21页/ 共21页