F5 BIG-IP负载均衡器配置实例与Web管理界面体验[转载]

Stupig posted @ 2010年7月09日 01:46 in Server with tags F5 服务器 负载均衡 , 2498 阅读

  [文章作者:张宴  转载请注明出自: http://blog.s135.com/f5_big_ip]

   前言:最近一直在对比测试F5 BIG-IP和Citrix NetScaler负载均衡器的各项性能,于是写下此篇文章,记录F5 BIG-IP的常见应用配置方法。

  目前,许多厂商推出了专用于平衡服务器负载的负载均衡器,如F5 Network公司的BIG-IP,Citrix公司的NetScaler。F5 BIG-IP LTM 的官方名称叫做本地流量管理器,可以做4-7层负载均衡,具有负载均衡、应用交换、会话交换、状态监控、智能网络地址转换、通用持续性、响应错误处理、 IPv6网关、高级路由、智能端口镜像、SSL加速、智能HTTP压缩、TCP优化、第7层速率整形、内容缓冲、内容转换、连接加速、高速缓存、 Cookie加密、选择性内容加密、应用攻击过滤、拒绝服务(DoS)攻击和SYN Flood保护、防火墙—包过滤、包消毒等功能。

  以下是F5 BIG-IP用作HTTP负载均衡器的主要功能:

  ①、F5 BIG-IP提供12种灵活的算法将所有流量均衡的分配到各个服务器,而面对用户,只是一台虚拟服务器。

  ②、F5 BIG-IP可以确认应用程序能否对请求返回对应的数据。假如F5 BIG-IP后面的某一台服务器发生服务停止、死机等故障,F5会检查出来并将该服务器标识为宕机,从而不将用户的访问请求传送到该台发生故障的服务器 上。这样,只要其它的服务器正常,用户的访问就不会受到影响。宕机一旦修复,F5 BIG-IP就会自动查证应用已能对客户请求作出正确响应并恢复向该服务器传送。

  ③、F5 BIG-IP具有动态Session的会话保持功能。

  ④、F5 BIG-IP的iRules功能可以做HTTP内容过滤,根据不同的域名、URL,将访问请求传送到不同的服务器。


   下面,结合实例,配置F5 BIG-IP LTM v9.x:

F5

   ①、如图,假设域名blog.s135.com被解析到F5的外网/公网虚拟IP:61.1.1.3(vs_squid),该虚拟IP下有一个服务器池 (pool_squid),该服务器池下包含两台真实的Squid服务器(192.168.1.11和192.168.1.12)。

  ②、如果 Squid缓存未命中,则会请求F5的内网虚拟IP:192.168.1.3(vs_apache),该虚拟IP下有一个默认服务器池 (pool_apache_default),该服务器池下包含两台真实的Apache服务器(192.168.1.21和192.168.1.22), 当该虚拟IP匹配iRules规则时,则会访问另外一个服务器池(pool_apache_irules),该服务器池下同样包含两台真实的Apache 服务器(192.168.1.23和192.168.1.24)。

  ③、另外,所有真实服务器的默认网关指向F5的自身内网IP,即 192.168.1.2。

  ④、所有的真实服务器通过SNAT IP地址61.1.1.4访问互联网。


  详细配置步骤:

  一、登录到F5 BIG-IP管理界面:

  1、初次使用:

  ①、打开F5 BIG-IP电源,用一根网线(直连线和交叉线均可)连接F5 BIG-IP的3.1管理网口和笔记本电脑的网口,将笔记本电脑的IP地址配置为“192.168.1.*”,子网掩码配置为 “255.255.255.0”。

  ②、用浏览器访问F5 BIG-IP的出厂默认管理IP地址https://192.168.1.245https://192.168.245.245

  ③、输入出厂默认用户名:admin,密码:admin

  ④、点击Activate进入F5 BIG-IP License申请与激活页面,激活License。

  ⑤、修改默认管理密码。

  2、以后登录:

   通过F5 BIG-IP的自身外网IP登录。

  ①、假设设置的F5自身外网IP为61.1.1.2,就可以通过https://61.1.1.2/登录。

  ②、还可以通过SSH登录,用户名为root,密码跟Web管理的密码相同。


  二、创建两个 VLAN:internal和external,分别表示内网和外网。

  ★创建VLAN演示页面:http://blog.s135.com/book/f5/vlan_create.htm

  ★VLAN列表演示页面:http://blog.s135.com/book/f5/vlan_list.htm

  1、创建VLAN:internal(内网)

  在“Network→VLANs”页面点击 “create”按钮:

  ①、Name栏填写:internal(填一个英文名称)

  ②、Tag栏填写:4093(填一个数字)

  ③、Interfaces栏:将Available列的“1.1”拉到Untagged列。1.1表示F5 BIG-IP的第一块网卡。   

  2、创建VLAN:external(外网)

  在“Network→VLANs”页面点击 “create”按钮创建VLAN:

  ①、Name栏填写:internal(填一个英文名称)

  ②、Tag栏填写:4094(填一 个数字)

  ③、Interfaces栏:将Available列的“1.2”拉到Untagged列。1.2表示F5 BIG-IP的第二块网卡。


  三、创建F5 BIG-IP的自身IP:分别对应internal(内网)和external(外网)。

  ★创建自身IP演示页面:http://blog.s135.com/book/f5/selfip_create.htm

  1、创建自身内网IP:192.168.1.2

  在“Network→Self IPs”页面点击“create”按钮:

  ①、IP Address栏填写:192.168.1.2(填内网IP地址)

  ②、 Netmask栏填写:255.255.255.0(填内网子网掩码)

  ③、VLAN栏选择:internal

  ④、Port Lockdown栏选择:Allow Default(默认值)  

  2、创建自身外网IP:61.1.1.2

  在“Network→Self IPs”页面点击“create”按钮:

  ①、IP Address栏填写:61.1.1.2(填外网IP地址)

  ②、Netmask栏填写:255.255.255.0(填外网子网掩码)

  ③、VLAN栏选择:external

  ④、Port Lockdown栏选择:Allow Default(默认值)


  四、创建默认网关路由

  ★ 创建默认网关路由演示页面:http://blog.s135.com/book/f5/routes_create.htm

  1、创建默认网关路由

  在“Network→Routes”页面点击“create”按钮:

  ①、Type栏选择:Default Gateway(默认值)

  ②、Resource栏选择:Use Gateeay...,在其后的输入框填写网关IP地址:61.1.1.1(这里假设此IP为外网网关地址)


  五、 创建服务器自定义健康检查

  ★创建服务器自定 义健康检查演示页面:http://blog.s135.com/book/f5/monitors_create.htm

   1、创建自定义HTTP健康检查:monitor_http

  在“Local Traffic→Monitors”页面点击“create”按钮:

  ①、Name栏填写:monitor_http(填一个英文名称)

  ②、Type栏选择:HTTP

  ③、Import Settings栏选择:HTTP

  ④、Interval栏填写:5(表示每5 秒钟进行一次健康检查)

  ⑤、Timeout栏填写:16(表示健康检查的连接超时时间为16秒)

  ⑥、Send String栏填写:GET /(也可以根据自己的需求发送其他方法的请求,例如HEAD /或者GET /index.htm)

  ⑦、 Receive String栏填写:(填写对应的返回字符串,默认不填写)


  六、创建服务器池 (pool)

  ★创建服务器池演示页面:http://blog.s135.com/book/f5/pools_create.htm

   1、创建Squid服务器池:pool_squid

  在“Local Traffic→Pools”页面点击“create”按钮:

  ①、Name栏填写:pool_squid(填一个英文名称)

  ②、 Health Monitors栏:将第四步创建的自定义HTTP健康检查“monitor_http”由Available列拉到Active列

  ③、Load Balancing Method栏选择:Round Robin(这里选择的负载均衡方式是轮询,也可以选择其他方式)

  ④、New Members栏:先选择New Address,再添加两台Squid服务器的IP地址192.168.1.11、192.168.1.12以及它们的端口80

  2、 创建第一组Apache服务器池:pool_apache_default

  在“Local Traffic→Pools”页面点击“create”按钮:

  ①、Name栏填写:pool_apache_default(填一个英文名 称)

  ②、Health Monitors栏:将第四步创建的自定义HTTP健康检查“monitor_http”由Available列拉到Active列

  ③、 Load Balancing Method栏选择:Round Robin(这里选择的负载均衡方式是轮询,也可以选择其他方式)

  ④、 New Members栏:先选择New Address,再添加第一组两台Apache服务器的IP地址192.168.1.21、192.168.1.22以及它们的端口80

  3、创建第二组Apache服务器池:pool_apache_irules

  在“Local Traffic→Pools”页面点击“create”按钮:

  ①、Name栏填写:pool_apache_irules(填一个英文名称)

  ②、Health Monitors栏:将第四步创建的自定义HTTP健康检查“monitor_http”由Available列拉到Active列

  ③、Load Balancing Method栏选择:Round Robin(这里选择的负载均衡方式是轮询,也可以选择其他方式)

  ④、New Members栏:先选择New Address,再添加第二组两台Apache服务器的IP地址192.168.1.23、192.168.1.24以及它们的端口80


  七、创建供七层负载均衡使用的Profiles配置

  ★创建Profiles演示页面:http://blog.s135.com/book/f5/profiles_create.htm

  1、创建Profiles配置:profile_http

  在“Local Traffic→Profiles”页面点击“create”按钮:

  ①、Name栏填写:profile_http(填一个英文名称)

  ②、Parent Profile栏选择:HTTP

  ③、Insert XForwarded For栏:如果需要,可以选中方框,选择Enable(在Header头中插入x-forwarded-for标记,以便做七层负载均衡时能够获取用户真 实IP,本文中Squid服务器开启了follow_x_forwarded_for allow all,因此F5无需设置此项)

   注:在此设置页面中,还有压缩等优化功能,可以根据需要进行设置。


  八、创建iRules规则

  ★创建iRules规则演示页面:http://blog.s135.com/book/f5/irules_create.htm

   1、创建iRules规则:irules_apache

  在“Local Traffic→Profiles”页面点击“create”按钮:

  ①、Name栏填写:irules_apache(填一个英文名称)

  ②、Definition栏填写以下脚本,将访问的域名为“blog.s135.com”,访问的网址以“.htm”结尾,或者以 “/read.php”开头的请求全部转到服务器池“pool_apache_irules”: view plainprint?

when HTTP_REQUEST {  
  if {[HTTP::host] equals "blog.s135.com" and [HTTP::uri] ends_with ".htm"} {  
  pool pool_apache_irules  
  }  
  elseif {[HTTP::host] equals "blog.s135.com" and [HTTP::uri] starts_with "/read.php"} {  
  pool pool_apache_irules  
  }  
}  


  九、创建虚拟服务器(Virtual Servers)

  ★创建虚拟服务器演示页面:http://blog.s135.com/book/f5/vs_create.htm

  1、以“四层”负载均衡模式创建Squid虚拟服务器:vs_squid

  在“Local Traffic→Virtual Servers”页面点击“create”按钮:

  ⑴、General Properties大类下:

  ①、Name栏填写:vs_squid(填一个英文名称)

  ②、Destination栏:选择Host,填写Squid服务器的外网虚拟 IP(Virtual IP,简称VIP):61.1.1.3

  ③、Service Port栏填写:80

  ⑵、 Configuration大类下:

  ①、Configuration栏选择: Advanced(选择高级模式,这一步很重要)

  ②、Type栏选择:Performance (Layer 4)

  ③、SNAT Pool栏选择:None(注意:这一步很重要,四层模式下,请确保此项选择为None)

  ⑶、Resources大类下:

  ①、Default Pool栏选择:pool_squid

  注意:F5的四层负载均衡由硬件芯片处理,不消耗CPU资源,能够处理 更大的访问量。在四层负载均衡模式下,真实服务器的默认网关必须指向F5的自身内网IP,即192.168.1.2

  2、 以“七层”负载均衡模式创建Apache虚拟服务器:vs_apache

  在“Local Traffic→Virtual Servers”页面点击“create”按钮:

  ⑴、General Properties大类下:

  ①、Name栏填 写:vs_apache(填一个英文名称)

  ②、Destination栏:选择Host,填写Apache服务器的内网虚拟 IP(Virtual IP,简称VIP):192.168.1.3

  ③、Service Port栏填写:80

  ⑵、 Configuration大类下:

  Configuration栏选择: Advanced(选择高级模式,这一步很重要)

  ①、 Type栏选择:Standard(标准模式,即七层负载均衡模式)

  ②、HTTP Profile栏选择:profile_http(注意:此项为None时,不能使用iRules规则,因此必须选一个。在此选择第六步创建的 profile_http)

  ③、SNAT Pool栏选择:Auto Map(注意:在本文的架构中必须选择,原因如下)

  说明: 当其中的一台Squid服务器“192.168.1.11”缓存未命中时,会去访问虚拟IP“192.168.1.3”。如果SNAT Pool选择默认值None,虚拟IP“192.168.1.3”后端的Apache服务器,看到的将是Squid服务器的真实 IP“192.168.1.11”。由于Squid和Apache服务器的IP地址属于在同一网段,Apache服务器将无需经过F5网关 “192.168.1.2”,直接通过交换机回包给Squid服务器“192.168.1.11”,这样虚拟IP“192.168.1.3”就会收不到回 包信息,HTTP请求无法完成。因此,需要选择Auto Map,进行地址转换,让后端Apache服务器看到的是F5的自身内网IP,回包给F5。

  ⑶、Resources大类下:

  ①、iRules栏:将Available列的“irules_apache”拉到Enabled列。

  ②、Default Pool栏选择:pool_apache_default

  ⑷、Apache虚拟服务器──vs_apache 创建完成后,如需进行修改,在以下两个配置页完成:

  ★修改虚拟 服务器演示页面1:http://blog.s135.com/book/f5/vs_properties.htm

  ★修改虚拟服务器演示页面2:http://blog.s135.com/book/f5/vs_resources.htm


  十、创建SNAT安全网络地址转换,让真实服务器能够访问互联网、对外发邮件

  ★创建SNAT演示页面:http://blog.s135.com/book/f5/snat_create.htm

  1、创建SNAT:snat_all_server

  在“Local Traffic→SNATs”页面点击“create”按钮:

  ①、Name栏填写:snat_all_server(填一个英文名称)

  ②、Translation栏选择:IP Address,并填写SNAT IP地址:61.1.1.4(此项也可以选择Automap,使用F5的自身外网IP作为SNAT IP)

  ③、Origin栏选 择:Address List

  ④、Address List栏:①Type栏选择host,填写要访问互联网、对外发邮件的内网IP地址。②或者Type栏选择Network,填写要访问互联网、对外发邮 件的网段和子网掩码。

  ⑤、VLAN Traffic栏选择:Enabled on...

  ⑥、VLAN List栏:将Available列的“internal”拉到Selected列。

  注意:真实服务器的默认网关需要指向F5的自身 内网IP,即192.168.1.2,才能通过SNAT访问互联网、对外发邮件。


  附1:F5 BIG-IP LTM 配置手册(中文简化版)

      《F5 BIG-IP LTM 配置手册(英文详细版)

  附2:使用F5 BIG-IP作为负载均衡器的部分国内网站:

点击在新窗口中浏览此图片

AAA 说:
2021年8月09日 21:17

I would like to say that this blog really convinced me to do it! Thanks, very good post. Online pharmacy technician classes

BASIT 说:
2021年8月15日 15:25

You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! buy google voice for verification

dfg` 说:
2021年8月22日 17:58

That'sthe rationale advertising and marketing for you to proper studying before writing. Also, it is attainable to write down superior writing because of this. สล็อต

dfg` 说:
2021年8月25日 21:14

Wow, excellent post. I'd like to draft like this too - taking time and real hard work to make a great article. This post has encouraged me to write some posts that I am going to write soon. buy youtube subscribers

dfg` 说:
2021年8月26日 22:51

This process is definitely confidently seriously the best choice. Every one with incredibly small streaks will be expected via a variety of tradition capabilities. I like to recommend software program such a large amount. video pokies

dfg` 说:
2021年9月11日 17:02

You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. krt carts

dfg` 说:
2021年9月12日 14:32

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. 美国代写被抓

dfg` 说:
2021年9月13日 12:10

I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. Situs Slot Gacor 2021

dfg` 说:
2021年9月13日 16:01

Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. 먹튀사이트

dfg` 说:
2021年9月14日 14:25

I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading, I had to go show it to my friend and he ejoyed it as well! play slots doubledown casino free chips

dfg` 说:
2021年10月08日 00:12 i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. white label real estate crowdfunding software
dfg` 说:
2021年10月12日 22:17

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work... VPN검증

dfg` 说:
2021年10月28日 23:33

Interesting and interesting information can be found on this topic here profile worth to see it. buy viagra with cialis combination pill

satac key dates 说:
2021年11月01日 17:50

메이저사이트 메이저놀이터에서는 스포츠 종목으로 축구,야구,농구에 대한 배팅이 가능하면서 먹튀가 존재하지 않는 사이트를 일컫는 명칭입니다.

satac key dates 说:
2021年11月03日 20:08

توصيل مياه للمنازل رشــفة متجــر وتطبيــق الكترونــي مختــص فــي بيــع وتوصيــل ميــاه الشــرب الــى المنــازل او المســاجد او أي مــكان تحددونــه مــن خــال وســائل النقــل التــي نمتلكهــا بالإضافــة الــى مســتودعاتنا المنتشــرة فــي عمــوم المملكــة لضمــان الســرعة والكفــاءة بالعمــل كل ذلــك عــن طريـق تطبيـق بتصميم بسـيط سـهل الإ

satac key dates 说:
2021年11月03日 22:04

best website design & development agency Charlotte NC We're not just another website company. Evolution in technology is continually transforming how businesses operate and how people interact with the world.

satac key dates 说:
2021年11月04日 16:23

https://soap2day.eus/ Soap2day is a FREE Movie Streaming site to watch movies and tv series. Soap2dayto, soap2day to, soap 2 day, soaptoday is free and safe to use.

satac key dates 说:
2021年11月04日 21:45

Best Vendor risk management software in UK LEVIZO provide Third-party risk management services in UK, Information security services in UK and Information risk management Services in UK. Contact us today for more details and quotation.

AAA 说:
2022年5月19日 03:37

Dale, played by Charlie Day, probably has the least horrible boss in Jennifer Aniston, playing a completely different character than people are used to seeing her in. crypto exchange service Hello! I just now would choose to make a massive thumbs up for any great info you've got here with this post. I am returning to your blog site for further soon. bouncy house rentals roseville It's not the case that reader must be completely agreed with author's views about article. So this is what happened with me, anyways it's a good effort, I appreciate it. Thanks intercambio de criptomonedas You ought to indulge in a contest for just one of the best blogs on-line. I will recommend this page! btc a usdt comprar

NCERT Evs Sample Pap 说:
2022年9月28日 13:26

Environmental Education or Environmental Studies (EVS) was introduced from the foundation of education to enable students to understand the situations occurring around our surroundings without any difficulties. NCERT Evs Sample Paper Class 2 The subject refers to the neighbouring in which all life, also makes use of to solve day-to-day challenges involving the environmental elements.To get a complete analysis of examination question pattern and to get ready to write an exam with confidence, subject experts of the NCERT has provided the Class 2 EVS Sample Paper 2023 with study & learning material that supports all formats of exams held under Term-1, Term-2 and other types of exams for every interested candidate.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter