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安装及集群创建
参考:https://www.cnblogs.com/a120608yby/p/17167566.html
3、Twemproxy安装及配置
# 下载程序包 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、验证
# 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"
参考:https://github.com/twitter/twemproxy
标签:10.32,Twemproxy,twemproxy,Redis,nutcracker,161.130,redis,6379 From: https://www.cnblogs.com/a120608yby/p/17242958.html