diff --git a/README.md b/README.md index 861a9c27fb19db62e2ba95934c36366cbd1b173a..77a2b89ed250b80a507a011cd37989c0bd0efb5d 100644 --- a/README.md +++ b/README.md @@ -20,26 +20,4 @@ nredis-proxy 是一个以redis 协议为主的高性能稳定的代理中间件 ![输入图片说明](http://git.oschina.net/uploads/images/2016/1110/000104_44f5a5cb_54128.png "在这里输入图片标题") - 四:例子配置文件: - - - - - - - - - - - - - - - - \ No newline at end of file + 详细文档地址 :[https://my.oschina.net/liubingsmile/blog/786465](https://my.oschina.net/liubingsmile/blog/786465) \ No newline at end of file diff --git a/nredis-proxy-sample/.classpath b/nredis-proxy-sample/.classpath index 698778fef3378d2b00e5d4e260491f33b776287d..484684893ee7ef4e0f16c74dfd0fcdd7540b8e18 100644 --- a/nredis-proxy-sample/.classpath +++ b/nredis-proxy-sample/.classpath @@ -17,6 +17,8 @@ + + diff --git a/nredis-proxy-sample/log/hedis.log b/nredis-proxy-sample/log/hedis.log index 3f463c7fe45b1dd1372f1ce7fc59d93b6e02d444..a5e364065e3926d74ae944f651b11e33981c6535 100644 --- a/nredis-proxy-sample/log/hedis.log +++ b/nredis-proxy-sample/log/hedis.log @@ -25,3 +25,30 @@ [VAMS][2016-11-09 23:05:26,586] INFO | [ZookeeperRegistry] Url (com.opensource.netty.redis.proxy.core.url.RedisProxyURL@55f47e63) will register to Registry [null:0] | [main] com.opensource.netty.redis.proxy.core.log.impl.LogService.info(52) [VAMS][2016-11-09 23:05:26,607] INFO | [ZookeeperRegistry] Url (com.opensource.netty.redis.proxy.core.url.RedisProxyURL@1ae9bae7) will createPersistent,parentPath 127.0.0.1:6380 ,value,{"host":"127.0.0.1","key":"redis_proxy_127.0.0.1|6381","maxActiveConnection":5000,"maxIdleConnection":500,"minConnection":50,"port":6381,"serverKey":"127.0.0.1:6381","timeout":5000,"weight":1} | [main] com.opensource.netty.redis.proxy.core.log.impl.LogService.info(52) [VAMS][2016-11-09 23:05:26,775] INFO | RedisProxy_Server 已经启动 | [main] com.opensource.netty.redis.proxy.net.server.LBRedisServer.start(124) +[VAMS][2016-11-11 16:42:19,400] INFO | Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@14c8f24: startup date [Fri Nov 11 16:42:19 CST 2016]; root of context hierarchy | [main] org.springframework.context.support.AbstractApplicationContext.prepareRefresh(510) +[VAMS][2016-11-11 16:42:19,472] INFO | Loading XML bean definitions from URL [file:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-sample/target/classes/redisProxy.xml] | [main] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(317) +[VAMS][2016-11-11 16:42:19,903] INFO | Starting ZkClient event thread. | [ZkClient-EventThread-8-127.0.0.1:2181] org.I0Itec.zkclient.ZkEventThread.run(66) +[VAMS][2016-11-11 16:42:19,925] INFO | Client environment:zookeeper.version=3.4.8--1, built on 02/06/2016 03:18 GMT | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,926] INFO | Client environment:host.name=192.168.0.18 | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,926] INFO | Client environment:java.version=1.7.0_71 | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,926] INFO | Client environment:java.vendor=Oracle Corporation | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,927] INFO | Client environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,927] INFO | Client environment:java.class.path=/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-sample/target/classes:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-spring/target/classes:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-net/target/classes:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-core/target/classes:/Users/liubing/.m2/repository/io/netty/netty-all/4.0.26.Final/netty-all-4.0.26.Final.jar:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-commons/target/classes:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-pool/target/classes:/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-register/target/classes:/Users/liubing/.m2/repository/org/apache/zookeeper/zookeeper/3.4.8/zookeeper-3.4.8.jar:/Users/liubing/.m2/repository/jline/jline/0.9.94/jline-0.9.94.jar:/Users/liubing/.m2/repository/io/netty/netty/3.7.0.Final/netty-3.7.0.Final.jar:/Users/liubing/.m2/repository/com/alibaba/fastjson/1.2.4/fastjson-1.2.4.jar:/Users/liubing/.m2/repository/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar:/Users/liubing/.m2/repository/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar:/Users/liubing/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar:/Users/liubing/.m2/repository/redis/clients/jedis/2.7.3/jedis-2.7.3.jar:/Users/liubing/.m2/repository/org/apache/commons/commons-pool2/2.3/commons-pool2-2.3.jar:/Users/liubing/.m2/repository/org/springframework/spring-context/4.1.7.RELEASE/spring-context-4.1.7.RELEASE.jar:/Users/liubing/.m2/repository/org/springframework/spring-aop/4.1.7.RELEASE/spring-aop-4.1.7.RELEASE.jar:/Users/liubing/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/liubing/.m2/repository/org/springframework/spring-beans/4.1.7.RELEASE/spring-beans-4.1.7.RELEASE.jar:/Users/liubing/.m2/repository/org/springframework/spring-core/4.1.7.RELEASE/spring-core-4.1.7.RELEASE.jar:/Users/liubing/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/liubing/.m2/repository/org/springframework/spring-expression/4.1.7.RELEASE/spring-expression-4.1.7.RELEASE.jar | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,927] INFO | Client environment:java.library.path=/Users/liubing/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,928] INFO | Client environment:java.io.tmpdir=/var/folders/g8/z6zm23pj75g9l7lz3cmrmy0h0000gn/T/ | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,928] INFO | Client environment:java.compiler= | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,928] INFO | Client environment:os.name=Mac OS X | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,929] INFO | Client environment:os.arch=x86_64 | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,929] INFO | Client environment:os.version=10.10.3 | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,929] INFO | Client environment:user.name=liubing | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,930] INFO | Client environment:user.home=/Users/liubing | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,930] INFO | Client environment:user.dir=/Users/liubing/Documents/learnDocument/nredis-proxy/nredis-proxy-sample | [main] org.apache.zookeeper.Environment.logEnv(100) +[VAMS][2016-11-11 16:42:19,931] INFO | Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=60000 watcher=org.I0Itec.zkclient.ZkClient@1c572cc4 | [main] org.apache.zookeeper.ZooKeeper.(438) +[VAMS][2016-11-11 16:42:19,946] INFO | Waiting for keeper state SyncConnected | [main] org.I0Itec.zkclient.ZkClient.waitForKeeperState(955) +[VAMS][2016-11-11 16:42:19,948] INFO | Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) | [main-SendThread(127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn$SendThread.logStartConnect(1032) +[VAMS][2016-11-11 16:42:19,955] INFO | Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session | [main-SendThread(127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn$SendThread.primeConnection(876) +[VAMS][2016-11-11 16:42:19,997] INFO | Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x158528ac0a70000, negotiated timeout = 40000 | [main-SendThread(127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn$SendThread.onConnected(1299) +[VAMS][2016-11-11 16:42:19,998] INFO | zookeeper state changed (SyncConnected) | [main-EventThread] org.I0Itec.zkclient.ZkClient.processStateChanged(729) +[VAMS][2016-11-11 16:42:20,424] INFO | [ZookeeperRegistry] Url (com.opensource.netty.redis.proxy.core.url.RedisProxyURL@31ddd557) will register to Registry [null:0] | [main] com.opensource.netty.redis.proxy.core.log.impl.LogService.info(52) +[VAMS][2016-11-11 16:42:20,493] INFO | [ZookeeperRegistry] Url (com.opensource.netty.redis.proxy.core.url.RedisProxyURL@37df4449) will createPersistent,parentPath 127.0.0.1:6380 ,value,{"host":"127.0.0.1","key":"redis_proxy_127.0.0.1|6381","maxActiveConnection":5000,"maxIdleConnection":500,"minConnection":50,"port":6381,"serverKey":"127.0.0.1:6381","timeout":5000,"weight":1} | [main] com.opensource.netty.redis.proxy.core.log.impl.LogService.info(52) +[VAMS][2016-11-11 16:42:20,744] INFO | RedisProxy_Server 已经启动 | [main] com.opensource.netty.redis.proxy.net.server.LBRedisServer.start(124) diff --git a/nredis-proxy-sample/pom.xml b/nredis-proxy-sample/pom.xml index 8925ba9730da12dd8fb94856f64add39d392f488..056f18746fb8b99dfec2034e77672dafe4a0017a 100644 --- a/nredis-proxy-sample/pom.xml +++ b/nredis-proxy-sample/pom.xml @@ -53,4 +53,28 @@ 4.1.7.RELEASE + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4 + + false + + src/main/assembly/assembly.xml + + + + + make-assembly + package + + single + + + + + + diff --git a/nredis-proxy-sample/src/main/assembly/assembly.xml b/nredis-proxy-sample/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..599b447a27a54e3b52c70d84e958186bae888ca9 --- /dev/null +++ b/nredis-proxy-sample/src/main/assembly/assembly.xml @@ -0,0 +1,26 @@ + + package + + dir + + false + + + true + lib + + + + + true + src/main/resources + /config + + + + + src/main/deploy/single.sh + /bin + + + \ No newline at end of file diff --git a/nredis-proxy-sample/src/main/deploy/package-dependency.properties b/nredis-proxy-sample/src/main/deploy/package-dependency.properties new file mode 100644 index 0000000000000000000000000000000000000000..f95d0002073f3db20bc49613bd4b6f339ca7bfa6 --- /dev/null +++ b/nredis-proxy-sample/src/main/deploy/package-dependency.properties @@ -0,0 +1,3 @@ +settlement-base +settlement-dao +settlement-service \ No newline at end of file diff --git a/nredis-proxy-sample/src/main/deploy/single.sh b/nredis-proxy-sample/src/main/deploy/single.sh new file mode 100644 index 0000000000000000000000000000000000000000..7339eee61283461910741f25048e3304f9938f2b --- /dev/null +++ b/nredis-proxy-sample/src/main/deploy/single.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +#取当前目录 +BASE_PATH=`cd "$(dirname "$0")"; pwd` + +#设置java运行参数 +DEFAULT_JAVA_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -Dfile.encoding=utf-8 " + + +#引入外部参数配置文件: +SHELL_PARAMS="$BASE_PATH/params.conf" +if [ -f "$SHELL_PARAMS" ]; then + . $SHELL_PARAMS +fi + +#定义变量: +APP_PATH=${APP_PATH:-`dirname "$BASE_PATH"`} +LOG_PATH=${APP_PATH}/logs +if [ ! -d $LOG_PATH ]; then + mkdir -p $LOG_PATH +fi +CLASS_PATH=${CLASS_PATH:-$APP_PATH/config:$APP_PATH/lib/*} +CONSOLE_LOG=${LOG_PATH}/timer_console.log +JAVA_OPTS=${JAVA_OPTS:-$DEFAULT_JAVA_OPTS} +MAIN_CLASS=${MAIN_CLASS:-"com.opensource.netty.redis.proxy.sample.RedisProxyServerBootStrap"} + + +exist(){ + if test $( pgrep -f "$MAIN_CLASS $APP_PATH" | wc -l ) -eq 0 + then + return 1 + else + return 0 + fi +} + +start(){ + if exist; then + echo "Timer is already running." + exit 1 + else + cd $APP_PATH + echo "nohup java $JAVA_OPTS -cp $CLASS_PATH $MAIN_CLASS $APP_PATH 2> /dev/null & " + nohup java $JAVA_OPTS -cp $CLASS_PATH $MAIN_CLASS $APP_PATH > ${CONSOLE_LOG} 2>&1 & + echo "Timer is started." + fi +} + +stop(){ + runningPID=`pgrep -f "$MAIN_CLASS $APP_PATH"` + if [ "$runningPID" ]; then + echo "Timer pid: $runningPID" + count=0 + kwait=5 + echo "Timer is stopping, please wait..." + kill -15 $runningPID + until [ `ps --pid $runningPID 2> /dev/null | grep -c $runningPID 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ] + do + sleep 1 + let count=$count+1; + done + + if [ $count -gt $kwait ]; then + kill -9 $runningPID + fi + clear + echo "Timer is stopped." + else + echo "Timer has not been started." + fi +} + +check(){ + if exist; then + echo "Timer is alive." + exit 0 + else + echo "Timer is dead." + exit -1 + fi +} + +restart(){ + stop + start +} + +case "$1" in + +start) + start +;; +stop) + stop +;; +restart) + restart +;; +check) + check +;; +*) + echo "available operations: [start|stop|restart|check]" + exit 1 +;; +esac \ No newline at end of file diff --git a/nredis-proxy-sample/src/main/resources/redisProxy.xml b/nredis-proxy-sample/src/main/resources/redisProxy.xml index f67585faa2ba1b4d02ec4e3164264b136200c6ba..15e3e957639a875074f4ca0a724ebb83247f0d82 100644 --- a/nredis-proxy-sample/src/main/resources/redisProxy.xml +++ b/nredis-proxy-sample/src/main/resources/redisProxy.xml @@ -8,10 +8,10 @@ http://www.nredisproxy.com/redisProxy/redisProxy.xsd" > - + - - + +