posts - 158,  comments - 0,  views - 11万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

1、环境

服务名称 IP地址 备注
twemproxy-161-130 10.32.161.130 twemproxy (nutcracker)
redis-161-131 10.32.161.131 redis节点
redis-161-132 10.32.161.132 redis节点
redis-161-133 10.32.161.133 redis节点
redis-161-134 10.32.161.134 redis节点
redis-161-135 10.32.161.135 redis节点
redis-161-136 10.32.161.136 redis节点

2、Redis安装及集群创建

1
参考:https://www.cnblogs.com/a120608yby/p/17167566.html

3、Twemproxy安装及配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 下载程序包
wget https://github.com/twitter/twemproxy/releases/download/0.5.0/twemproxy-0.5.0.tar.gz -P /usr/local/src
 
# 编译安装
cd /usr/local/src
tar xf twemproxy-0.5.0.tar.gz
cd twemproxy-0.5.0
./configure --prefix=/usr/local/twemproxy
make && make install
 
# 拷贝服务启动文件
cp scripts/nutcracker.init /etc/init.d/nutcracker
chmod +x /etc/init.d/nutcracker
 
# 配置环境变量
# vim /etc/profile.d/twemproxy.sh
export PATH=$PATH:/usr/local/twemproxy/sbin
# source /etc/profile.d/twemproxy.sh
 
# 修改配置文件
# mkdir /etc/nutcracker /usr/local/twemproxy/conf -p
# cat /usr/local/twemproxy/conf/nutcracker.yml
alpha:
  listen: 10.32.161.130:22121
  hash: fnv1a_64
  distribution: ketama
  auto_eject_hosts: true
  redis: true
  redis_auth: password
  server_retry_timeout: 2000
  server_failure_limit: 1
  servers:
   - 10.32.161.131:6379:1
   - 10.32.161.132:6379:1
   - 10.32.161.133:6379:1
   - 10.32.161.134:6379:1
   - 10.32.161.135:6379:1
   - 10.32.161.136:6379:1
# ln -sv /usr/local/twemproxy/conf/nutcracker.yml /etc/nutcracker/nutcracker.yml
# chown -R nobody. /etc/nutcracker /usr/local/twemproxy/
 
# 启动服务
chkconfig nutcracker on
/etc/init.d/nutcracker start

4、验证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# redis-cli -c -h 10.32.161.130 -p 22121 -a password
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
10.32.161.130:22121> set key1 111
OK
10.32.161.130:22121> set key2 222
-> Redirected to slot [4998] located at 10.32.161.130:6379
OK
10.32.161.130:6379> set key3 333
OK
10.32.161.130:6379> set key4 444
-> Redirected to slot [13120] located at 10.32.161.132:6379
OK
10.32.161.132:6379> set key5 555
-> Redirected to slot [9057] located at 10.32.161.131:6379
OK
10.32.161.131:6379> set key6 666
-> Redirected to slot [4866] located at 10.32.161.130:6379
OK
10.32.161.130:6379> get key3
"333"
10.32.161.130:6379> get key6
"666"
10.32.161.130:6379> get key1
-> Redirected to slot [9189] located at 10.32.161.131:6379
"111"
10.32.161.131:6379> get key2
-> Redirected to slot [4998] located at 10.32.161.130:6379
"222"
10.32.161.130:6379> get key5
-> Redirected to slot [9057] located at 10.32.161.131:6379
"555"
10.32.161.131:6379> get key4
-> Redirected to slot [13120] located at 10.32.161.132:6379
"444"

参考:

1
https://github.com/twitter/twemproxy

  

posted on   a120608yby  阅读(48)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示