您的位置:首页 > 其它

阿里云SLB配置

2018-03-21 15:17 295 查看

一、简介

负载均衡(Server Load Balancer)是对多台云服务器进行流量分发的负载均衡服务。负载均衡可以通过流量分发扩展应用系统对外的服务能力,通过消除单点故障提升应用系统的可用性。

二、配置SLB

1.购买SLB并接入交换机

公网SLB是可以直接分发到内网服务器的,这样可以不占用公网带宽。

这里使用内网SLB示例,因为免费。

2.配置后端服务器

(1)环境介绍

ip环境
172.17.198.246SLB的分发ip
172.17.198.242单机LNMP
172.17.198.238单机LNMP
(2)配置

ip权重文件
172.17.198.2421index.php
172.17.198.2383inex.html
3.配置端口

前端端口80,分发到后端服务器的80端口。

4.写入访问文件并且配置nginx

[root@172.17.198.238 test]# cat index.html
test 2018

[root@172.17.198.242 test]# cat index.php
<?php
phpinfo();
?>


三、访问

1.使用curl -H “Host:zwwl.test.com”指定域名测试,负载均衡配置成功。

[root@zhangwan22222222 ~]# curl 172.17.198.246:80 -H "Host:zwwl.test.com"
test 2018
[root@zhangwan22222222 ~]# curl 172.17.198.246:80 -H "Host:zwwl.test.com"
test 2018
[root@zhangwan22222222 ~]# curl 172.17.198.246:80 -H "Host:zwwl.test.com"
test 2018
[root@zhangwan22222222 ~]# curl 172.17.198.246:80 -H "Host:zwwl.test.com"|less
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>;
<style type="text/css">
body {background-color: #fff; color: #222; font-family: sans-serif;}
pre {margin: 0; font-family: monospace;}
a:link {color: #009; text-decoration: none; background-color: #fff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse; border: 0; width: 934px; box-shadow: 1px 2px 3px #ccc;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: