twemproxy安装

官方配置:https://github.com/twitter/twemproxy 

 

 

由于版本较低导致按照失败所以先centos 下 autoconf版本升级

http://www.aiuxian.com/article/p-879158.html

 

首先查看当前版本

#rpm -qf /usr/bin/autoconf

autoconf-2.63-5.1.el6.noarch

卸载当前版本
rpm -e --nodeps autoconf-2.63  

下载新版本

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.gz

解压安装

tar zxvf autoconf-2.64.tar.gz

cd autoconf-2.64

./configure --prefix=/usr

make && make install

查看是否安装成功

/usr/bin/autoconf -V

 

 

安装配置:

http://blog.mkfree.com/posts/515bce9d975a30cc561dc360

 

$ git clone [email protected]:twitter/twemproxy.git
$ cd twemproxy
$ autoreconf -fvi
$ ./configure --enable-debug=full
$ make
$ src/nutcracker -h

 

 

   看到以下说明安装成功

 

[root@slave1 twemproxy]# ./src/nutcracker  -h
This is nutcracker-0.4.1

Usage: nutcracker [-?hVdDt] [-v verbosity level] [-o output file]
                  [-c conf file] [-s stats port] [-a stats addr]
                  [-i stats interval] [-p pid file] [-m mbuf size]

Options:
  -h, --help             : this help
  -V, --version          : show version and exit
  -t, --test-conf        : test configuration for syntax errors and exit
  -d, --daemonize        : run as a daemon
  -D, --describe-stats   : print stats description and exit
  -v, --verbose=N        : set logging level (default: 5, min: 0, max: 11)
  -o, --output=S         : set logging file (default: stderr)
  -c, --conf-file=S      : set configuration file (default: conf/nutcracker.yml)
  -s, --stats-port=N     : set stats monitoring port (default: 22222)
  -a, --stats-addr=S     : set stats monitoring ip (default: 0.0.0.0)
  -i, --stats-interval=N : set stats aggregation interval in msec (default: 30000 msec)
  -p, --pid-file=S       : set pid file (default: off)
  -m, --mbuf-size=N      : set size of mbuf chunk in bytes (default: 16384 bytes)

 

 

[root@slave1 twemproxy]# vim conf/nutcracker.yml

alpha:
  listen: 192.168.1.135:55555  #可以修改服务器的IP以及端口号
  hash: fnv1a_64
  distribution: ketama
  auto_eject_hosts: true
  redis: true
  server_retry_timeout: 2000
  server_failure_limit: 1
  servers:
   - 192.168.1.135:6379:1  #Redis服务的IP:Port
   - 192.168.1.137:6379:1  #Redis服务的IP:Port

 

#启动命令

1. 为了方便调试启动
./src/nutcracker -c /opt/module/twenproxy/conf/nutcracker.yml

2.守护进程启动
./src/nutcracker -d -c /opt/module/twenproxy/conf/nutcracker.yml

 

#连接并测试是否成功

[root@slave1 src]# ./redis-cli -h 192.168.1.135 -p 55555
192.168.1.135:55555> get foo
"bar1455790328132"

 

说明客户端也配置完成

 

https://github.com/xetorthio/jedis 客户端JAR  以及简单示例

JAVA客户端配置测试

public class JredisTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Jedis jedis = new Jedis("192.168.1.135",55555);
		jedis.set("foo", "bar" + System.currentTimeMillis());
		String value = jedis.get("foo");
		System.out.println("++value++" + value);
		
	/*	
		Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
		//Jedis Cluster will attempt to discover cluster nodes automatically
		jedisClusterNodes.add(new HostAndPort("192.168.1.135", 6379));
		JedisCluster jc = new JedisCluster(jedisClusterNodes);
		jc.set("foo", "12345689");
		System.out.println("++name++" + jc.get("foo"));*/
	}
}

 

 

 

 

 

猜你喜欢

转载自wo-niu.iteye.com/blog/2277247