基于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
感谢您的阅读祝您生活愉快。
近期RAKsmart上线云服务器Cloud Server产品,KVM架构1核1G内存40G硬盘1M带宽基础配置7.59美元/月!RAKsmart云服务器Cloud Server位于美国硅谷机房,下单可选DIY各项配置,VPC网络/经典网络,大陆优化/精品网线路,1-1000Mbps带宽,支持Linux或者Windows操作系统,提供Snap和Backup。RAKsmart机房是一家成立于2012年...
美得云成立于2021年,是一家云产品管理服务商(cloud)专业提供云计算服务、DDOS防护、网络安全服务、国内海外数据中心托管租用等业务、20000+用户的选择,43800+小时稳定运行香港特价将军澳CTG+CN2云服务器、采用高端CPU 优质CN2路线 SDD硬盘。香港CTG+CN22核2G3M20G数据盘25元点击购买香港CTG+CN22核2G5M30G数据盘39元点击购买香港CTG+CN...
spinservers怎么样?spinservers大硬盘服务器。Spinservers刚刚在美国圣何塞机房补货120台独立服务器,CPU都是双E5系列,64-512GB DDR4内存,超大SSD或NVMe存储,数量有限,机器都是预部署好的,下单即可上架,无需人工干预,有需要的朋友抓紧下单哦。Spinservers是Majestic Hosting Solutions,LLC旗下站点,主营美国独立...