RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Twemproxy安装配置-创新互联

简介:

创新互联专业为企业提供大箐山网站建设、大箐山做网站、大箐山网站设计、大箐山网站制作等企业网站建设、网页设计与制作、大箐山企业网站模板建站服务,10余年大箐山做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

简单来说,twemproxy是twitter开发的一个redis代理proxy。

通过Twemproxy可以使用多台服务器来水平扩张redis服务,可以有效的避免单点故障问题。

虽然使用Twemproxy需要更多的硬件资源和在redis性能有一定的损失(twitter测试约20%),

但是能够提高整个系统的HA也是相当划算的。

Twemproxy可以把数据sharding到多台服务器的上,每台服务器存储着整个数据集的一部分。

因而,当某一台redis服务器宕机了,那么也就失去了一部分数据。如果借助于redis的master-slave replication,

能保证在任何一台redis不能工作情况下,仍然能够保证能够存在一个整个数据集的完全覆盖,

那么整个redis  group(或者称作cluster)仍然能够正常工作。

安装配置:

autoconf下载地址:http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz

twemproxy的安装要求autoconf的版本在2.64以上,否则提示”error: Autoconf version 2.64 or higher is required“。autoconf直接make和make install即可。

twemproxy下载地址:https://codeload.github.com/twitter/twemproxy/zip/master

下载完成后进入twemproxy-master目录

[root@redis-server twemproxy-master]# autoreconf --install

libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.

libtoolize: copying file `config/ltmain.sh'

libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.

libtoolize: copying file `m4/libtool.m4'

libtoolize: copying file `m4/ltoptions.m4'

libtoolize: copying file `m4/ltsugar.m4'

libtoolize: copying file `m4/ltversion.m4'

libtoolize: copying file `m4/lt~obsolete.m4'

libtoolize: `AC_PROG_RANLIB' is rendered obsolete by `LT_INIT'

configure.ac:36: installing 'config/config.guess'

configure.ac:36: installing 'config/config.sub'

configure.ac:16: installing 'config/install-sh'

configure.ac:16: installing 'config/missing'

src/Makefile.am: installing 'config/depcomp'

[root@redis-server twemproxy-master]# autoconf -f -i -v

autoconf: running /usr/local/bin/autom4te -f --melt -v --language=autoconf --output=configure configure.ac

autom4te: the trace request object is:

autom4te: $VAR1 = bless( [

autom4te:          '4',

autom4te:          0,

autom4te:          [

autom4te:           '/usr/local/share/autoconf'

autom4te:          ],

autom4te:          [

autom4te:           '/usr/local/share/autoconf/m4sugar/m4sugar.m4',

autom4te:           '/usr/local/share/autoconf/m4sugar/m4sh.m4',

autom4te:           '/usr/local/share/autoconf/autoconf/autoconf.m4',

autom4te:           'aclocal.m4',

autom4te:           'configure.ac'

autom4te:          ],

autom4te:          {

autom4te:           '_LT_AC_TAGCONFIG' => 1,

autom4te:           'AM_PROG_F77_C_O' => 1,

autom4te:           'AC_INIT' => 1,

autom4te:           'm4_pattern_forbid' => 1,

autom4te:           '_AM_COND_IF' => 1,

autom4te:           'AC_CANONICAL_TARGET' => 1,

autom4te:           'AC_SUBST' => 1,

autom4te:           'AC_CONFIG_LIBOBJ_DIR' => 1,

autom4te:           'AC_FC_SRCEXT' => 1,

autom4te:           'AC_CANONICAL_HOST' => 1,

autom4te:           'AC_PROG_LIBTOOL' => 1,

autom4te:           'AM_INIT_AUTOMAKE' => 1,

autom4te:           'AM_PATH_GUILE' => 1,

autom4te:           'AC_CONFIG_SUBDIRS' => 1,

autom4te:           'AM_AUTOMAKE_VERSION' => 1,

autom4te:           'LT_CONFIG_LTDL_DIR' => 1,

autom4te:           'AC_REQUIRE_AUX_FILE' => 1,

autom4te:           'AC_CONFIG_LINKS' => 1,

autom4te:           'm4_sinclude' => 1,

autom4te:           'LT_SUPPORTED_TAG' => 1,

autom4te:           'AM_MAINTAINER_MODE' => 1,

autom4te:           'AM_NLS' => 1,

autom4te:           'AC_FC_PP_DEFINE' => 1,

autom4te:           'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,

autom4te:           'AM_MAKEFILE_INCLUDE' => 1,

autom4te:           '_m4_warn' => 1,

autom4te:           'AM_PROG_CXX_C_O' => 1,

autom4te:           '_AM_COND_ENDIF' => 1,

autom4te:           '_AM_MAKEFILE_INCLUDE' => 1,

autom4te:           'AM_ENABLE_MULTILIB' => 1,

autom4te:           'AM_SILENT_RULES' => 1,

autom4te:           'AM_PROG_MOC' => 1,

autom4te:           'AC_CONFIG_FILES' => 1,

autom4te:           'include' => 1,

autom4te:           'LT_INIT' => 1,

autom4te:           'AM_PROG_AR' => 1,

autom4te:           'AM_GNU_GETTEXT' => 1,

autom4te:           'AC_LIBSOURCE' => 1,

autom4te:           'AM_PROG_FC_C_O' => 1,

autom4te:           'AC_CANONICAL_BUILD' => 1,

autom4te:           'AC_FC_FREEFORM' => 1,

autom4te:           'AH_OUTPUT' => 1,

autom4te:           'AC_FC_PP_SRCEXT' => 1,

autom4te:           '_AM_SUBST_NOTMAKE' => 1,

autom4te:           'AC_CONFIG_AUX_DIR' => 1,

autom4te:           'sinclude' => 1,

autom4te:           'AM_PROG_CC_C_O' => 1,

autom4te:           'm4_pattern_allow' => 1,

autom4te:           'AM_XGETTEXT_OPTION' => 1,

autom4te:           'AC_CANONICAL_SYSTEM' => 1,

autom4te:           'AM_CONDITIONAL' => 1,

autom4te:           'AC_CONFIG_HEADERS' => 1,

autom4te:           'AC_DEFINE_TRACE_LITERAL' => 1,

autom4te:           'AM_POT_TOOLS' => 1,

autom4te:           'm4_include' => 1,

autom4te:           '_AM_COND_ELSE' => 1,

autom4te:           'AC_SUBST_TRACE' => 1

autom4te:          }

autom4te:         ], 'Autom4te::Request' );

autom4te: running: /usr/local/bin/m4 --nesting-limit=1024 --gnu --include=/usr/local/share/autoconf --debug=aflq --fatal-warning --debugfile=autom4te.cache/traces.4t --trace=AC_CANONICAL_BUILD --trace=AC_CANONICAL_HOST --trace=AC_CANONICAL_SYSTEM --trace=AC_CANONICAL_TARGET --trace=AC_CONFIG_AUX_DIR --trace=AC_CONFIG_FILES --trace=AC_CONFIG_HEADERS --trace=AC_CONFIG_LIBOBJ_DIR --trace=AC_CONFIG_LINKS --trace=AC_CONFIG_SUBDIRS --trace=AC_DEFINE_TRACE_LITERAL --trace=AC_FC_FREEFORM --trace=AC_FC_PP_DEFINE --trace=AC_FC_PP_SRCEXT --trace=AC_FC_SRCEXT --trace=AC_INIT --trace=AC_LIBSOURCE --trace=AC_PROG_LIBTOOL --trace=AC_REQUIRE_AUX_FILE --trace=AC_SUBST --trace=AC_SUBST_TRACE --trace=AH_OUTPUT --trace=AM_AUTOMAKE_VERSION --trace=AM_CONDITIONAL --trace=AM_ENABLE_MULTILIB --trace=AM_GNU_GETTEXT --trace=AM_GNU_GETTEXT_INTL_SUBDIR --trace=AM_INIT_AUTOMAKE --trace=AM_MAINTAINER_MODE --trace=AM_MAKEFILE_INCLUDE --trace=AM_NLS --trace=AM_PATH_GUILE --trace=AM_POT_TOOLS --trace=AM_PROG_AR --trace=AM_PROG_CC_C_O --trace=AM_PROG_CXX_C_O --trace=AM_PROG_F77_C_O --trace=AM_PROG_FC_C_O --trace=AM_PROG_MOC --trace=AM_SILENT_RULES --trace=AM_XGETTEXT_OPTION --trace=LT_CONFIG_LTDL_DIR --trace=LT_INIT --trace=LT_SUPPORTED_TAG --trace=_AM_COND_ELSE --trace=_AM_COND_ENDIF --trace=_AM_COND_IF --trace=_AM_MAKEFILE_INCLUDE --trace=_AM_SUBST_NOTMAKE --trace=_LT_AC_TAGCONFIG --trace=_m4_warn --trace=include --trace=m4_include --trace=m4_pattern_allow --trace=m4_pattern_forbid --trace=m4_sinclude --trace=sinclude /usr/local/share/autoconf/m4sugar/m4sugar.m4 /usr/local/share/autoconf/m4sugar/m4sh.m4 /usr/local/share/autoconf/autoconf/autoconf.m4 aclocal.m4 configure.ac > autom4te.cache/output.4t

autom4te: formatting traces for `/tmp/am4tcWNSQj/warnings': _m4_warn

autom4te: reading /tmp/am4tcWNSQj/warnings

autom4te: creating configure

autom4te: formatting traces for `/tmp/am4tcWNSQj/patterns': m4_pattern_allow, m4_pattern_forbid

autom4te: forbidden tokens: ^_?A[CHUM]_|_AC_|^LIBOBJS$|^_?m4_|^dnl$|^_?AS_|^_?LT_[A-Z_]+$

autom4te: forbidden token : ^LIBOBJS$ => do not use LIBOBJS directly, use AC_LIBOBJ (see section `AC_LIBOBJ vs LIBOBJS'

autom4te: allowed  tokens: ^AS_FLAGS$|^SHELL$|^PATH_SEPARATOR$|^PACKAGE_NAME$|^PACKAGE_TARNAME$|^PACKAGE_VERSION$|^PACKAGE_STRING$|^PACKAGE_BUGREPORT$|^PACKAGE_URL$|^exec_prefix$|^prefix$|^program_transform_name$|^bindir$|^sbindir$|^libexecdir$|^datarootdir$|^datadir$|^sysconfdir$|^sharedstatedir$|^localstatedir$|^includedir$|^oldincludedir$|^docdir$|^infodir$|^htmldir$|^dvidir$|^pdfdir$|^psdir$|^libdir$|^localedir$|^mandir$|^PACKAGE_NAME$|^PACKAGE_TARNAME$|^PACKAGE_VERSION$|^PACKAGE_STRING$|^PACKAGE_BUGREPORT$|^PACKAGE_URL$|^DEFS$|^ECHO_C$|^ECHO_N$|^ECHO_T$|^LIBS$|^build_alias$|^host_alias$|^target_alias$|^AM_[A-Z]+FLAGS$|^INSTALL_PROGRAM$|^INSTALL_SCRIPT$|^INSTALL_DATA$|^am__isrc$|^CYGPATH_W$|^PACKAGE$|^VERSION$|^PACKAGE$|^VERSION$|^ACLOCAL$|^AUTOCONF$|^AUTOMAKE$|^AUTOHEADER$|^MAKEINFO$|^install_sh$|^STRIP$|^INSTALL_STRIP_PROGRAM$|^MKDIR_P$|^mkdir_p$|^AWK$|^SET_MAKE$|^am__leading_dot$|^AMTAR$|^am__tar$|^am__untar$|^AM_V$|^AM_DEFAULT_V$|^AM_DEFAULT_VERBOSITY$|^AM_BACKSLASH$|^NC_VERSION_MAJOR$|^NC_VERSION_MINOR$|^NC_VERSION_PATCH$|^NC_VERSION_STRING$|^AWK$|^CC$|^CFLAGS$|^LDFLAGS$|^LIBS$|^CPPFLAGS$|^CC$|^CC$|^CC$|^CC$|^ac_ct_CC$|^EXEEXT$|^OBJEXT$|^DEPDIR$|^am__include$|^am__quote$|^AMDEP_TRUE$|^AMDEP_FALSE$|^AMDEPBACKSLASH$|^am__nodep$|^CCDEPMODE$|^am__fastdepCC_TRUE$|^am__fastdepCC_FALSE$|^CPP$|^CPPFLAGS$|^CPP$|^CXX$|^CXXFLAGS$|^LDFLAGS$|^LIBS$|^CPPFLAGS$|^CXX$|^ac_ct_CXX$|^CXXDEPMODE$|^am__fastdepCXX_TRUE$|^am__fastdepCXX_FALSE$|^LN_S$|^SET_MAKE$|^RANLIB$|^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$|^LIBTOOL$|^build$|^build_cpu$|^build_vendor$|^build_os$|^host$|^host_cpu$|^host_vendor$|^host_os$|^SED$|^GREP$|^EGREP$|^FGREP$|^GREP$|^LD$|^DUMPBIN$|^ac_ct_DUMPBIN$|^DUMPBIN$|^NM$|^OBJDUMP$|^OBJDUMP$|^DLLTOOL$|^DLLTOOL$|^AR$|^ac_ct_AR$|^STRIP$|^RANLIB$|LT_OBJDIR|^LT_OBJDIR$|^MANIFEST_TOOL$|^DSYMUTIL$|^NMEDIT$|^LIPO$|^OTOOL$|^OTOOL64$|^STDC_HEADERS$|^HAVE_DLFCN_H$|^CXXCPP$|^CPPFLAGS$|^CXXCPP$|^LD$|^int8_t$|^int16_t$|^int32_t$|^int64_t$|^HAVE_UNSIGNED_LONG_LONG_INT$|^HAVE_LONG_LONG_INT$|^HAVE_INTMAX_T$|^intmax_t$|^HAVE_INTPTR_T$|^intptr_t$|^_UINT8_T$|^uint8_t$|^uint16_t$|^_UINT32_T$|^uint32_t$|^_UINT64_T$|^uint64_t$|^HAVE_UINTMAX_T$|^uintmax_t$|^HAVE_UINTPTR_T$|^uintptr_t$|^off_t$|^pid_t$|^size_t$|^ssize_t$|^WORDS_BIGENDIAN$|^HAVE_LITTLE_ENDIAN$|^HAVE__BOOL$|^HAVE_STDBOOL_H$|^HAVE_EXECINFO_H$|^HAVE_BACKTRACE$|^HAVE_SYS_EPOLL_H$|^HAVE_SYS_EVENT_H$|^HAVE_LIBM$|^HAVE_LIBPTHREAD$|^HAVE_VFORK_H$|^HAVE_WORKING_VFORK$|^vfork$|^HAVE_WORKING_FORK$|^HAVE_STDLIB_H$|^HAVE_MALLOC$|^HAVE_MALLOC$|^LIBOBJS$|^malloc$|^HAVE_STDLIB_H$|^HAVE_REALLOC$|^HAVE_REALLOC$|^LIBOBJS$|^realloc$|^HAVE_SOCKET$|^HAVE_EPOLL$|^HAVE_KQUEUE$|^HAVE_EVENT_PORTS$|^OS_LINUX_TRUE$|^OS_LINUX_FALSE$|^OS_BSD_TRUE$|^OS_BSD_FALSE$|^OS_SOLARIS_TRUE$|^OS_SOLARIS_FALSE$|^OS_FREEBSD_TRUE$|^OS_FREEBSD_FALSE$|^HAVE_ASSERT_PANIC$|^HAVE_DEBUG_LOG$|^HAVE_ASSERT_LOG$|^HAVE_DEBUG_LOG$|^HAVE_DEBUG_LOG$|^HAVE_STATS$|^subdirs$|^LIBOBJS$|^LTLIBOBJS$|^am__EXEEXT_TRUE$|^am__EXEEXT_FALSE$

编译安装twemproxy

./configure --prefix=/export/Server/twemproxy

报错

configure: error: cannot find install-sh, install.sh, or shtool in config "."/config

方法:

automake --add-missing

再来:

./configure --prefix=/export/Server/twemproxy

报错

config.status: error: cannot find input file: `Makefile.in'

方法:

automake --add-missing

automake

再来:

./configure --prefix=/export/Server/twemproxy

成功

最后

make -j 8

make install

添加环境变量

echo "PATH=$PATH:/export/Server/twemproxy/sbin/" >> /etc/profile

source /etc/profile

新建配置文件

创建pid文件目录

cd /usr/local/twemproxy

mkdir run

创建proxy配置文件

mkdir sbin/conf

cd /sbin/conf

拷贝配置文件

cp /data/packages/twemproxy-master/conf/nutcracker.yml /usr/local/twemproxy/sbin/conf

然后根据需求修改配置文件

测试配置文件语法正确性

[root@redis-server sbin]# ./nutcracker -t

测试配置文件的时候报错

nutcracker: configuration file 'conf/nutcracker.yml' syntax is invalid

conf下面的nutcracker.yml文件必须放在twemproxy/sbin/目录下,否则报上面错误

再次测试

[root@redis-server sbin]# ./nutcracker -t

nutcracker: configuration file 'conf/nutcracker.yml' syntax is ok

启动

./nutcracker -d -c /export/Server/twemproxy/sbin/conf/nutcracker.yml -p /export/Server/twemproxy/run/redisproxy.pid -o /export/Server/twemproxy/run/redisproxy.log

查看日志

/export/Server/twemproxy/run/redisproxy.log

性能测试

这里使用redis自带的redis-benchmark进行简单的性能测试,测试结果如下:

Set测试:

通过twemproxy测试:

[root@redis-server src]#redis-benchmark -h 10.23.22.240 -p 22121 -c 100 -t set -d 100 -l –q

SET: 38167.94 requests per second

直接对后端redis测试:

[root@redis-server ~]#redis-benchmark -h 10.23.22.241 -p 6379 -c 100 -t set -d 100 -l –q

SET: 53191.49 requests per second

Get测试:

通过twemproxy测试:

[root@redis-server src]#redis-benchmark -h 10.23.22.240 -p 22121 -c 100 -t get -d 100 -l -q

GET: 37453.18 requests per second

直接对后端redis测试:

[root@redis-server ~]#redis-benchmark -h 10.23.22.241 -p 6379 -c 100 -t get -d 100 -l -q

GET: 62111.80 requests per second

查看键值分布:

[root@redis-server ~]#redis-cli info|grep db0

db0:keys=51483,expires=0,avg_ttl=0

[root@redis-server ~]#redis-cli info|grep db0

db0:keys=48525,expires=0,avg_ttl=0

测试结果:以基本的set get命令通过twemproxy性能有所下降;通过twemproxy分布基本平均。测试数据以业务测试为准。

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻标题:Twemproxy安装配置-创新互联
本文网址:http://scpingwu.com/article/deojec.html