设为首页 收藏本站
查看: 448|回复: 0

[经验分享] Redis集群方案,Codis安装测试

[复制链接]

尚未签到

发表于 2018-11-5 12:53:19 | 显示全部楼层 |阅读模式
  Redis集群方案,Codis安装测试
  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。
  cd /usr/loca/
  wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
  tar -zxvf go1.4.2.linux-amd64.tar.gz
  1
  2
  3
  设置环境变量,vi /etc/profile
  #set go & codis environment
  Export GOROOT=/usr/local/go
  Export PATH=$PATH:$GOROOT/bin
  Export GOPATH=/usr/local/codis
  1
  2
  下载codis
  cd /usr/local
  git clone https://github.com/wandoulabs/codis.git
  #将codis的pkg包拷贝到$GOPATH目录。
  mkdir -p /usr/local/codis/src/github.com/wandoulabs/codis
  cp /usr/local/codis/pkg/ /usr/local/codis/cmd/ /usr/local/codis/src/github.com/wandoulabs/codis -R
  安装codis,需要下载依赖包。比较慢,依赖
  #安装编译工具
  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 `/usr/local/codis/extern/redis-2.8.13'
  cd src && make all
  make[2]: Entering directory `/usr/local/codis/extern/redis-2.8.13/src'
  rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
  (cd ../deps && make distclean)
  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-*)
  make[3]: Leaving directory `/usr/local/codis/extern/redis-2.8.13/deps'
  (rm -f .make-*)
  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_CFLAGS= >> .make-settings
  echo REDIS_LDFLAGS= >> .make-settings
  echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
  echo PREV_FINAL_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_ANSI " MYLDFLAGS=""
  make[4]: Entering directory `/usr/local/codis/extern/redis-2.8.13/deps/hiredis'
  cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
  make[4]: Entering directory `/usr/local/codis/extern/redis-2.8.13/deps/lua/src'
  cc -O2 -Wall -DLUA_ANSI    -c -o lapi.o lapi.c
  MAKE jemalloc
  cd jemalloc && ./configure --with-jemalloc-prefix=je_ --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 `/usr/local/codis/extern/redis-2.8.13/deps/linenoise'
  cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
  cc -O2 -Wall -DLUA_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_ANSI    -c -o ldebug.o ldebug.c
  cc -O2 -Wall -DLUA_ANSI    -c -o ldo.o ldo.c
  cc -O2 -Wall -DLUA_ANSI    -c -o ldump.o ldump.c
  ar rcs libhiredis.a net.o hiredis.o sds.o async.o
  make[4]: Leaving directory `/usr/local/codis/extern/redis-2.8.13/deps/hiredis'
  cc -O2 -Wall -DLUA_ANSI    -c -o lfunc.o lfunc.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lgc.o lgc.c
  cc -O2 -Wall -DLUA_ANSI    -c -o llex.o llex.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lmem.o lmem.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lobject.o lobject.c
  checking for xsltproc... /usr/bin/xsltproc
  checking for gcc... gcc
  cc -O2 -Wall -DLUA_ANSI    -c -o lopcodes.o lopcodes.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lparser.o lparser.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lstate.o lstate.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lstring.o lstring.c
  checking whether the C compiler works... cc -O2 -Wall -DLUA_ANSI    -c -o ltable.o ltable.c
  cc -O2 -Wall -DLUA_ANSI    -c -o ltm.o ltm.c
  cc -O2 -Wall -DLUA_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_ANSI    -c -o lvm.o lvm.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lzio.o lzio.c
  checking whether we are cross compiling... cc -O2 -Wall -DLUA_ANSI    -c -o strbuf.o strbuf.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lauxlib.o lauxlib.c
  no
  checking for suffix of object files... cc -O2 -Wall -DLUA_ANSI    -c -o lbaselib.o lbaselib.c
  o
  checking whether we are using the GNU C compiler... cc -O2 -Wall -DLUA_ANSI    -c -o ldblib.o ldblib.c
  yes
  checking whether gcc accepts -g... cc -O2 -Wall -DLUA_ANSI    -c -o liolib.o liolib.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lmathlib.o lmathlib.c
  yes
  checking for gcc option to accept ISO C89... cc -O2 -Wall -DLUA_ANSI    -c -o loslib.o loslib.c
  none needed
  checking how to run the C preprocessor... cc -O2 -Wall -DLUA_ANSI    -c -o ltablib.o ltablib.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lstrlib.o lstrlib.c
  cc -O2 -Wall -DLUA_ANSI    -c -o loadlib.o loadlib.c
  cc -O2 -Wall -DLUA_ANSI    -c -o linit.o linit.c
  gcc -E
  cc -O2 -Wall -DLUA_ANSI    -c -o lua_cjson.o lua_cjson.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lua_struct.o lua_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_ANSI    -c -o lua_cmsgpack.o lua_cmsgpack.c
  cc -O2 -Wall -DLUA_ANSI    -c -o lua.o lua.c
  lua_cmsgpack.c: In function ‘table_is_an_array’:
  lua_cmsgpack.c:370:21: warning: variable ‘max’ set but not used [-Wunused-but-set-variable]

  long count = 0, max = 0,>  ^
  cc -O2 -Wall -DLUA_ANSI    -c -o luac.o luac.c
  cc -O2 -Wall -DLUA_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_cjson.o lua_struct.o lua_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 `/usr/local/codis/extern/redis-2.8.13/deps/lua/src'
  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>
  checking>
  checking>
  checking>  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*() is compilable... no
  checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
  checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no
  checking whether Darwin OSSpin*() is compilable... no
  checking for stdbool.h that conforms to C99... yes
  checking for _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_macros.h
  config.status: creating include/jemalloc/jemalloc_protos.h
  config.status: creating include/jemalloc/internal/jemalloc_internal.h
  config.status: creating test/test.sh
  config.status: creating test/include/test/jemalloc_test.h
  config.status: creating config.stamp
  config.status: creating bin/jemalloc.sh
  config.status: creating include/jemalloc/jemalloc_defs.h
  config.status: creating include/jemalloc/internal/jemalloc_internal_defs.h
  config.status: creating test/include/test/jemalloc_test_defs.h
  config.status: executing include/jemalloc/internal/private_namespace.h commands
  config.status: executing include/jemalloc/internal/private_unnamespace.h commands
  config.status: executing include/jemalloc/internal/public_symbols.txt commands
  config.status: executing include/jemalloc/internal/public_namespace.h commands
  config.status: executing include/jemalloc/internal/public_unnamespace.h commands
  config.status: executing include/jemalloc/internal/size_classes.h commands
  config.status: executing include/jemalloc/jemalloc_protos_jet.h commands
  config.status: executing include/jemalloc/jemalloc_rename.h commands
  config.status: executing include/jemalloc/jemalloc_mangle.h commands
  config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
  config.status: executing include/jemalloc/jemalloc.h commands
  ===============================================================================
  jemalloc version   : 3.6.0-0-g46c0af68bd248b04df75e4f92d5fb804c3d75340
  library revision   : 1
  CC                 : gcc
  CPPFLAGS           :  -D_GNU_SOURCE -D_REENTRANT
  CFLAGS             : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -fvisibility=hidden
  LDFLAGS            :
  EXTRA_LDFLAGS      :
  LIBS               :  -lpthread
  RPATH_EXTRA        :
  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_srcroot        : /usr/local/codis/extern/redis-2.8.13/deps/jemalloc/
  objroot            :
  abs_objroot        : /usr/local/codis/extern/redis-2.8.13/deps/jemalloc/
  JEMALLOC_PREFIX    : je_
  JEMALLOC_PRIVATE_NAMESPACE
  : je_
  install_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_lock          : 0
  tls                : 1
  ===============================================================================
  cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
  make[4]: Entering directory `/usr/local/codis/extern/redis-2.8.13/deps/jemalloc'
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.o src/chunk_dss.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_mmap.o src/chunk_mmap.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/quarantine.o src/quarantine.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/util.o src/util.c
  gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_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_dss.o src/chunk_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 `/usr/local/codis/extern/redis-2.8.13/deps/jemalloc'
  make[3]: Leaving directory `/usr/local/codis/extern/redis-2.8.13/deps'
  CC adlist.o
  CC ae.o
  CC anet.o
  CC dict.o
  CC redis.o
  CC sds.o
  CC zmalloc.o
  CC lzf_c.o
  CC lzf_d.o
  CC pqsort.o
  CC zipmap.o
  CC sha1.o
  CC ziplist.o

  CC>  CC networking.o
  CC util.o
  CC object.o
  CC db.o
  CC replication.o
  CC rdb.o
  CC t_string.o
  CC t_list.o
  CC t_set.o
  CC t_zset.o
  CC t_hash.o
  CC config.o
  CC aof.o
  CC pubsub.o
  CC multi.o
  CC debug.o
  CC sort.o
  CC intset.o
  CC syncio.o
  CC migrate.o
  CC endianconv.o
  CC slowlog.o
  CC scripting.o
  CC bio.o
  CC rio.o
  CC rand.o
  CC memtest.o
  CC crc64.o
  CC crc32.o
  CC bitops.o
  CC sentinel.o
  CC notify.o
  CC setproctitle.o
  CC hyperloglog.o
  CC latency.o
  CC sparkline.o
  CC slots.o
  CC redis-cli.o
  CC redis-benchmark.o
  CC redis-check-dump.o
  CC redis-check-aof.o
  LINK redis-benchmark
  LINK redis-check-aof
  LINK redis-server
  LINK redis-check-dump
  LINK redis-cli
  INSTALL redis-sentinel

  Hint: To run 'make test' is a good>  make[2]: Leaving directory `/usr/local/codis/extern/redis-2.8.13/src'
  make[1]: Leaving directory `/usr/local/codis/extern/redis-2.8.13'
  go test ./pkg/... ./cmd/... -race
  ?       _/usr/local/codis/pkg/env       [no test files]
  ok      _/usr/local/codis/pkg/models    2.253s
  ok      _/usr/local/codis/pkg/proxy/cachepool   0.009s
  ?       _/usr/local/codis/pkg/proxy/group       [no test files]
  ok      _/usr/local/codis/pkg/proxy/parser      0.018s
  ?       _/usr/local/codis/pkg/proxy/redisconn   [no test files]
  ?       _/usr/local/codis/pkg/proxy/redispool   [no test files]
  ok      _/usr/local/codis/pkg/proxy/router      17.146s
  ?       _/usr/local/codis/pkg/proxy/router/topology     [no test files]
  ok      _/usr/local/codis/pkg/utils     0.012s
  ok      _/usr/local/codis/cmd/cconfig   0.019s
  ?       _/usr/local/codis/cmd/proxy     [no test files]
  1
  2
  3
  安装测试成功,就可以配置了。
  编译后的二进制文件在/usr/local/codis/bin目录下面。
  启动codis之前需要安装zookeeper。
  下载地址:http://zookeeper.apache.org/releases.html#download
  安装目录/usr/local/zookeeper
  mkdir /usr/local/zookeeper/logs
  1
  vi /usr/local/zookeeper/conf/zoo.cfg配置文件
  tickTime=2000
  clientPort=2181
  dataDir=/usr/local/zookeeper/data
  dataLogDir=/usr/local/zookeeper/logs
  1
  2
  3
  4
  启动zookeeper
  sh /usr/local/zookeeper/bin/zkServer.sh start
  1
  启动Codis服务,之前必须启动zookeeper,sample目录有简单的集群配置。
  startall.sh脚本会同时将redis启动。
  # 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 set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
  [1259] 06 Mar 09:55:30.853 * The server is now ready to accept connections on port 6381
  _._
  _.-``__ ''-._
  _.-``    `.  `_.  ''-._           Redis 2.8.13 (6e3095dc/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
  (    '      ,       .-`  | `,    )     Running in stand alone mode
  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6382
  |    `-._   `._    /     _.-'    |     PID: 1260
  `-._    `-._  `-./  _.-'    _.-'
  |`-._`-._    `-.__.-'    _.-'_.-'|
  |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
  |`-._`-._    `-.__.-'    _.-'_.-'|
  |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
  `-._    `-.__.-'    _.-'
  `-._        _.-'
  `-.__.-'
  [1260] 06 Mar 09:55:30.846 # Server started, Redis version 2.8.13
  [1260] 06 Mar 09:55:30.846 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
  [1260] 06 Mar 09:55:30.846 * The server is now ready to accept connections on port 6382
  add group 1 with a master(localhost:6381), Notice: do not use localhost when in produciton
  add group 2 with a master(localhost:6382), Notice: do not use localhost when in produciton
  slots initializing...
  add group 1 with a master(localhost:6381), Notice: do not use localhost when in produciton
  {
  "msg": "OK",
  "ret": 0
  }
  add group 2 with a master(localhost:6382), Notice: do not use localhost when in produciton
  {
  "msg": "OK",
  "ret": 0
  }
  slots initializing...
  {
  "msg": "OK",
  "ret": 0
  }
  done
  set slot ranges to server groups...
  {
  "msg": "OK",
  "ret": 0
  }
  {
  "msg": "OK",
  "ret": 0
  }
  done
  shut down proxy_1...
  {
  "msg": "OK",
  "ret": 0
  }
  done
  start new proxy...
  done
  sleep 3s
  nohup: appending output to ‘nohup.out’
  2015/03/06 09:55:33 main.go:98: [info] dump file path: /usr/local/codis/bin
  2015/03/06 09:55:33 main.go:106: [info] running on  0.0.0.0:19000
  2015/03/06 09:55:33 helper.go:312: [info] &{proxyId:proxy_1 productName:test zkAddr:localhost:2181 f: netTimeout:5 proto:tcp}
  2015/03/06 09:55:33 router.go:628: [info] start with configuration: &{proxyId:proxy_1 productName:test zkAddr:localhost:2181 f: netTimeout:5 proto:tcp}
  2015/03/06 09:55:33 router.go:652: [info] proxy_info:{Id:proxy_1 Addr:go:19000 LastEvent: LastEventTs:0 State:offline Description: DebugVarAddr:go:11000}
  2015/03/06 09:55:34 router.go:615: [fatal] zk: could not connect to a server
  2015/03/06 11:12:51 main.go:98: [info] dump file path: /usr/local/codis/bin
  2015/03/06 11:12:51 main.go:106: [info] running on  0.0.0.0:19000
  2015/03/06 11:12:51 helper.go:312: [info] &{proxyId:proxy_1 productName:test zkAddr:localhost:2181 f: netTimeout:5 proto:tcp}
  2015/03/06 11:12:51 router.go:628: [info] start with configuration: &{proxyId:proxy_1 productName:test zkAddr:localhost:2181 f: netTimeout:5 proto:tcp}
  2015/03/06 11:12:51 router.go:652: [info] proxy_info:{Id:proxy_1 Addr:go:19000 LastEvent: LastEventTs:0 State:offline Description: DebugVarAddr:go:11000}
  2015/03/06 11:12:51 router.go:600: [warning] proxy_1 wait to be online
  set proxy_1 online
  {
  "msg": "OK",
  "ret": 0
  }
  done
  1
  启动之后就可以看到zookeeper里面的数据了。
  [zk: localhost:2181(CONNECTED) 8] ls /zk/codis/db_test
  [migrate_manager, fence, migrate_tasks, LOCK, slots, actions, servers, proxy]
  1
  2
  3,管理界面显示
  启动之后就可以访问admin页面了。

  数据迁移界面

  整个桶结构

  4,总结
  Codis可以完美的解决Redis集群问题,在目前Redis 3.0版本还不是很稳定的情况下,是非常不错的解决方案。支持数据扩展。
  但是并不是所有的redis命令都支持。
  如果你使用以下命令:
  KEYS, MOVE, OBJECT, RENAME, RENAMENX, SORT, SCAN, BITOP,MSETNX, BLPOP, BRPOP, BRPOPLPUSH, PSUBSCRIBE,PUBLISH, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE, DISCARD, EXEC, MULTI, UNWATCH, WATCH, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL, SCRIPT LOAD, AUTH, ECHO, SELECT, BGREWRITEAOF, BGSAVE, CLIENT KILL, CLIENT LIST, CONFIG GET, CONFIG SET, CONFIG RESETSTAT, DBSIZE, DEBUG OBJECT, DEBUG SEGFAULT, FLUSHALL, FLUSHDB, INFO, LASTSAVE, MONITOR, SAVE, SHUTDOWN, SLAVEOF, SLOWLOG, SYNC, TIME
  是无法直接迁移到Codis 上的. 你需要修改你的代码, 用其他的方式实现.


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-631146-1-1.html 上篇帖子: Redis 优化配置 下篇帖子: Redis安装教程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表