配置一个代理医管局对 Cloudstack

来自Chinese Ikoula Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

zh:配置一个代理医管局对 Cloudstack he:הגדר פרוקסי HA-Cloudstack ro:Configuraţi un Proxy HA pe Cloudstack ru:Настроить прокси на Cloudstack pl:Konfigurowanie serwera Proxy HA w Cloudstack ja:Cloudstack で HA プロキシを構成します。 ar:تكوين وكيل هكتار في كلودستاك de:Konfigurieren Sie einen Proxy HA auf Cloudstack nl:Configureer een Proxy HA op Cloudstack it:Configurare un Proxy HA Cloudstack pt:Configurar um Proxy HA em Cloudstack es:Configurar a un Proxy HA de Cloudstack en:Configure a Proxy HA on Cloudstack fr:Configurer un HA Proxy sur Cloudstack

这篇文章是从由软件进行自动翻译。你可以看到这篇文章的源代码

介绍

您想要配置 医管局代理 在 Cl或 dstack 平台上。这篇文章将解释的方法通过一个示例配置。

执行

在这里是为了执行接下来的程序 医管局代理 在 Debian 的实例上 8 "杰西 " 根据 Cl或 dstack。
注意 :这种方法也适用于框架的一项专门条文 .

创建新的实例 HAProxy

你会发现程序用于创建实例 Cl或 dstack en 直接路由 fr:Deploiement d'une instance en zone direct-routing 和在 提前路由 fr:Deploiement d'une instance en zone advanced-routing

配置新实例 HAProxy

现在开始我们的 VM

InfoVM.png

我们可以从综合控制台或 ssh 连接

ConnectVM.png

系统必备组件

前提之一是维护其系统最新情况。

 apt-get update
 apt-get upgrade 

你 Debian 的系统保持最新,请确保你有官方资料库的列表。你可以找到在 Ikoula 资料库和安装说明的可用列表 a 这个地址.

警告 : 在对您的系统进行任何更改之前仍在努力筹划 备份 您的文件时处理不当。
服务器 生产,认为执行这些操作,在非高峰时段,尽量减少影响你的行动。

我们的实例安装 负载平衡 根据 Cloudstack 我们需要服务 医管局代理 .

医管局代理设置

若要安装医管局代理版本 1.5在您的终端中运行下面的命令
 apt-get install haproxy 
如果你想要的医管局代理版本最新版本 1.6运行以下命令
# Ajout du repo
echo deb http://httpredir.debian.org/debian jessie-backports main | tee /etc/apt/sources.list.d/backports.list
apt-get install debian-keyring
# Recuperation de la cle gpg
gpg --keyring /usr/share/keyrings/debian-keyring.gpg --export bernat@debian.org |  apt-key add -
# Mise a jour des depots
apt-get update
# Installation de haproxy
apt-get install haproxy -t jessie-backports-1.6

医管局代理激活

医管局代理现在安装,我们现在通过更改已启用值来启用它 =0 通过启用 =1 在这两个文件 /etc/default/haproxy et /etc/init.d/haproxy
# activation de HA Proxy dans /etc/default/haproxy
sed -i "s/ENABLED=0/ENABLED=1/g" /etc/default/haproxy
# activation de 医管局代理  dans /etc/init.d/haproxy
sed -i "s/ENABLED=0/ENABLED=1/g" /etc/init.d/haproxy

医管局代理配置

医管局代理执行配置文件中 /etc/haproxy/haproxy.cfg .

下面是一个示例配置 d 'HAProxy
global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        user haproxy
        group haproxy
        daemon
 
defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        contimeout 5000
        clitimeout 50000
        srvtimeout 50000
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http
 
listen cluster_web xxx.xxx.xxx.xxx:80

        mode http

        balance roundrobin
 

        option httpclose
        option forwardfor
 

        server web1 yyy.yyy.yyy.yyy:80 check
        server web2 zzz.zzz.zzz.zzz:80 check
 

        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats auth ikoula:ikoula
        stats uri  /stats

Ip 地址登陆的 ip 地址是我们 服务器 负载平衡、 yyy.yyy.yyy.yyy 和 zzz.zzz.zzz.zzz 地址是我们 服务器后面的 web s 负载平衡器 .

listen cluster_web 地址和端口的医管局代理服务将需要侦听连接。
mode 摆动模式,在我们的示例 http 为 web
balance 用于负载分布,在我们的示例封合写的算法
可用的值是 : 封合写,源,至少连接,第一反应
server 宣言 》 的各种服务器背后我们 负载平衡器 在我们的示例 web1 et web2.
stats 将 stats 页的访问配置 负载平衡器
在我们的示例页面将可对登陆 /与统计 ikoula/ikoula 如登录名和密码

医管局代理开始

我们现在可以开始 医管局代理
 service haproxy start 

ou

 etc/init.d/haproxy start 
让我们对我们登陆 ip /统计数据,并利用我们的登录名和密码我们准时医管局代理管理页。

HAProxyStats.png

我们现在可以连接到我们 服务器在 s SSH 打字
# Serveur web1
ssh root@yyy.yyy.yyy.yyy
# Serveur web2
ssh root@zzz.zzz.zzz.zzz

配置 服务器web s

如果 服务器s 还没有它不安装的 web 服务,例如
 apt-get install apache2 php5 
一旦安装了 web 服务,或者如果 服务器 已经有了一个 web 1 和 web 2 在统计信息页中以绿色显示

HAProxyStat2.png

如果您尝试访问 服务器 使用地址 xxx.xxx.xxx 你落在测试页 服务器 web1 或 web 2 根据分配做

HAProxSite.png

配置持久性

通过源 IP 持久性

为了配置持久性的源 ip 地址只需更改平开医管局代理配置文件中的通过添加选项 .

启用的源 ip 地址通过持久性 棍子表 这是与我们的配置示例
listen cluster_web xxx.xxx.xxx.xxx:80

        mode http

       # Modifier le mode de balancement
       balance source
       hash-type consistent

       # Ajouter une stick-table afin de garder en mémoire les IP
       stick-table type ip size 1m expire 1h
       stick on src

        option httpclose
        option forwardfor

        server web1 yyy.yyy.yyy.yyy:80 check
        server web2 zzz.zzz.zzz.zzz:80 check

        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats auth utilisateur:motdepasse
        stats uri  /stats

上面的示例允许实现持久性的 负载平衡 基于用户的 IP。通过确保这种持久性 棍子表 谁还记得有联系的 IPS 服务器.
stick-table 有一个大小为 1MB 和过期每小时。当用户连接到 服务器 它仍然是在这同一 服务器 直到期满的表或在出现错误时的 服务器.

注意 : 所需的内存 stick-table 相对较低,在范围内 25.000 针对 1MB。要么 40MB 1.000.000 IP 地址。

通过 Cookie 持久性

另一种方法,以确保持续是秋千的使用 cookie。Cookie 是为了存储的信息在用户的计算机上放置一个小文件 服务器.

方法 cookie 插入

第一个示例就是一个专门设计的附加 cookie 到创造 医管局代理 .

编辑医管局代理配置文件,并将以下行添加到我们的配置
listen cluster_web xxx.xxx.xxx.xxx:80

        mode http

        # Modifier le mode de balancement
        balance roundrobin

        # option du cookie
        cookie SRVNAME insert indirect nocache

        option httpclose
        option forwardfor

        server web1 yyy.yyy.yyy.yyy:80 cookie WeB1 check
        server web2 zzz.zzz.zzz.zzz:80 cookie WeB2 check

        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats auth utilisateur:motdepasse
        stats uri  /stats

上面的示例允许执行我们通过专用的 cookie 持久性会话。当连接 负载平衡器 将客户端定向到两个之一 服务器s 和添加称为一个 cookie, SRVNAME 与值 WeB1 ou WeB2 之后的分布作。
选项 间接 防止产生一个 cookie,如果另一个有效的 cookie 已存在为访问者和 使用 NoCache 避免了缓存的 cookie 之间第位访客和 负载平衡器 .
HACookieInsert.png

方法 cookie 前缀

第二个例子是一个预先存在的 cookie 预 fixage,这个方法会很有用,如果你想要只上一些饼干的持久性,或你不想创建一个专用的 cookie 到 HA Proxy.

编辑医管局代理配置文件,并将以下行添加到我们的配置
listen cluster_web xxx.xxx.xxx.xxx:80

        mode http

        # Modifier le mode de balancement
        balance roundrobin

        # option du cookie
        cookie PHPSESSID prefix indirect nocache

        option httpclose
        option forwardfor

        server web1 yyy.yyy.yyy.yyy:80 cookie WeB1 check
        server web2 zzz.zzz.zzz.zzz:80 cookie WeB2 check

        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats auth utilisateur:motdepasse
        stats uri  /stats

上面的示例允许设立的我们通过前缀对现有的 cookie 的会话持久性。当连接 负载平衡器 将客户端定向到两个之一 服务器s 将前缀添加到命名的 cookie PHPSESSID 与值 WeB1 ou WeB2 之后的分布作。
选项 indirect 防止产生一个 cookie,如果另一个有效的 cookie 已存在为访问者和 nocache 避免了缓存的 cookie 之间第位访客和 负载平衡器 .
HACookiePrefix.png

配置 保持

根据您的配置,您可能需要激活 保持 .

保持  允许对  负载平衡器  重用之间的现有连接  服务器 和用户,而不是启动一个新的连接,为每个请求。
编辑医管局代理配置文件,并将以下行添加到我们的配置
listen cluster_web xxx.xxx.xxx.xxx:80

        mode http

        balance roundrobin

        # Modifier la directive de fermeture
        option http-server-close
        # Ajouter un delai de 3000 secondes avant fermeture
        timeout http-keep-alive 3000

        option forwardfor

        server web1 yyy.yyy.yyy.yyy:80 check
        server web2 zzz.zzz.zzz.zzz:80 check

        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats auth utilisateur:motdepasse
        stats uri  /stats

实施 SSL 管理

它可能有助于建立 SSL 重定向你网站管理,例如,在具有空间安全的网站。
为了执行 HTTP 重定向 -> 在他的 HTTPS HA Proxy 文档是可用: fr: Mettre en place une redirection SSL HA Proxy



您未被允许发表评论。