Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态、数据库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。其守护进程(daemon )是用C写的,但是客户端可以用任何语言来编写,并通过memcached协议与守护进程通信。
实验环境:
在centos7环境下
jdk版本:1.8
因为是基于libevent的事件处理,所以先安装libevent
yum -y install gcc libevent libevent-devel 已加载插件:fastestmirror, langpacks base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql57-community | 2.5 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): mysql-connectors-community/x86_64/primary_db | 20 kB 00:00:00 (2/4): mysql-tools-community/x86_64/primary_db | 41 kB 00:00:00 (3/4): mysql57-community/x86_64/primary_db | 144 kB 00:00:00 (4/4): updates/7/x86_64/primary_db | 6.9 MB 00:00:05 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirror.bit.edu.cn * updates: mirrors.aliyun.com 软件包 libevent-2.0.21-4.el7.x86_64 已安装并且是最新版本 正在解决依赖关系 --> 正在检查事务 ---> 软件包 libevent-devel.x86_64.0.2.0.21-4.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ============================================================================================================== Package 架构 版本 源 大小 ============================================================================================================== 正在安装: libevent-devel x86_64 2.0.21-4.el7 base 85 k 事务概要 ============================================================================================================== 安装 1 软件包 总下载量:85 k 安装大小:357 k Downloading packages: libevent-devel-2.0.21-4.el7.x86_64.rpm | 85 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : libevent-devel-2.0.21-4.el7.x86_64 1/1 验证中 : libevent-devel-2.0.21-4.el7.x86_64 1/1 已安装: libevent-devel.x86_64 0:2.0.21-4.el7 完毕!
安装memcached缓存服务器
wget http://memcached.org/files/memcached-1.5.7.tar.gz tar -zxvf memcached-1.5.7.tar.gz cd memcached-1.5.7 ./configure --prefix=/data/soft/memcached && make && make install
编译安装过程如下
./configure --prefix=/data/soft/memcached && make && make install checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for icc in use... no checking for clang in use... no checking for ANSI C header files... yes 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 __SUNPRO_C is declared... no checking for gcc option to accept ISO C99... -std=gnu99 checking sasl/sasl.h usability... no checking sasl/sasl.h presence... no checking for sasl/sasl.h... no checking for gcov... /usr/bin/gcov checking for main in -lgcov... yes checking for library containing clock_gettime... none required checking for library containing socket... none required checking for library containing gethostbyname... none required checking for libevent directory... (system) checking for library containing umem_cache_create... no checking for library containing gethugepagesizes... no checking for stdbool.h that conforms to C99... yes checking for _Bool... yes checking for inttypes.h... (cached) yes checking for sasl_callback_ft... no checking for print macros for integers (C99 section 7.8.1)... yes checking for an ANSI C-conforming const... yes checking for socklen_t... yes checking for endianness... little checking for htonll... no checking for library containing pthread_create... none required checking for mlockall... yes checking for getpagesizes... no checking for memcntl... no checking for sigignore... yes checking for clock_gettime... yes checking for accept4... yes checking for getopt_long... yes checking for alignment... none checking for GCC atomics... yes checking for GCC 64bit atomics... yes checking for setppriv... no checking for pledge... no checking umem.h usability... no checking umem.h presence... no checking for umem.h... no checking for xml2rfc... no checking for xsltproc... /usr/bin/xsltproc checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating doc/Makefile config.status: creating config.h config.status: executing depfiles commands make all-recursive make[1]: 进入目录“/data/soft/memcached-1.5.7” Making all in doc make[2]: 进入目录“/data/soft/memcached-1.5.7/doc” make all-am make[3]: 进入目录“/data/soft/memcached-1.5.7/doc” make[3]: 对“all-am”无需做任何事。 make[3]: 离开目录“/data/soft/memcached-1.5.7/doc” make[2]: 离开目录“/data/soft/memcached-1.5.7/doc” make[2]: 进入目录“/data/soft/memcached-1.5.7” gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-memcached.o -MD -MP -MF .deps/memcached-memcached.Tpo -c -o memcached-memcached.o `test -f 'memcached.c' || echo './'`memcached.c mv -f .deps/memcached-memcached.Tpo .deps/memcached-memcached.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-hash.o -MD -MP -MF .deps/memcached-hash.Tpo -c -o memcached-hash.o `test -f 'hash.c' || echo './'`hash.c mv -f .deps/memcached-hash.Tpo .deps/memcached-hash.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-jenkins_hash.o -MD -MP -MF .deps/memcached-jenkins_hash.Tpo -c -o memcached-jenkins_hash.o `test -f 'jenkins_hash.c' || echo './'`jenkins_hash.c mv -f .deps/memcached-jenkins_hash.Tpo .deps/memcached-jenkins_hash.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-murmur3_hash.o -MD -MP -MF .deps/memcached-murmur3_hash.Tpo -c -o memcached-murmur3_hash.o `test -f 'murmur3_hash.c' || echo './'`murmur3_hash.c mv -f .deps/memcached-murmur3_hash.Tpo .deps/memcached-murmur3_hash.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-slabs.o -MD -MP -MF .deps/memcached-slabs.Tpo -c -o memcached-slabs.o `test -f 'slabs.c' || echo './'`slabs.c mv -f .deps/memcached-slabs.Tpo .deps/memcached-slabs.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-items.o -MD -MP -MF .deps/memcached-items.Tpo -c -o memcached-items.o `test -f 'items.c' || echo './'`items.c mv -f .deps/memcached-items.Tpo .deps/memcached-items.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-assoc.o -MD -MP -MF .deps/memcached-assoc.Tpo -c -o memcached-assoc.o `test -f 'assoc.c' || echo './'`assoc.c mv -f .deps/memcached-assoc.Tpo .deps/memcached-assoc.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-thread.o -MD -MP -MF .deps/memcached-thread.Tpo -c -o memcached-thread.o `test -f 'thread.c' || echo './'`thread.c mv -f .deps/memcached-thread.Tpo .deps/memcached-thread.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-daemon.o -MD -MP -MF .deps/memcached-daemon.Tpo -c -o memcached-daemon.o `test -f 'daemon.c' || echo './'`daemon.c mv -f .deps/memcached-daemon.Tpo .deps/memcached-daemon.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-stats.o -MD -MP -MF .deps/memcached-stats.Tpo -c -o memcached-stats.o `test -f 'stats.c' || echo './'`stats.c mv -f .deps/memcached-stats.Tpo .deps/memcached-stats.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-util.o -MD -MP -MF .deps/memcached-util.Tpo -c -o memcached-util.o `test -f 'util.c' || echo './'`util.c mv -f .deps/memcached-util.Tpo .deps/memcached-util.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-bipbuffer.o -MD -MP -MF .deps/memcached-bipbuffer.Tpo -c -o memcached-bipbuffer.o `test -f 'bipbuffer.c' || echo './'`bipbuffer.c mv -f .deps/memcached-bipbuffer.Tpo .deps/memcached-bipbuffer.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-logger.o -MD -MP -MF .deps/memcached-logger.Tpo -c -o memcached-logger.o `test -f 'logger.c' || echo './'`logger.c mv -f .deps/memcached-logger.Tpo .deps/memcached-logger.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-crawler.o -MD -MP -MF .deps/memcached-crawler.Tpo -c -o memcached-crawler.o `test -f 'crawler.c' || echo './'`crawler.c mv -f .deps/memcached-crawler.Tpo .deps/memcached-crawler.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-itoa_ljust.o -MD -MP -MF .deps/memcached-itoa_ljust.Tpo -c -o memcached-itoa_ljust.o `test -f 'itoa_ljust.c' || echo './'`itoa_ljust.c mv -f .deps/memcached-itoa_ljust.Tpo .deps/memcached-itoa_ljust.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-slab_automove.o -MD -MP -MF .deps/memcached-slab_automove.Tpo -c -o memcached-slab_automove.o `test -f 'slab_automove.c' || echo './'`slab_automove.c mv -f .deps/memcached-slab_automove.Tpo .deps/memcached-slab_automove.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -DNDEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-cache.o -MD -MP -MF .deps/memcached-cache.Tpo -c -o memcached-cache.o `test -f 'cache.c' || echo './'`cache.c mv -f .deps/memcached-cache.Tpo .deps/memcached-cache.Po gcc -std=gnu99 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o memcached memcached-memcached.o memcached-hash.o memcached-jenkins_hash.o memcached-murmur3_hash.o memcached-slabs.o memcached-items.o memcached-assoc.o memcached-thread.o memcached-daemon.o memcached-stats.o memcached-util.o memcached-bipbuffer.o memcached-logger.o memcached-crawler.o memcached-itoa_ljust.o memcached-slab_automove.o memcached-cache.o -levent gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-memcached.o -MD -MP -MF .deps/memcached_debug-memcached.Tpo -c -o memcached_debug-memcached.o `test -f 'memcached.c' || echo './'`memcached.c mv -f .deps/memcached_debug-memcached.Tpo .deps/memcached_debug-memcached.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-hash.o -MD -MP -MF .deps/memcached_debug-hash.Tpo -c -o memcached_debug-hash.o `test -f 'hash.c' || echo './'`hash.c mv -f .deps/memcached_debug-hash.Tpo .deps/memcached_debug-hash.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-jenkins_hash.o -MD -MP -MF .deps/memcached_debug-jenkins_hash.Tpo -c -o memcached_debug-jenkins_hash.o `test -f 'jenkins_hash.c' || echo './'`jenkins_hash.c mv -f .deps/memcached_debug-jenkins_hash.Tpo .deps/memcached_debug-jenkins_hash.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-murmur3_hash.o -MD -MP -MF .deps/memcached_debug-murmur3_hash.Tpo -c -o memcached_debug-murmur3_hash.o `test -f 'murmur3_hash.c' || echo './'`murmur3_hash.c mv -f .deps/memcached_debug-murmur3_hash.Tpo .deps/memcached_debug-murmur3_hash.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-slabs.o -MD -MP -MF .deps/memcached_debug-slabs.Tpo -c -o memcached_debug-slabs.o `test -f 'slabs.c' || echo './'`slabs.c mv -f .deps/memcached_debug-slabs.Tpo .deps/memcached_debug-slabs.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-items.o -MD -MP -MF .deps/memcached_debug-items.Tpo -c -o memcached_debug-items.o `test -f 'items.c' || echo './'`items.c mv -f .deps/memcached_debug-items.Tpo .deps/memcached_debug-items.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-assoc.o -MD -MP -MF .deps/memcached_debug-assoc.Tpo -c -o memcached_debug-assoc.o `test -f 'assoc.c' || echo './'`assoc.c mv -f .deps/memcached_debug-assoc.Tpo .deps/memcached_debug-assoc.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-thread.o -MD -MP -MF .deps/memcached_debug-thread.Tpo -c -o memcached_debug-thread.o `test -f 'thread.c' || echo './'`thread.c mv -f .deps/memcached_debug-thread.Tpo .deps/memcached_debug-thread.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-daemon.o -MD -MP -MF .deps/memcached_debug-daemon.Tpo -c -o memcached_debug-daemon.o `test -f 'daemon.c' || echo './'`daemon.c mv -f .deps/memcached_debug-daemon.Tpo .deps/memcached_debug-daemon.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-stats.o -MD -MP -MF .deps/memcached_debug-stats.Tpo -c -o memcached_debug-stats.o `test -f 'stats.c' || echo './'`stats.c mv -f .deps/memcached_debug-stats.Tpo .deps/memcached_debug-stats.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-util.o -MD -MP -MF .deps/memcached_debug-util.Tpo -c -o memcached_debug-util.o `test -f 'util.c' || echo './'`util.c mv -f .deps/memcached_debug-util.Tpo .deps/memcached_debug-util.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-bipbuffer.o -MD -MP -MF .deps/memcached_debug-bipbuffer.Tpo -c -o memcached_debug-bipbuffer.o `test -f 'bipbuffer.c' || echo './'`bipbuffer.c mv -f .deps/memcached_debug-bipbuffer.Tpo .deps/memcached_debug-bipbuffer.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-logger.o -MD -MP -MF .deps/memcached_debug-logger.Tpo -c -o memcached_debug-logger.o `test -f 'logger.c' || echo './'`logger.c mv -f .deps/memcached_debug-logger.Tpo .deps/memcached_debug-logger.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-crawler.o -MD -MP -MF .deps/memcached_debug-crawler.Tpo -c -o memcached_debug-crawler.o `test -f 'crawler.c' || echo './'`crawler.c mv -f .deps/memcached_debug-crawler.Tpo .deps/memcached_debug-crawler.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-itoa_ljust.o -MD -MP -MF .deps/memcached_debug-itoa_ljust.Tpo -c -o memcached_debug-itoa_ljust.o `test -f 'itoa_ljust.c' || echo './'`itoa_ljust.c mv -f .deps/memcached_debug-itoa_ljust.Tpo .deps/memcached_debug-itoa_ljust.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-slab_automove.o -MD -MP -MF .deps/memcached_debug-slab_automove.Tpo -c -o memcached_debug-slab_automove.o `test -f 'slab_automove.c' || echo './'`slab_automove.c mv -f .deps/memcached_debug-slab_automove.Tpo .deps/memcached_debug-slab_automove.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached_debug-cache.o -MD -MP -MF .deps/memcached_debug-cache.Tpo -c -o memcached_debug-cache.o `test -f 'cache.c' || echo './'`cache.c mv -f .deps/memcached_debug-cache.Tpo .deps/memcached_debug-cache.Po gcc -std=gnu99 -fprofile-arcs -ftest-coverage -DMEMCACHED_DEBUG -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o memcached-debug memcached_debug-memcached.o memcached_debug-hash.o memcached_debug-jenkins_hash.o memcached_debug-murmur3_hash.o memcached_debug-slabs.o memcached_debug-items.o memcached_debug-assoc.o memcached_debug-thread.o memcached_debug-daemon.o memcached_debug-stats.o memcached_debug-util.o memcached_debug-bipbuffer.o memcached_debug-logger.o memcached_debug-crawler.o memcached_debug-itoa_ljust.o memcached_debug-slab_automove.o memcached_debug-cache.o -lgcov -levent gcc -std=gnu99 -DHAVE_CONFIG_H -I. -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT sizes.o -MD -MP -MF .deps/sizes.Tpo -c -o sizes.o sizes.c mv -f .deps/sizes.Tpo .deps/sizes.Po gcc -std=gnu99 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o sizes sizes.o -levent gcc -std=gnu99 -DHAVE_CONFIG_H -I. -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT testapp.o -MD -MP -MF .deps/testapp.Tpo -c -o testapp.o testapp.c mv -f .deps/testapp.Tpo .deps/testapp.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT util.o -MD -MP -MF .deps/util.Tpo -c -o util.o util.c mv -f .deps/util.Tpo .deps/util.Po gcc -std=gnu99 -DHAVE_CONFIG_H -I. -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT cache.o -MD -MP -MF .deps/cache.Tpo -c -o cache.o cache.c mv -f .deps/cache.Tpo .deps/cache.Po gcc -std=gnu99 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o testapp testapp.o util.o cache.o -levent gcc -std=gnu99 -DHAVE_CONFIG_H -I. -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT timedrun.o -MD -MP -MF .deps/timedrun.Tpo -c -o timedrun.o timedrun.c mv -f .deps/timedrun.Tpo .deps/timedrun.Po gcc -std=gnu99 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -o timedrun timedrun.o -levent make[2]: 离开目录“/data/soft/memcached-1.5.7” make[1]: 离开目录“/data/soft/memcached-1.5.7” make install-recursive make[1]: 进入目录“/data/soft/memcached-1.5.7” Making install in doc make[2]: 进入目录“/data/soft/memcached-1.5.7/doc” make install-am make[3]: 进入目录“/data/soft/memcached-1.5.7/doc” make[4]: 进入目录“/data/soft/memcached-1.5.7/doc” make[4]: 对“install-exec-am”无需做任何事。 /usr/bin/mkdir -p '/data/soft/memcached/share/man/man1' /usr/bin/install -c -m 644 memcached.1 '/data/soft/memcached/share/man/man1' make[4]: 离开目录“/data/soft/memcached-1.5.7/doc” make[3]: 离开目录“/data/soft/memcached-1.5.7/doc” make[2]: 离开目录“/data/soft/memcached-1.5.7/doc” make[2]: 进入目录“/data/soft/memcached-1.5.7” make[3]: 进入目录“/data/soft/memcached-1.5.7” /usr/bin/mkdir -p '/data/soft/memcached/bin' /usr/bin/install -c memcached '/data/soft/memcached/bin' /usr/bin/mkdir -p '/data/soft/memcached/include/memcached' /usr/bin/install -c -m 644 protocol_binary.h '/data/soft/memcached/include/memcached' make[3]: 离开目录“/data/soft/memcached-1.5.7” make[2]: 离开目录“/data/soft/memcached-1.5.7” make[1]: 离开目录“/data/soft/memcached-1.5.7”
启动服务
bin/memcached -d -m 1024 -u root -l 127.0.0.1 -p 322054 -c 1024 #选项说明,这里只列出比较重要的选项,具体选项说明使用memcached -h来查阅 -p TCP端口,默认为11211,可以不设置 -U UDP端口,默认为11211,0为关闭 -l 监听的ip地址 -d 守护进程(daemon) -u 指定用户,如果当前为 root ,需要使用此参数指定用户 -m 最大内存,单位MB。默认64MB,32位操作系统,每个进程最多只能使用2GB,64位无限制 -M 禁止LRU策略,内存耗尽时返回错误,而不是删除数据 -c 最大连接数,默认是1024 -vv 查看日志 -P memcache的pid文件,结束memcache进程:kill `cat /tmp/memcached_32054.pid` -f 增长因子,默认1.25 -n 初始chunk=key+suffix+value+32结构体,默认48字节 -L 启用大内存页,可以降低内存浪费,改进性能 -t 线程数,默认4。由于memcached采用NIO,所以更多线程没有太多作用 -R 每个event连接最大并发数,默认20 -C 禁用CAS命令(可以禁止版本计数,减少开销) -I 每次申请内存的页的大小(page),默认1M,最小1k,最大128M -F 禁用flush_all
查看进程
很多种方式可以查看
第一种
pgrep memcached 34953
第二种
ps -ef |grep memcached root 34953 1 0 14:31 ? 00:00:00 bin/memcached -d -m 1024 -u root -l 127.0.0.1 -p 3456 -c 1024 root 34990 5190 0 14:32 pts/1 00:00:00 grep --color=auto memcached
第三种
ps -aux | grep memcached root 34953 0.0 0.0 413808 1080 ? Ssl 14:31 0:00 bin/memcached -d -m 1024 -u root -l 127.0.0.1 -p 3456 -c 1024 root 35115 0.0 0.0 112680 976 pts/1 R+ 14:34 0:00 grep --color=auto memcached
安装telnet远程协助,基本上是自己的服务端安装telnet-server,客户端安装telnet-client,我为了方便,将软件安在一台服务器上,直接 yum安装
yum -y install telnet telnet-server
使用telnet测试说明
telnet localhost 3456 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. stats STAT pid 34953 STAT uptime 851 STAT time 1524206745 STAT version 1.5.7 STAT libevent 2.0.21-stable STAT pointer_size 64 STAT rusage_user 0.049797 STAT rusage_system 0.161840 STAT max_connections 1024 STAT curr_connections 1 STAT total_connections 4 STAT rejected_connections 0 STAT connection_structures 2 STAT reserved_fds 20 STAT cmd_get 0 STAT cmd_set 2 STAT cmd_flush 0 STAT cmd_touch 0 STAT get_hits 0 STAT get_misses 0 STAT get_expired 0 STAT get_flushed 0 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT touch_hits 0 STAT touch_misses 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 178 STAT bytes_written 2129 STAT limit_maxbytes 1073741824 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT time_in_listen_disabled_us 0 STAT threads 4 STAT conn_yields 0 STAT hash_power_level 16 STAT hash_bytes 524288 STAT hash_is_expanding 0 STAT slab_reassign_rescues 0 STAT slab_reassign_chunk_rescues 0 STAT slab_reassign_evictions_nomem 0 STAT slab_reassign_inline_reclaim 0 STAT slab_reassign_busy_items 0 STAT slab_reassign_busy_deletes 0 STAT slab_reassign_running 0 STAT slabs_moved 0 STAT lru_crawler_running 0 STAT lru_crawler_starts 1275 STAT lru_maintainer_juggles 1014 STAT malloc_fails 0 STAT log_worker_dropped 0 STAT log_worker_written 0 STAT log_watcher_skipped 0 STAT log_watcher_sent 0 STAT bytes 65 STAT curr_items 1 STAT total_items 1 STAT slab_global_page_pool 0 STAT expired_unfetched 0 STAT evicted_unfetched 0 STAT evicted_active 0 STAT evictions 0 STAT reclaimed 0 STAT crawler_reclaimed 0 STAT crawler_items_checked 0 STAT lrutail_reflocked 0 STAT moves_to_cold 1 STAT moves_to_warm 0 STAT moves_within_lru 0 STAT direct_reclaims 0 STAT lru_bumps_dropped 0 END
停止服务
kill -9 进程号
好了,这就是简单的memcached的安装方式,我本着简化,直接,方便的原则,参考网上各位大神的笔记心得,希望大家能够喜欢!!