基于keepalived的redis系统master双机热备读数据负载均
衡设
基于keepalived的redis系统master双机热备读数据负载均衡设置方案==============================================================================
============
硬件
机器 ip 作用master 192. 168.0.2 redis系统的master主机slave1 192. 168.0.3 redis系统的slave机器和master组成双机热备slave2 192. 168.0.4redis系统的slave机器和slave1构成读数据的负载均衡系统
软件keepalived下载地址 www.keepalived.orglvs下载地址 http://www. l inuxvirtualserver.orgredis下载地址 www.redis. iocentos 6.4版本
安装
不采用编译安装的方式使用yum安装
1.安装kernel-devel yum install kernel-devel.这是ipvsadm需要的
2.安装lvs yum install ipvsadm
3.安装keepalived:yum install keepalived
如果无法联网请去这里考古寻找自己需要的rpm文件base:http://tel.mirrors. 163.com/centos/6/os/x86_64/Packages/update:http://tel.mirrors. 163. com/centos/6/updates/x86_64/Packages/下面是需要的r pm文件列表截图kernel-devel需要的文件
以及需要的证书lvs需要的文件keepalived需要的文件
注意三台机器都需要安装keepalived
配置keepalived
1.centos必要配置
/etc/sysctl. conf文件net. ipv4. ip_forward=1#转发开启
2.keepalived必要配置master修改/etc/keepalived/keepalived. conf为如下
[plain] view plaincopy 1. ! Configuration File for keepalived 2.
3. global_defs {
4. notification_email { 5. 邮箱 6. }
7. not ificat ion_email_from邮箱 8. smtp_server邮箱服务器地址 9.smtp_connect_timeout 30 10. router_id LVS_DEVEL 11. }
12. vrrp_instance VI_1 { 13. state MASTER
14. interface eth0 #eth0是要绑定的网卡
15. virtual_router_id 100 #同一个vrrp_instance中的值必须一样 16.priority 160 #master的值要高于backup的 17. advert_int 1 18.authentication { 19. auth_type PASS 20. auth_pass 1111
21. }
22. virtual_ipaddress {
23. 192. 168.0.5 #用于双机热备的虚拟ip 24. } 25. 26. }
27. virtual_server 192. 168.0.5 6379 { 28. delay_loop 3 29.lb_algo wrr 30. lb_kind DR
31. persistence_timeout 30 32. protocol TCP
33. real_server 192. 168.0. 2 6379 { 34. weight 8
35. notify_down redis服务失败后要执行的脚本的路径/脚本名 #服务失败后要执行的
脚本
36. TCP_CHECK { 37. connect_timeout 1 38.nb_get_retry 3 39. delay_before_retry 3 40. connect_port
6379 41. } 42. } 43. }slave1修改/etc/keepalived/keepalived. conf为如下
[plain] view plaincopy 1. ! Configuration File for keepalived 2.
3. global_defs {
4. notification_email { 5. 邮箱 6. }
7. not ificat ion_email_from邮箱 8. smtp_server邮箱服务器地址 9.smtp_connect_timeout 30 10. router_id LVS_DEVEL 11. } 12.
13. vrrp_instance VI_1 { 14. state MASTER
15. interface eth0 #eth0是要绑定的网卡
16. virtual_router_id 100 #同一个vrrp_instance中的值必须一样 17.priority 160 #master的值要高于backup的 18. advert_int 1 19.authentication { 20. auth_type PASS 21. auth_pass 1111
22. }
23. virtual_ipaddress {
24. 192. 168.0.5 #用于双机热备的虚拟ip 25. }
26. notify_master将slave重新转换为slave的脚本 27. }
28. vrrp_instance VI_2 {
29. state MASTER #将此slave作为读数据的master
30. interface eth0 31. virtual_router_id 101 32. priority
151 33. advert_int 1 34. authenticat ion { 35. auth_type PASS
36. auth_pass 1111 37. }
38. virtual_ipaddress {
39. 192. 168.0.6 #用于读取数据的负载均衡的虚拟ip 40. } 41. }
42. virtual_server 192. 168.0.5 6379 { 43. delay_loop 3 44.lb_algo wrr 45. lb_kind DR
46. persistence_timeout 30 47. protocol TCP
48. real_server 192. 168.0. 2 6379 { 49. weight 1
50. notify_down redis服务失败后要执行的脚本的路径/脚本名#服务失败后
要执行的脚本
51. TCP_CHECK { 52. connect_timeout 1 53.nb_get_retry 2 54. delay_before_retry 1 55. connect_port
6379 56. } 57. }
58. real_server 192. 168.0. 3 6379 { 59. weight 8 60.TCP_CHECK { 61. connect_t imeout 10 62. nb_get_retry 3 63.delay_before_retry 3 64. connect_port 6379 65. } 66. }
67. }
68. virtual_server 192. 168.0.6 6379 { 69. delay_loop 3 70.lb_algo wrr 71. lb_kind DR
72. persistence_timeout 30
感谢您的阅读祝您生活愉快。
CheapWindowsVPS是一家成立于2007年的老牌国外主机商,顾名思义,一个提供便宜的Windows系统VPS主机(同样也支持安装Linux系列的哈)的商家,可选数据中心包括美国洛杉矶、达拉斯、芝加哥、纽约、英国伦敦、法国、新加坡等等,目前商家针对VPS主机推出5折优惠码,优惠后最低4GB内存套餐月付仅4.5美元。下面列出几款VPS主机配置信息。CPU:2cores内存:4GB硬盘:60G...
DogYun是一家2019年成立的国人主机商,提供VPS和独立服务器租用等,数据中心包括中国香港、美国洛杉矶、日本、韩国、德国、荷兰等,其中VPS包括常规VPS(经典云)和按小时计费VPS(动态云),使用自行开发的面板和管理系统,支持自定义配置,动态云各个硬件独立按小时计费,带宽按照用户使用量计费(不使用不计费)或者购买流量包,线路也可以自行切换。目前商家发布了6.18促销方案,新购动态云7折,经...
hosteons当前对美国洛杉矶、达拉斯、纽约数据中心的VPS进行特别的促销活动:(1)免费从1Gbps升级到10Gbps带宽,(2)Free Blesta License授权,(3)Windows server 2019授权,要求从2G内存起,而且是年付。 官方网站:https://www.hosteons.com 使用优惠码:zhujicepingEDDB10G,可以获得: 免费升级10...