热门IT资讯网

如何直接用keepalived实现企业级WEB的负载均衡高可用性

发表于:2024-11-27 作者:热门IT资讯网编辑
编辑最后更新 2024年11月27日,下文给大家带来如何直接用keepalived实现企业级WEB的负载均衡高可用性,希望能够给大家在实际运用中带来一定的帮助,负载均衡涉及的东西比较多,理论也不多,网上有很多书籍,今天我们就用在行业内累计

下文给大家带来如何直接用keepalived实现企业级WEB的负载均衡高可用性,希望能够给大家在实际运用中带来一定的帮助,负载均衡涉及的东西比较多,理论也不多,网上有很多书籍,今天我们就用在行业内累计的经验做一个解答。

③编辑keepalived.conf文件,直接用keepalived实现负载均衡及高可用性。

a)Keepalved的安装

a)Keepalved的安装

  1. #wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz

  2. #tar zxvf keepalived-1.1.15.tar.gz

  3. #cd keepalived-1.1.15

  4. #./configure

  5. #make

  6. #make install

将keepalived做成启动脚务,方便管理:

  1. #cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/

  2. #cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

  3. #mkdir /etc/keepalived

  4. #cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

  5. #cp /usr/local/sbin/keepalived /usr/sbin/

  6. #service keepalived start|stop

b)Keealived的配置

①分别在主从负载均衡云服务器上配置keepalived.conf ,内容分别如下:

  1. ! Configuration File for keepalived

  2. global_defs {

  3. notification_email {

  4. [email protected]

  5. }

  6. notification_email_from [email protected]

  7. smtp_server 127.0.0.1

  8. router_id LVS_DEVEL

  9. }

  10. vrrp_instance VI_1 {

  11. state MASTER

  12. interface eth0

  13. virtual_router_id 51

  14. priority 100

  15. advert_int 1

  16. authentication {

  17. auth_type PASS

  18. auth_pass 1111

  19. }

  20. virtual_ipaddress {

  21. 192.168.5.188

  22. }

  23. }

  24. virtual_server 192.168.5.188 80 {

  25. delay_loop 6

  26. lb_algo wrr

  27. lb_kind DR

  28. persistence_timeout 60

  29. protocol TCP

  30. real_server 192.168.5.104 80 {

  31. weight 3

  32. TCP_CHECK {

  33. connect_timeout 10

  34. nb_get_retry 3

  35. delay_before_retry 3

  36. connect_port 80

  37. }

  38. }

  39. real_server 192.168.5.105 80 {

  40. weight 3

  41. TCP_CHECK {

  42. connect_timeout 10

  43. nb_get_retry 3

  44. delay_before_retry 3

  45. connect_port 80

  46. }

  47. }

  48. }

  1. ! Configuration File for keepalived

  2. global_defs {

  3. notification_email {

  4. [email protected]

  5. }

  6. notification_email_from [email protected]

  7. smtp_server 127.0.0.1

  8. router_id LVS_DEVEL

  9. }

  10. vrrp_instance VI_1 {

  11. state BACKUP

  12. interface eth0

  13. virtual_router_id 51

  14. priority 99

  15. advert_int 1

  16. authentication {

  17. auth_type PASS

  18. auth_pass 1111

  19. }

  20. virtual_ipaddress {

  21. 192.168.5.188

  22. }

  23. }

  24. virtual_server 192.168.5.188 80 {

  25. delay_loop 6

  26. lb_algo wrr

  27. lb_kind DR

  28. persistence_timeout 60

  29. protocol TCP

  30. real_server 192.168.5.104 80 {

  31. weight 3

  32. TCP_CHECK {

  33. connect_timeout 10

  34. nb_get_retry 3

  35. delay_before_retry 3

  36. connect_port 80

  37. }

  38. }

  39. real_server 192.168.5.105 80 {

  40. weight 3

  41. TCP_CHECK {

  42. connect_timeout 10

  43. nb_get_retry 3

  44. delay_before_retry 3

  45. connect_port 80

  46. }

  47. }

  48. }

看了以上关于如何直接用keepalived实现企业级WEB的负载均衡高可用性,如果大家还有什么地方需要了解的可以在行业资讯里查找自己感兴趣的或者找我们的专业技术工程师解答的,技术工程师在行业内拥有十几年的经验了。

0