Redis叢集方案,Codis安裝測試

五柳-先生發表於2015-04-21

1,關於豌豆莢開源的Codis

Codis是豌豆莢使用Go和C語言開發、以代理的方式實現的一個Redis分散式叢集解決方案,且完全相容Twemproxy。Twemproxy對於上一層的應用來說, 連線Codis Proxy(Redis代理服務)和連線原生的Redis伺服器沒有明顯的區別,上一層應用能夠像使用單機的 Redis一樣對待。Codis底層會處理請求的轉發、不停機的資料遷移等工作, 所有底層的一切處理, 對於客戶端來說是透明的。總之,可以簡單的認為後臺連線的是一個記憶體無限大的Redis服務。Codis遵循MIT開源協議釋出,更多關於Codis的資訊請登入其在GitHub的主頁檢視。

Codis 是一個分散式 Redis 解決方案, 對於上層的應用來說, 連線到 Codis Proxy 和連線原生的 Redis Server 沒有明顯的區別 (不支援的命令列表), 上層應用可以像使用單機的 Redis 一樣使用, Codis 底層會處理請求的轉發, 不停機的資料遷移等工作, 所有後邊的一切事情, 對於前面的客戶端來說是透明的, 可以簡單的認為後邊連線的是一個記憶體無限大的 Redis 服務.

Codis 由四部分組成:

Codis Proxy (codis-proxy)
Codis Manager (codis-config)
Codis Redis (codis-server)
ZooKeeper

架構圖:

專案地址:
https://github.com/wandoulabs/codis
中文說明文件:
https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md
Redis 開源叢集方案:
http://www.infoq.com/cn/news/2014/11/open-source-redis-cache
Redis 3.0 rc4已經發布了,也是一種方案可以研究下,線上系統不建議使用。

2,安裝Codis&配置

參考文件:
https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md#build-codis-proxy–codis-config
首先按照golang,下載地址:https://golang.org/dl/,最新的1.4.2版本。
如果被牆使用golang中國下載http://golangtc.com/download

<code class="hljs avrasm has-numbering">cd /usr/loca/
wget https://storage<span class="hljs-preprocessor">.googleapis</span><span class="hljs-preprocessor">.com</span>/golang/go1<span class="hljs-number">.4</span><span class="hljs-number">.2</span><span class="hljs-preprocessor">.linux</span>-amd64<span class="hljs-preprocessor">.tar</span><span class="hljs-preprocessor">.gz</span>
tar -zxvf go1<span class="hljs-number">.4</span><span class="hljs-number">.2</span><span class="hljs-preprocessor">.linux</span>-amd64<span class="hljs-preprocessor">.tar</span><span class="hljs-preprocessor">.gz</span></code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li><li>3</li></ul>

設定環境變數,vi /etc/profile

<code class="hljs sql has-numbering">#<span class="hljs-operator"><span class="hljs-keyword">set</span> <span class="hljs-keyword">go</span> & codis environment
GOROOT=/usr/<span class="hljs-keyword">local</span>/<span class="hljs-keyword">go</span>
PATH=$PATH:$GOROOT/bin
GOPATH=/usr/<span class="hljs-keyword">local</span>/codis</span></code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li></ul>

下載codis

<code class="hljs livecodeserver has-numbering">cd /usr/<span class="hljs-built_in">local</span>
git clone <span class="hljs-keyword">https</span>://github.com/wandoulabs/codis.git
<span class="hljs-comment">#將codis的pkg包拷貝到$GOPATH目錄。</span>
mkdir -p /usr/<span class="hljs-built_in">local</span>/codis/src/github.com/wandoulabs/codis
cp /usr/<span class="hljs-built_in">local</span>/codis/pkg/ /usr/<span class="hljs-built_in">local</span>/codis/cmd/ /usr/<span class="hljs-built_in">local</span>/codis/src/github.com/wandoulabs/codis -R</code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul>

安裝codis,需要下載依賴包。比較慢,依賴

<code class="hljs asciidoc has-numbering">#安裝編譯工具
yum groupinstall "Development Tools"
#執行編譯測試指令碼,編譯go和reids。
sh /usr/local/codis/bootstrap.sh 
go build -o bin/codis-proxy ./cmd/proxy
go build -o bin/codis-config ./cmd/cconfig
make -j4 -C extern/redis-2.8.13/
make[1]: Entering directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13'</span>
cd src && make all
make[2]: Entering directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/src'</span>
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof <span class="hljs-strong">*.o *</span>.gcda <span class="hljs-strong">*.gcno *</span>.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[3]: Entering directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps'</span>
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-<span class="hljs-strong">*)
make[3]: Leaving directory `/usr/local/codis/extern/redis-2.8.13/deps'
(rm -f .make-*</span>)
echo STD=-std=c99 -pedantic >> .make-settings
echo WARN=-Wall >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS<span class="hljs-emphasis">_CFLAGS= >> .make-settings
echo REDIS_</span>LDFLAGS= >> .make-settings
echo PREV<span class="hljs-emphasis">_FINAL_</span>CFLAGS=-std=c99 -pedantic -Wall -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE<span class="hljs-emphasis">_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_</span>FINAL<span class="hljs-emphasis">_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[3]: Entering directory `/usr/local/codis/extern/redis-2.8.13/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
MAKE linenoise
cd linenoise && make
make[4]: Entering directory `/usr/local/codis/extern/redis-2.8.13/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_</span>ANSI " MYLDFLAGS=""
make[4]: Entering directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/hiredis'</span>
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[4]: Entering directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/lua/src'</span>
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lapi.o lapi.c
MAKE jemalloc
cd jemalloc && ./configure --with-jemalloc-prefix=je_</span> --enable-cc-silence CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS=""
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
make[4]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/linenoise'</span>
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lcode.o lcode.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o ldo.o ldo.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o ldump.o ldump.c
ar rcs libhiredis.a net.o hiredis.o sds.o async.o
make[4]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/hiredis'</span>
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o llex.o llex.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lobject.o lobject.c
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... gcc
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lstring.o lstring.c
checking whether the C compiler works... cc -O2 -Wall -DLUA_</span>ANSI    -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lundump.o lundump.c
yes
checking for C compiler default output file name... a.out
checking for suffix of executables... cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lvm.o lvm.c

</span>cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lzio.o lzio.c
checking whether we are cross compiling... cc -O2 -Wall -DLUA_</span>ANSI    -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lauxlib.o lauxlib.c
no
checking for suffix of object files... cc -O2 -Wall -DLUA_</span>ANSI    -c -o lbaselib.o lbaselib.c
o
checking whether we are using the GNU C compiler... cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o ldblib.o ldblib.c
yes
checking whether gcc accepts -g... cc -O2 -Wall -DLUA_</span>ANSI    -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lmathlib.o lmathlib.c
yes
checking for gcc option to accept ISO C89... cc -O2 -Wall -DLUA_</span>ANSI    -c -o loslib.o loslib.c
none needed
checking how to run the C preprocessor... cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o linit.o linit.c
gcc -E
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lua_</span>cjson.o lua<span class="hljs-emphasis">_cjson.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lua<span class="hljs-emphasis">_struct.o lua_</span>struct.c
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o lua_</span>cmsgpack.o lua<span class="hljs-emphasis">_cmsgpack.c
cc -O2 -Wall -DLUA_</span>ANSI    -c -o lua.o lua.c
lua<span class="hljs-emphasis">_cmsgpack.c: In function ‘table_</span>is<span class="hljs-emphasis">_an_</span>array’:
lua<span class="hljs-emphasis">_cmsgpack.c:370:21: warning: variable ‘max’ set but not used [-Wunused-but-set-variable]
     long count = 0, max = 0, idx = 0;
                     ^
cc -O2 -Wall -DLUA_</span>ANSI    -c -o luac.o luac.c
cc -O2 -Wall -DLUA<span class="hljs-emphasis">_ANSI    -c -o print.o print.c
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_</span>cjson.o lua<span class="hljs-emphasis">_struct.o lua_</span>cmsgpack.o   # DLL needs all object files
ranlib liblua.a
cc -o lua  lua.o liblua.a -lm 
cc -o luac  luac.o print.o liblua.a -lm 
yes
make[4]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/lua/src'</span>
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void <span class="hljs-strong">*... 8
checking size of int... 4
checking size of long... 8
checking size of intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether pause instruction is compilable... yes
checking whether SSE2 intrinsics is compilable... yes
checking for ar... ar
checking whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether compiler supports -Werror... yes
checking whether tls_model attribute is compilable... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld... /usr/bin/ld
checking for autoconf... /usr/bin/autoconf
checking for memalign... yes
checking for valloc... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace(2) is compilable... no
checking whether valgrind is compilable... no
checking STATIC_PAGE_SHIFT... 12
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether a program using ffsl is compilable... yes
checking whether atomic(9) is compilable... no
checking whether Darwin OSAtomic*</span>() is compilable... no
checking whether to force 32-bit _<span class="hljs-emphasis">_sync_</span>{add,sub}<span class="hljs-emphasis">_and_</span>fetch()... no
checking whether to force 64-bit _<span class="hljs-emphasis">_sync_</span>{add,sub}<span class="hljs-emphasis">_and_</span>fetch()... no
checking whether Darwin OSSpin*() is compilable... no
checking for stdbool.h that conforms to C99... yes
checking for <span class="hljs-emphasis">_Bool... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/html.xsl
config.status: creating doc/manpages.xsl
config.status: creating doc/jemalloc.xml
config.status: creating include/jemalloc/jemalloc_</span>macros.h
config.status: creating include/jemalloc/jemalloc<span class="hljs-emphasis">_protos.h
config.status: creating include/jemalloc/internal/jemalloc_</span>internal.h
config.status: creating test/test.sh
config.status: creating test/include/test/jemalloc<span class="hljs-emphasis">_test.h
config.status: creating config.stamp
config.status: creating bin/jemalloc.sh
config.status: creating include/jemalloc/jemalloc_</span>defs.h
config.status: creating include/jemalloc/internal/jemalloc<span class="hljs-emphasis">_internal_</span>defs.h
config.status: creating test/include/test/jemalloc<span class="hljs-emphasis">_test_</span>defs.h
config.status: executing include/jemalloc/internal/private<span class="hljs-emphasis">_namespace.h commands
config.status: executing include/jemalloc/internal/private_</span>unnamespace.h commands
config.status: executing include/jemalloc/internal/public<span class="hljs-emphasis">_symbols.txt commands
config.status: executing include/jemalloc/internal/public_</span>namespace.h commands
config.status: executing include/jemalloc/internal/public<span class="hljs-emphasis">_unnamespace.h commands
config.status: executing include/jemalloc/internal/size_</span>classes.h commands
config.status: executing include/jemalloc/jemalloc<span class="hljs-emphasis">_protos_</span>jet.h commands
config.status: executing include/jemalloc/jemalloc<span class="hljs-emphasis">_rename.h commands
config.status: executing include/jemalloc/jemalloc_</span>mangle.h commands
config.status: executing include/jemalloc/jemalloc<span class="hljs-emphasis">_mangle_</span>jet.h commands
<span class="hljs-header">config.status: executing include/jemalloc/jemalloc.h commands
===============================================================================</span>
jemalloc version   : 3.6.0-0-g46c0af68bd248b04df75e4f92d5fb804c3d75340
library revision   : 1

CC                 : gcc
CPPFLAGS           :  -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT
CFLAGS             : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -fvisibility=hidden
LDFLAGS            : 
EXTRA_</span>LDFLAGS      : 
LIBS               :  -lpthread
RPATH<span class="hljs-emphasis">_EXTRA        : 

</span>XSLTPROC           : /usr/bin/xsltproc
XSLROOT            : 

PREFIX             : /usr/local
BINDIR             : /usr/local/bin
INCLUDEDIR         : /usr/local/include
LIBDIR             : /usr/local/lib
DATADIR            : /usr/local/share
MANDIR             : /usr/local/share/man

srcroot            : 
abs<span class="hljs-emphasis">_srcroot        : /usr/local/codis/extern/redis-2.8.13/deps/jemalloc/
objroot            : 
abs_</span>objroot        : /usr/local/codis/extern/redis-2.8.13/deps/jemalloc/

JEMALLOC<span class="hljs-emphasis">_PREFIX    : je_</span>
JEMALLOC<span class="hljs-emphasis">_PRIVATE_</span>NAMESPACE
<span class="hljs-code">                   : je_</span>
install<span class="hljs-emphasis">_suffix     : 
autogen            : 0
experimental       : 1
cc-silence         : 1
debug              : 0
code-coverage      : 0
stats              : 1
prof               : 0
prof-libunwind     : 0
prof-libgcc        : 0
prof-gcc           : 0
tcache             : 1
fill               : 1
utrace             : 0
valgrind           : 0
xmalloc            : 0
mremap             : 0
munmap             : 0
dss                : 0
lazy_</span>lock          : 0
<span class="hljs-header">tls                : 1
===============================================================================</span>
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
make[4]: Entering directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/jemalloc'</span>
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/chunk_</span>dss.o src/chunk<span class="hljs-emphasis">_dss.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/chunk<span class="hljs-emphasis">_mmap.o src/chunk_</span>mmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/quarantine.o src/quarantine.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D<span class="hljs-emphasis">_GNU_</span>SOURCE -D<span class="hljs-emphasis">_REENTRANT -Iinclude -Iinclude -o src/util.o src/util.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_</span>GNU<span class="hljs-emphasis">_SOURCE -D_</span>REENTRANT -Iinclude -Iinclude -o src/tsd.o src/tsd.c
ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk<span class="hljs-emphasis">_dss.o src/chunk_</span>mmap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o
make[4]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps/jemalloc'</span>
make[3]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/deps'</span>
<span class="hljs-code">    CC adlist.o</span>
<span class="hljs-code">    CC ae.o</span>
<span class="hljs-code">    CC anet.o</span>
<span class="hljs-code">    CC dict.o</span>
<span class="hljs-code">    CC redis.o</span>
<span class="hljs-code">    CC sds.o</span>
<span class="hljs-code">    CC zmalloc.o</span>
<span class="hljs-code">    CC lzf_c.o</span>
<span class="hljs-code">    CC lzf_d.o</span>
<span class="hljs-code">    CC pqsort.o</span>
<span class="hljs-code">    CC zipmap.o</span>
<span class="hljs-code">    CC sha1.o</span>
<span class="hljs-code">    CC ziplist.o</span>
<span class="hljs-code">    CC release.o</span>
<span class="hljs-code">    CC networking.o</span>
<span class="hljs-code">    CC util.o</span>
<span class="hljs-code">    CC object.o</span>
<span class="hljs-code">    CC db.o</span>
<span class="hljs-code">    CC replication.o</span>
<span class="hljs-code">    CC rdb.o</span>
<span class="hljs-code">    CC t_string.o</span>
<span class="hljs-code">    CC t_list.o</span>
<span class="hljs-code">    CC t_set.o</span>
<span class="hljs-code">    CC t_zset.o</span>
<span class="hljs-code">    CC t_hash.o</span>
<span class="hljs-code">    CC config.o</span>
<span class="hljs-code">    CC aof.o</span>
<span class="hljs-code">    CC pubsub.o</span>
<span class="hljs-code">    CC multi.o</span>
<span class="hljs-code">    CC debug.o</span>
<span class="hljs-code">    CC sort.o</span>
<span class="hljs-code">    CC intset.o</span>
<span class="hljs-code">    CC syncio.o</span>
<span class="hljs-code">    CC migrate.o</span>
<span class="hljs-code">    CC endianconv.o</span>
<span class="hljs-code">    CC slowlog.o</span>
<span class="hljs-code">    CC scripting.o</span>
<span class="hljs-code">    CC bio.o</span>
<span class="hljs-code">    CC rio.o</span>
<span class="hljs-code">    CC rand.o</span>
<span class="hljs-code">    CC memtest.o</span>
<span class="hljs-code">    CC crc64.o</span>
<span class="hljs-code">    CC crc32.o</span>
<span class="hljs-code">    CC bitops.o</span>
<span class="hljs-code">    CC sentinel.o</span>
<span class="hljs-code">    CC notify.o</span>
<span class="hljs-code">    CC setproctitle.o</span>
<span class="hljs-code">    CC hyperloglog.o</span>
<span class="hljs-code">    CC latency.o</span>
<span class="hljs-code">    CC sparkline.o</span>
<span class="hljs-code">    CC slots.o</span>
<span class="hljs-code">    CC redis-cli.o</span>
<span class="hljs-code">    CC redis-benchmark.o</span>
<span class="hljs-code">    CC redis-check-dump.o</span>
<span class="hljs-code">    CC redis-check-aof.o</span>
<span class="hljs-code">    LINK redis-benchmark</span>
<span class="hljs-code">    LINK redis-check-aof</span>
<span class="hljs-code">    LINK redis-server</span>
<span class="hljs-code">    LINK redis-check-dump</span>
<span class="hljs-code">    LINK redis-cli</span>
<span class="hljs-code">    INSTALL redis-sentinel</span>

Hint: To run <span class="hljs-emphasis">'make test'</span> is a good idea ;)

make[2]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13/src'</span>
make[1]: Leaving directory <span class="hljs-smartquote">`/usr/local/codis/extern/redis-2.8.13'</span>
go test ./pkg/... ./cmd/... -race
?       <span class="hljs-emphasis">_/usr/local/codis/pkg/env       [no test files]
ok      _</span>/usr/local/codis/pkg/models    2.253s
ok      <span class="hljs-emphasis">_/usr/local/codis/pkg/proxy/cachepool   0.009s
?       _</span>/usr/local/codis/pkg/proxy/group       [no test files]
ok      <span class="hljs-emphasis">_/usr/local/codis/pkg/proxy/parser      0.018s
?       _</span>/usr/local/codis/pkg/proxy/redisconn   [no test files]
?       <span class="hljs-emphasis">_/usr/local/codis/pkg/proxy/redispool   [no test files]
ok      _</span>/usr/local/codis/pkg/proxy/router      17.146s
?       <span class="hljs-emphasis">_/usr/local/codis/pkg/proxy/router/topology     [no test files]
ok      _</span>/usr/local/codis/pkg/utils     0.012s
ok      <span class="hljs-emphasis">_/usr/local/codis/cmd/cconfig   0.019s
?       _</span>/usr/local/codis/cmd/proxy     [no test files]</code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li><li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li><li>40</li><li>41</li><li>42</li><li>43</li><li>44</li><li>45</li><li>46</li><li>47</li><li>48</li><li>49</li><li>50</li><li>51</li><li>52</li><li>53</li><li>54</li><li>55</li><li>56</li><li>57</li><li>58</li><li>59</li><li>60</li><li>61</li><li>62</li><li>63</li><li>64</li><li>65</li><li>66</li><li>67</li><li>68</li><li>69</li><li>70</li><li>71</li><li>72</li><li>73</li><li>74</li><li>75</li><li>76</li><li>77</li><li>78</li><li>79</li><li>80</li><li>81</li><li>82</li><li>83</li><li>84</li><li>85</li><li>86</li><li>87</li><li>88</li><li>89</li><li>90</li><li>91</li><li>92</li><li>93</li><li>94</li><li>95</li><li>96</li><li>97</li><li>98</li><li>99</li><li>100</li><li>101</li><li>102</li><li>103</li><li>104</li><li>105</li><li>106</li><li>107</li><li>108</li><li>109</li><li>110</li><li>111</li><li>112</li><li>113</li><li>114</li><li>115</li><li>116</li><li>117</li><li>118</li><li>119</li><li>120</li><li>121</li><li>122</li><li>123</li><li>124</li><li>125</li><li>126</li><li>127</li><li>128</li><li>129</li><li>130</li><li>131</li><li>132</li><li>133</li><li>134</li><li>135</li><li>136</li><li>137</li><li>138</li><li>139</li><li>140</li><li>141</li><li>142</li><li>143</li><li>144</li><li>145</li><li>146</li><li>147</li><li>148</li><li>149</li><li>150</li><li>151</li><li>152</li><li>153</li><li>154</li><li>155</li><li>156</li><li>157</li><li>158</li><li>159</li><li>160</li><li>161</li><li>162</li><li>163</li><li>164</li><li>165</li><li>166</li><li>167</li><li>168</li><li>169</li><li>170</li><li>171</li><li>172</li><li>173</li><li>174</li><li>175</li><li>176</li><li>177</li><li>178</li><li>179</li><li>180</li><li>181</li><li>182</li><li>183</li><li>184</li><li>185</li><li>186</li><li>187</li><li>188</li><li>189</li><li>190</li><li>191</li><li>192</li><li>193</li><li>194</li><li>195</li><li>196</li><li>197</li><li>198</li><li>199</li><li>200</li><li>201</li><li>202</li><li>203</li><li>204</li><li>205</li><li>206</li><li>207</li><li>208</li><li>209</li><li>210</li><li>211</li><li>212</li><li>213</li><li>214</li><li>215</li><li>216</li><li>217</li><li>218</li><li>219</li><li>220</li><li>221</li><li>222</li><li>223</li><li>224</li><li>225</li><li>226</li><li>227</li><li>228</li><li>229</li><li>230</li><li>231</li><li>232</li><li>233</li><li>234</li><li>235</li><li>236</li><li>237</li><li>238</li><li>239</li><li>240</li><li>241</li><li>242</li><li>243</li><li>244</li><li>245</li><li>246</li><li>247</li><li>248</li><li>249</li><li>250</li><li>251</li><li>252</li><li>253</li><li>254</li><li>255</li><li>256</li><li>257</li><li>258</li><li>259</li><li>260</li><li>261</li><li>262</li><li>263</li><li>264</li><li>265</li><li>266</li><li>267</li><li>268</li><li>269</li><li>270</li><li>271</li><li>272</li><li>273</li><li>274</li><li>275</li><li>276</li><li>277</li><li>278</li><li>279</li><li>280</li><li>281</li><li>282</li><li>283</li><li>284</li><li>285</li><li>286</li><li>287</li><li>288</li><li>289</li><li>290</li><li>291</li><li>292</li><li>293</li><li>294</li><li>295</li><li>296</li><li>297</li><li>298</li><li>299</li><li>300</li><li>301</li><li>302</li><li>303</li><li>304</li><li>305</li><li>306</li><li>307</li><li>308</li><li>309</li><li>310</li><li>311</li><li>312</li><li>313</li><li>314</li><li>315</li><li>316</li><li>317</li><li>318</li><li>319</li><li>320</li><li>321</li><li>322</li><li>323</li><li>324</li><li>325</li><li>326</li><li>327</li><li>328</li><li>329</li><li>330</li><li>331</li><li>332</li><li>333</li><li>334</li><li>335</li><li>336</li><li>337</li><li>338</li><li>339</li><li>340</li><li>341</li><li>342</li><li>343</li><li>344</li><li>345</li><li>346</li><li>347</li><li>348</li><li>349</li><li>350</li></ul>

安裝測試成功,就可以配置了。
編譯後的二進位制檔案在/usr/local/codis/bin目錄下面。
啟動codis之前需要安裝zookeeper。
下載地址:http://zookeeper.apache.org/releases.html#download
安裝目錄/usr/local/zookeeper

<code class="hljs perl has-numbering"><span class="hljs-keyword">mkdir</span> /usr/<span class="hljs-keyword">local</span>/zookeeper/logs</code><ul style="display: block;" class="pre-numbering"><li>1</li></ul>

vi /usr/local/zookeeper/conf/zoo.cfg配置檔案

<code class="hljs ruby has-numbering">tickTime=<span class="hljs-number">2000</span>
clientPort=<span class="hljs-number">2181</span>
dataDir=<span class="hljs-regexp">/usr/local</span><span class="hljs-regexp">/zookeeper/data</span>
dataLogDir=<span class="hljs-regexp">/usr/local</span><span class="hljs-regexp">/zookeeper/logs</span></code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li></ul>

啟動zookeeper

<code class="hljs lua has-numbering">sh /usr/<span class="hljs-keyword">local</span>/zookeeper/bin/zkServer.sh start</code><ul style="display: block;" class="pre-numbering"><li>1</li></ul>

啟動Codis服務,之前必須啟動zookeeper,sample目錄有簡單的叢集配置。
startall.sh指令碼會同時將redis啟動。

<code class="hljs sql has-numbering"># sh /usr/local/codis/sample/startall.sh 
sleep 3s
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.13 (6e3095dc/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6381
 |    `-._   `._    /     _.-'    |     PID: 1259
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

[1259] 06 Mar 09:55:30.852 # Server started, Redis version 2.8.13
[1259] 06 Mar 09:55:30.853 # WARNING overcommit_memory is <span class="hljs-operator"><span class="hljs-keyword">set</span> <span class="hljs-keyword">to</span> <span class="hljs-number">0</span>! Background save may fail under low memory condition. <span class="hljs-keyword">To</span> fix this issue <span class="hljs-keyword">add</span> <span class="hljs-string">'vm.overcommit_memory = 1'</span> <span class="hljs-keyword">to</span> /etc/sysctl.conf <span class="hljs-keyword">and</span> <span class="hljs-keyword">then</span> reboot <span class="hljs-keyword">or</span> run the command <span class="hljs-string">'sysctl vm.overcommit_memory=1'</span> <span class="hljs-keyword">for</span> this <span class="hljs-keyword">to</span> take effect.
[<span class="hljs-number">1259</span>] <span class="hljs-number">06</span> Mar <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">30.853</span> * The server <span class="hljs-keyword">is</span> now ready <span class="hljs-keyword">to</span> accept connections <span class="hljs-keyword">on</span> port <span class="hljs-number">6381</span>
                _._                                                  
           _.-<span class="hljs-string">``</span>__ <span class="hljs-string">''</span>-._                                             
      _.-<span class="hljs-string">``</span>    <span class="hljs-string">`.  `</span>_.  <span class="hljs-string">''</span>-._           Redis <span class="hljs-number">2.8</span><span class="hljs-number">.13</span> (<span class="hljs-number">6e3095</span>dc/<span class="hljs-number">0</span>) <span class="hljs-number">64</span> <span class="hljs-keyword">bit</span>
  .-<span class="hljs-string">``</span> .-<span class="hljs-string">``</span><span class="hljs-string">`.  `</span><span class="hljs-string">``</span>\/    _.,_ <span class="hljs-string">''</span>-._                                   
 (    <span class="hljs-string">'      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'</span><span class="hljs-string">` _.-'|     Port: 6382
 |    `</span>-._   <span class="hljs-string">`._    /     _.-'    |     PID: 1260
  `</span>-._    <span class="hljs-string">`-._  `</span>-./  _.-<span class="hljs-string">'    _.-'</span>                                   
 |<span class="hljs-string">`-._`</span>-._    <span class="hljs-string">`-.__.-'    _.-'_.-'|                                  
 |    `</span>-._<span class="hljs-string">`-._        _.-'_.-'    |           http://redis.io        
  `</span>-._    <span class="hljs-string">`-._`</span>-.__.-<span class="hljs-string">'_.-'</span>    _.-<span class="hljs-string">'                                   
 |`-._`-._    `-.__.-'</span>    _.-<span class="hljs-string">'_.-'</span>|                                  
 |    <span class="hljs-string">`-._`</span>-._        _.-<span class="hljs-string">'_.-'</span>    |                                  
  <span class="hljs-string">`-._    `</span>-._<span class="hljs-string">`-.__.-'_.-'    _.-'                                   
      `</span>-._    <span class="hljs-string">`-.__.-'    _.-'                                       
          `</span>-._        _.-<span class="hljs-string">'                                           
              `-.__.-'</span>                                               

[<span class="hljs-number">1260</span>] <span class="hljs-number">06</span> Mar <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">30.846</span> # Server started, Redis version <span class="hljs-number">2.8</span><span class="hljs-number">.13</span>
[<span class="hljs-number">1260</span>] <span class="hljs-number">06</span> Mar <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">30.846</span> # WARNING overcommit_memory <span class="hljs-keyword">is</span> <span class="hljs-keyword">set</span> <span class="hljs-keyword">to</span> <span class="hljs-number">0</span>! Background save may fail under low memory condition. <span class="hljs-keyword">To</span> fix this issue <span class="hljs-keyword">add</span> <span class="hljs-string">'vm.overcommit_memory = 1'</span> <span class="hljs-keyword">to</span> /etc/sysctl.conf <span class="hljs-keyword">and</span> <span class="hljs-keyword">then</span> reboot <span class="hljs-keyword">or</span> run the command <span class="hljs-string">'sysctl vm.overcommit_memory=1'</span> <span class="hljs-keyword">for</span> this <span class="hljs-keyword">to</span> take effect.
[<span class="hljs-number">1260</span>] <span class="hljs-number">06</span> Mar <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">30.846</span> * The server <span class="hljs-keyword">is</span> now ready <span class="hljs-keyword">to</span> accept connections <span class="hljs-keyword">on</span> port <span class="hljs-number">6382</span>
<span class="hljs-keyword">add</span> <span class="hljs-keyword">group</span> <span class="hljs-number">1</span> <span class="hljs-keyword">with</span> a master(localhost:<span class="hljs-number">6381</span>), Notice: <span class="hljs-keyword">do</span> <span class="hljs-keyword">not</span> use localhost <span class="hljs-keyword">when</span> <span class="hljs-keyword">in</span> produciton
<span class="hljs-keyword">add</span> <span class="hljs-keyword">group</span> <span class="hljs-number">2</span> <span class="hljs-keyword">with</span> a master(localhost:<span class="hljs-number">6382</span>), Notice: <span class="hljs-keyword">do</span> <span class="hljs-keyword">not</span> use localhost <span class="hljs-keyword">when</span> <span class="hljs-keyword">in</span> produciton
slots initializing...
<span class="hljs-keyword">add</span> <span class="hljs-keyword">group</span> <span class="hljs-number">1</span> <span class="hljs-keyword">with</span> a master(localhost:<span class="hljs-number">6381</span>), Notice: <span class="hljs-keyword">do</span> <span class="hljs-keyword">not</span> use localhost <span class="hljs-keyword">when</span> <span class="hljs-keyword">in</span> produciton
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
<span class="hljs-keyword">add</span> <span class="hljs-keyword">group</span> <span class="hljs-number">2</span> <span class="hljs-keyword">with</span> a master(localhost:<span class="hljs-number">6382</span>), Notice: <span class="hljs-keyword">do</span> <span class="hljs-keyword">not</span> use localhost <span class="hljs-keyword">when</span> <span class="hljs-keyword">in</span> produciton
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
slots initializing...
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
done
<span class="hljs-keyword">set</span> slot ranges <span class="hljs-keyword">to</span> server groups...
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
done
shut down proxy_1...
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
done
<span class="hljs-keyword">start</span> new proxy...
done
sleep <span class="hljs-number">3</span>s
nohup: appending <span class="hljs-keyword">output</span> <span class="hljs-keyword">to</span> ‘nohup.out’
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">33</span> main.<span class="hljs-keyword">go</span>:<span class="hljs-number">98</span>: [info] dump file path: /usr/<span class="hljs-keyword">local</span>/codis/bin 
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">33</span> main.<span class="hljs-keyword">go</span>:<span class="hljs-number">106</span>: [info] running <span class="hljs-keyword">on</span>  <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>:<span class="hljs-number">19000</span> 
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">33</span> helper.<span class="hljs-keyword">go</span>:<span class="hljs-number">312</span>: [info] &{proxyId:proxy_1 productName:test zkAddr:localhost:<span class="hljs-number">2181</span> f:<nil> netTimeout:<span class="hljs-number">5</span> proto:tcp}
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">33</span> router.<span class="hljs-keyword">go</span>:<span class="hljs-number">628</span>: [info] <span class="hljs-keyword">start</span> <span class="hljs-keyword">with</span> configuration: &{proxyId:proxy_1 productName:test zkAddr:localhost:<span class="hljs-number">2181</span> f:<nil> netTimeout:<span class="hljs-number">5</span> proto:tcp}
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">33</span> router.<span class="hljs-keyword">go</span>:<span class="hljs-number">652</span>: [info] proxy_info:{Id:proxy_1 Addr:<span class="hljs-keyword">go</span>:<span class="hljs-number">19000</span> LastEvent: LastEventTs:<span class="hljs-number">0</span> State:offline Description: DebugVarAddr:<span class="hljs-keyword">go</span>:<span class="hljs-number">11000</span>}
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">09</span>:<span class="hljs-number">55</span>:<span class="hljs-number">34</span> router.<span class="hljs-keyword">go</span>:<span class="hljs-number">615</span>: [fatal] zk: could <span class="hljs-keyword">not</span> <span class="hljs-keyword">connect</span> <span class="hljs-keyword">to</span> a server 
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">11</span>:<span class="hljs-number">12</span>:<span class="hljs-number">51</span> main.<span class="hljs-keyword">go</span>:<span class="hljs-number">98</span>: [info] dump file path: /usr/<span class="hljs-keyword">local</span>/codis/bin 
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">11</span>:<span class="hljs-number">12</span>:<span class="hljs-number">51</span> main.<span class="hljs-keyword">go</span>:<span class="hljs-number">106</span>: [info] running <span class="hljs-keyword">on</span>  <span class="hljs-number">0.0</span><span class="hljs-number">.0</span><span class="hljs-number">.0</span>:<span class="hljs-number">19000</span> 
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">11</span>:<span class="hljs-number">12</span>:<span class="hljs-number">51</span> helper.<span class="hljs-keyword">go</span>:<span class="hljs-number">312</span>: [info] &{proxyId:proxy_1 productName:test zkAddr:localhost:<span class="hljs-number">2181</span> f:<nil> netTimeout:<span class="hljs-number">5</span> proto:tcp}
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">11</span>:<span class="hljs-number">12</span>:<span class="hljs-number">51</span> router.<span class="hljs-keyword">go</span>:<span class="hljs-number">628</span>: [info] <span class="hljs-keyword">start</span> <span class="hljs-keyword">with</span> configuration: &{proxyId:proxy_1 productName:test zkAddr:localhost:<span class="hljs-number">2181</span> f:<nil> netTimeout:<span class="hljs-number">5</span> proto:tcp}
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">11</span>:<span class="hljs-number">12</span>:<span class="hljs-number">51</span> router.<span class="hljs-keyword">go</span>:<span class="hljs-number">652</span>: [info] proxy_info:{Id:proxy_1 Addr:<span class="hljs-keyword">go</span>:<span class="hljs-number">19000</span> LastEvent: LastEventTs:<span class="hljs-number">0</span> State:offline Description: DebugVarAddr:<span class="hljs-keyword">go</span>:<span class="hljs-number">11000</span>}
<span class="hljs-number">2015</span>/<span class="hljs-number">03</span>/<span class="hljs-number">06</span> <span class="hljs-number">11</span>:<span class="hljs-number">12</span>:<span class="hljs-number">51</span> router.<span class="hljs-keyword">go</span>:<span class="hljs-number">600</span>: [warning] proxy_1 wait <span class="hljs-keyword">to</span> be online 
<span class="hljs-keyword">set</span> proxy_1 online
{
  <span class="hljs-string">"msg"</span>: <span class="hljs-string">"OK"</span>,
  <span class="hljs-string">"ret"</span>: <span class="hljs-number">0</span>
}
done</span></code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li><li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li><li>40</li><li>41</li><li>42</li><li>43</li><li>44</li><li>45</li><li>46</li><li>47</li><li>48</li><li>49</li><li>50</li><li>51</li><li>52</li><li>53</li><li>54</li><li>55</li><li>56</li><li>57</li><li>58</li><li>59</li><li>60</li><li>61</li><li>62</li><li>63</li><li>64</li><li>65</li><li>66</li><li>67</li><li>68</li><li>69</li><li>70</li><li>71</li><li>72</li><li>73</li><li>74</li><li>75</li><li>76</li><li>77</li><li>78</li><li>79</li><li>80</li><li>81</li><li>82</li><li>83</li><li>84</li><li>85</li><li>86</li><li>87</li><li>88</li><li>89</li><li>90</li><li>91</li><li>92</li><li>93</li><li>94</li><li>95</li><li>96</li><li>97</li><li>98</li><li>99</li><li>100</li><li>101</li></ul>

啟動之後就可以看到zookeeper裡面的資料了。

<code class="hljs sql has-numbering">[zk: localhost:2181(CONNECTED) 8] ls /zk/codis/db_test 
[migrate_manager, fence, migrate_tasks, <span class="hljs-operator"><span class="hljs-keyword">LOCK</span>, slots, actions, servers, proxy]</span></code><ul style="display: block;" class="pre-numbering"><li>1</li><li>2</li></ul>

3,管理介面顯示

啟動之後就可以訪問admin頁面了。

資料遷移介面

整個桶結構

4,總結

Codis可以完美的解決Redis叢集問題,在目前Redis 3.0版本還不是很穩定的情況下,是非常不錯的解決方案。支援資料擴充套件。
但是並不是所有的redis命令都支援。

如果你使用以下命令:

<code class="hljs sql has-numbering">KEYS, MOVE, OBJECT, <span class="hljs-operator">RENAME, RENAMENX, SORT, SCAN, BITOP,MSETNX, BLPOP, BRPOP, BRPOPLPUSH, PSUBSCRIBE,PUBLISH, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE, DISCARD, <span class="hljs-keyword">EXEC</span>, MULTI, UNWATCH, WATCH, SCRIPT <span class="hljs-keyword">EXISTS</span>, SCRIPT FLUSH, SCRIPT KILL, SCRIPT <span class="hljs-keyword">LOAD</span>, AUTH, ECHO, <span class="hljs-keyword">SELECT</span>, BGREWRITEAOF, BGSAVE, CLIENT KILL, CLIENT LIST, CONFIG <span class="hljs-keyword">GET</span>, CONFIG <span class="hljs-keyword">SET</span>, CONFIG RESETSTAT, DBSIZE, DEBUG OBJECT, DEBUG SEGFAULT, FLUSHALL, FLUSHDB, INFO, LASTSAVE, MONITOR, SAVE, SHUTDOWN, SLAVEOF, SLOWLOG, SYNC, <span class="hljs-keyword">TIME</span></span></code><ul style="display: block;" class="pre-numbering"><li>1</li></ul>

是無法直接遷移到 Codis 上的. 你需要修改你的程式碼, 用其他的方式實現.


轉載:http://blog.csdn.net/freewebsys/article/details/44100919


相關文章