openstack中heat组件实现nginx负载均衡

前置操作

1.需要ceilometer监控服务以及alarm监控服务
2.可以将计算节点改造为http文件服务器,yum -y install httpd
特别注意装的是Apache2.4版本,默认没有文件列表,修改/etc/httpd/conf.d/welcome.conf


    Options +Indexes    修改这行
    ErrorDocument 403 /.noindex.html

3.scp /etc/xiandian/* 192.168.100.20:/var/www/html/
4.虚拟机环境控制节点和云主机无法通信
vi /etc/sysconfig/network-scripts/ifcfg-be-ex

DEVICE=br-ex
DEVICETYPE=OVS
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=192.168.200.10
NETMASK=255.255.255.0

修改计算节点注释部分lb-server.yaml

vi /var/www/html/lb-server.yaml

heat_template_version: 2014-10-16
description: A load-balancer server
parameters: 
  pool_id:
    type: string
    description: LBaas Pool to join
  flavor: 
    type: string
    default: m1.small
  image:
    type: string
    default: CentOS7.0    //以glance上传的镜像名字为准
    description: Images
  network_name:
    type: string
    default: int                  //内网名称
    description: Int Network
  server_name:
    type: string
    default: web_server
    description: Server Name
  ftp_yum_url:
    type: string
    description: Yum Url

resources:
  server:                 
    type: OS::Nova::Server
    properties:
      name: {get_param: server_name}
      flavor: {get_param: flavor}
      image: {get_param: image}
      networks:
          - network: {get_param: network_name}
      user_data_format: RAW
      user_data: 
        str_replace: 
          params:
            ftp_yum_url: { get_param: ftp_yum_url}
          template: |
            #!/bin/bash
            mkdir -p /opt/repo
            mv /etc/yum.repos.d/* /opt/repo
            cat > /etc/yum.repos.d/yum.repo <<-EOF
            [centos7]
            name=centos7
            gpgcheck=0
            baseurl=ftp_yum_url
            enabled=1
            EOF

            setenforce 0
            yum clean all

            yum install httpd -y
            systemctl restart httpd
            systemctl enable httpd

  member:
    type: OS::Neutron::PoolMember
    properties:                 
      pool_id: {get_param: pool_id}
      address: {get_attr: [server, first_address]}
      protocol_port: 80

创建栈

栈-创建栈
配置栈1.png

下一步
配置栈.png

创建即可

你可能感兴趣的:(openstack中heat组件实现nginx负载均衡)