Saltstack Web Platform Cluster Deployment (3)---HAPROXY+KEEPALIVE+HTTPD deployment

Source: Internet
Author: User
Tags haproxy saltstack

Last article we talked about the deployment and configuration of Haproxy

Let's talk about how to use keepalive and httpd to implement the Saltstack cluster deployment of the HAPROXY+KEEPALIVE+HTTPD Web architecture

First of all our HTTP deployment, very simple answer oh, the direct yum installation is complete, but in our saltstack is to use the installed definition of the line.

OK, let's get up.

[email protected] http]# pwd
/srv/salt/prod/http
[email protected] http]# cat Install.sls
Include
-Pkg.pkg-init

Httpd-install:
Pkg.installed:
-Names:
-httpd
-Httpd-devel

It's not very simple, let's get it started underneath.

[[email protected]cluster]# pwd
/srv/salt/prod/cluster
[[email protected]cluster]# Cat Http.sls
Include
-Http.install

Http-service:
File.managed:
-Name:/etc/httpd/conf/httpd.conf
-Source:salt://cluster/files/httpd.conf
-User:root
-Group:root
-mode:644
Service.running:
-NAME:HTTPD
-Enable:true
-Reload:true
-UNLESS:NETSTAT-LNTP |awk-f ': ' {print $4} ' | grep 8080

Let's get the keepalived installation file below.

[[email protected]keepalived]# pwd
/srv/salt/prod/keepalived
[[email protected]keepalived]# Cat Install.sls
Keepalived-install:
File.managed:
-Name:/usr/local/src/keepalived-1.2.17.tar.gz
-Source:salt://keepalived/files/keepalived-1.2.17.tar.gz
-mode:755
-User:root
-Group:root
Cmd.run:
-Name:cd/usr/local/src && tar zxf keepalived-1.2.17.tar.gz && cd keepalived-1.2.17 &&./configu Re--prefix=/usr/local/keepalived--disable-fwmark && make && make install
-Unless:test-d/usr/local/keepalived
-Require:
-File:keepalived-install

/etc/sysconfig/keepalived:
File.managed:
-Source:salt://keepalived/files/keepalived.sysconfig
-mode:644
-User:root
-Group:root

/etc/init.d/keepalived:
File.managed:
-Source:salt://keepalived/files/keepalived.init
-mode:755
-User:root
-Group:root

Keepalived-init:
Cmd.run:
-Name:chkconfig--add keepalived
-Unless:chkconfig--list | grep keepalived
-Require:
-File:/etc/init.d/keepalived

/etc/keepalived:
File.directory:
-User:root
-Group:root

Different people, defined in a different way, but the effect of the implementation is the same. This configuration is a simple answer, it is not described here specifically. There is an installation package in the attachment.

The installation section is complete, let's start the section below. Let's just put it under the cluster directory.

[[email protected]cluster]# pwd
/srv/salt/prod/cluster
[[email protected]cluster]# Cat Haproxy-outside-keepalived.sls # #为了区分是haproxy外网的配置
Include
-Keepalived.install
Keepalived-server:
File.managed:
-Name:/etc/keepalived/keepalived.conf
-Source:salt://cluster/files/haproxy-outside-keepalived.conf
-mode:644
-User:root
-Group:root
-Template:jinja
{% if grains[' fqdn '] = = ' test1 '%}
-Routeid:haproxy_ha
-Stateid:master
-priorityid:150
{% elif grains[' FQDN '] = = ' test2 '%}
-Routeid:haproxy_ha
-Stateid:backup
-priorityid:100
{% ENDIF%}
Service.running:
-Name:keepalived
-Enable:true
-Watch:
-File:keepalived-server

Here we briefly explain, first of all, the use of the Jinja template, using pillar to define the

Below is the configuration file for keepalived

[[email protected]files]# pwd
/srv/salt/prod/cluster/files
[[email protected]files]# Cat haproxy-outside-keepalived.conf
! Configuration File for Keepalived
Global_defs {
Notification_email {
[email protected]
}
Notification_email_from[email protected]
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
router_id {{Routeid}}
}

Vrrp_instance Haproxy_ha {
State {{Stateid}}
Interface eth0
VIRTUAL_ROUTER_ID 36
Priority {{Priorityid}}
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
virtual_ipaddress {
10.0.0.11
}
}

Execute Salt ' * ' State.sls cluster.haproxy-outside-keepalived env=prod test=true

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

And, of course, we add it to top to define it. Then it's done. Deployment of the Web platform cluster.

[[email protected]base]# pwd
/srv/salt/base
[[email protected]base]# Cat Top.sls
Base
‘*‘:
-Init.env_init

Prod
' test[1,2] ':
-Cluster.haproxy-outside-keepalived
-Cluster.haproxy-outside
-Cluster.http
[[email protected]base]# Salt ' * ' state.highstate test=true

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>


This article is from the "Share Knowledge" blog, so be sure to keep this source http://shark2013.blog.51cto.com/4170472/1714507

Saltstack Web Platform Cluster Deployment (3)---HAPROXY+KEEPALIVE+HTTPD deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.