仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1123|回复: 8
打印 上一主题 下一主题

[CentOS(社区)] 来讲讲:memcached 双机热备

[复制链接]
蒙在股里 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 21:16:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
小知识:Linux发展和成长过程始终依赖着五个重要支柱:UNIX操作系统、MINIX操作系统、GNU计划、POSIX标准和Internet网络。
1、需求背景
发明公司很多多少项目都用到memched。而且都是单点,memched办事器挂了就会影响营业,因而百度之,发明memched不成以集群,也没有看到有甚么高可用计划,可是发明了repcached(memched主从复制),分离LVS的NAT形式分歧端口转发完成memched双机HA,本文章纪录自己的部署历程,附属实战,没有笔墨性的申明,接待列位指导。
2、情况:
1、体系情况:

[/code]

  • CentOSrelease6.4(Final)
2、收集情况

[/code]

  • 调剂机(master):
  • vip:172.28.26.100
  • vip1:172.28.16.100(lvs转发网关)
  • eth1:172.28.26.101(内网)
  • eth2:172.28.16.101(lvs转发网段)
  • 调剂机(backup):
  • eth1:172.28.26.99(内网)
  • eth2:172.28.16.99(lvs转发网段)
  • memched备节点:
  • eth1:172.28.26.102(内网)
  • eth2:172.28.16.102(lvs转发网段)
  • memched主节点:
  • eth1:172.28.26.103(内网)
  • eth2:172.28.16.103(lvs转发网段)

3、路由战略

[/code]

  • 调剂机(master):
  • echo201eth1>>/etc/iproute2/rt_tables
  • echodefaulttableeth1via172.28.26.1deveth1>/etc/sysconfig/network-scripts/route-eth1
  • echofrom172.28.26.101/255.255.255.255tableeth1>/etc/sysconfig/network-scripts/rule-eth1
  • echofrom172.28.26.100/255.255.255.255tableeth1>>/etc/sysconfig/network-scripts/rule-eth1
  • echofrom172.28.16.101/32tableZW_LVS_LAN>/etc/sysconfig/network-scripts/rule-eth2
  • memched节点1:
  • echodefaulttableZW_LVS_LANvia172.28.16.100>/etc/sysconfig/network-scripts/route-eth2
  • echofrom172.28.16.0/24tableZW_LVS_LAN>/etc/sysconfig/network-scripts/rule-eth2
  • echo202ZW_LVS_LAN>>/etc/iproute2/rt_tables
  • memched节点2:
  • echodefaulttableZW_LVS_LANvia172.28.16.100>/etc/sysconfig/network-scripts/route-eth2
  • echofrom172.28.16.0/24tableZW_LVS_LAN>/etc/sysconfig/network-scripts/rule-eth2
  • echo202ZW_LVS_LAN>>/etc/iproute2/rt_tables

4、内核参数

[/code]

  • fs.file-max=1000000
  • kernel.core_uses_pid=1
  • kernel.msgmax=1048560
  • kernel.msgmnb=1073741824
  • kernel.shmall=4294967296
  • kernel.shmmax=68719476736
  • kernel.sysrq=0
  • net.core.netdev_max_backlog=1048576
  • net.core.rmem_default=2097152
  • net.core.rmem_max=16777216
  • net.core.somaxconn=1048576
  • net.core.wmem_default=2097152
  • net.core.wmem_max=16777216
  • net.ipv4.conf.default.accept_source_route=0
  • net.ipv4.conf.default.rp_filter=1
  • net.ipv4.ip_forward=1
  • net.ipv4.ip_local_port_range=102465000
  • net.ipv4.neigh.default.gc_thresh1=10240
  • net.ipv4.neigh.default.gc_thresh2=40960
  • net.ipv4.neigh.default.gc_thresh3=81920
  • net.ipv4.tcp_fin_timeout=1
  • net.ipv4.tcp_keepalive_intvl=15
  • net.ipv4.tcp_keepalive_probes=5
  • net.ipv4.tcp_keepalive_time=30
  • net.ipv4.tcp_max_orphans=3276800
  • net.ipv4.tcp_max_syn_backlog=1048576
  • net.ipv4.tcp_max_tw_buckets=50000
  • net.ipv4.tcp_mem=94500000915000000927000000
  • net.ipv4.tcp_orphan_retries=3
  • net.ipv4.tcp_reordering=5
  • net.ipv4.tcp_retrans_collapse=0
  • net.ipv4.tcp_retries2=5
  • net.ipv4.tcp_rmem=4096873804194304
  • net.ipv4.tcp_sack=1
  • net.ipv4.tcp_synack_retries=1
  • net.ipv4.tcp_syncookies=0
  • net.ipv4.tcp_syn_retries=1
  • net.ipv4.tcp_timestamps=1
  • net.ipv4.tcp_tw_recycle=1
  • net.ipv4.tcp_tw_reuse=1
  • net.ipv4.tcp_window_scaling=1
  • net.ipv4.tcp_wmem=4096163844194304
  • net.ipv6.conf.all.disable_ipv6=1
  • net.ipv6.conf.default.disable_ipv6=1
  • net.ipv4.conf.eth0.rp_filter=1#memched节点不必要
  • net.ipv4.conf.eth1.rp_filter=1#memched节点不必要
  • net.ipv4.conf.eth2.rp_filter=1#memched节点不必要
  • net.ipv4.conf.all.rp_filter=0#memched节点不必要

3、办事安装
1、调剂机(master、backup)

[/code]

  • yum-yinstallipvsadmkeepalivedsendmail
2、memched节点1、memched节点2

[/code]

  • wgethttp://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
  • wgethttp://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
  • wgethttp://downloads.sourceforge.net/repcached/memcached-1.2.8-repcached-2.2.tar.gz


[/code]

  • tar-zxvflibevent-1.4.13-stable.tar.gz
  • cdlibevent-1.4.13-stable
  • ./configure--prefix=/usr/local
  • make
  • makeinstall

  • tar-zxvfmemcached-1.4.15.tar.gz
  • cdmemcached-1.4.15
  • ./configure--with-libevent=/usr/local
  • make
  • makeinstall

  • tar-zxvfmemcached-1.2.8-repcached-2.2.tar.gz
  • cdmemcached-1.2.8-repcached-2.2
  • ./configure--enable-replication
  • make
  • makeinstall
4、keepalived设置(master、backup)
[root@LVS1keepalived]#cat/etc/keepalived/gobal_module
[/code]<olclass="dp-sql"style="padding:5px0px;color:rgb(92,92,92);list-style-position:initial;list-style-image:initial;border-left-width:3px;border-style:nonenonenonesolid;border-left-color:rgb(20,107,0);margin:0px0px1px3em!important;"><liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">!globalconfigurefile<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;"><liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">global_defs{<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;">notification_email{<liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">navyaijm@qq.com<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;">}<liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">notification_email_fromnavyaijm@qq.com<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;">smtp_server127.0.0.1<liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">smtp_connect_timeout30<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;">router_idZH_DG_LVS1<liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">}<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;"><liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">[root@LVS1keepalived]#cat/etc/keepalived/keepalived.conf<listyle="margin-left:20px;list-style:decimal-leading-zerooutside;line-height:1.3em;border:none;padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;">!Keepalivedmainconfigurefile<liclass="alt"style="padding:0px3px0px10px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:20px;list-style:decimal-leading-zerooutside;color:inherit;line-height:1.3em;border:none;">include/etc/keepalived/gobal_module
简单生活 该用户已被删除
沙发
发表于 2015-1-17 09:44:28 | 只看该作者
其实当你安装了一个完整的Linux系统后其中已经包含了一个强大的帮助,只是可能你还没有发现和使用它们的技巧。
深爱那片海 该用户已被删除
板凳
发表于 2015-1-24 16:06:43 | 只看该作者
请问谁有Linux的学习心得的吗?简单的说说?
admin 该用户已被删除
地板
发表于 2015-2-2 11:11:17 | 只看该作者
熟悉并掌握安装Linux,安装是学习的前提。目前较常见的安装方法有二种:
柔情似水 该用户已被删除
5#
发表于 2015-2-7 19:16:15 | 只看该作者
写学习日记,这是学习历程的见证,同时我坚持认为是增强学习信念的法宝。
海妖 该用户已被删除
6#
发表于 2015-2-23 10:49:26 | 只看该作者
老实说,第一个程序是在C中编译好的,调试好了才在Linux下运行,感觉用vi比较麻烦,因为有错了不能调试,只是提示错误。
若天明 该用户已被删除
7#
发表于 2015-3-7 09:14:27 | 只看该作者
任何一个叫做操作系统的东西都是这样子构成的:内核+用户界面+一般应用程序。
活着的死人 该用户已被删除
8#
发表于 2015-3-14 23:58:12 | 只看该作者
Linux只是个内核!这点很重要,你必须理解这一点。只有一个内核是不能构成一个操作系统的。
灵魂腐蚀 该用户已被删除
9#
发表于 2015-3-21 18:19:14 | 只看该作者
编程学习及开发,Linux是免费,开源的操作系统,并且可开发工具相当多,如果您支持自由软件,一定要同广大热爱自由软件人士一同为其不懈努力。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-9-24 09:14

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表