CentOS上安装Memcache及问题解决

前端之家收集整理的这篇文章主要介绍了CentOS上安装Memcache及问题解决前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文记录一次在CentOS上安装Memcache的过程,其中也包含了安装过程中遇到的错误以及相应的解决方法

Libevent安装

可以访问libevent.org网站下载最新的libevent,本文使用的是libevent-2.0.22-stable

,将下载的tar.gz包放到自己想安装的目录下。

解压缩

[root@dev18 libevent]# tar -zvxf libevent-2.0.22-stable.tar.gz

./configure

进入解压后的目录,执行./configure

[root@dev18 libevent]# cd libevent-2.0.22-stable
[root@dev18 libevent]# ./configure

执行后,部分配置显示内容如下:

checking for struct addrinfo... yes
checking for struct sockaddr_storage... yes
checking for struct in6_addr.s6_addr32... yes
checking for struct in6_addr.s6_addr16... yes
checking for struct sockaddr_in.sin_len... no
checking for struct sockaddr_in6.sin6_len... no
checking for struct sockaddr_storage.ss_family... yes
checking for struct sockaddr_storage.__ss_family... no
checking for socklen_t... yes
checking whether our compiler supports __func__... yes
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking size of pthread_t... 8
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating libevent.pc
config.status: creating libevent_openssl.pc
config.status: creating libevent_pthreads.pc
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating test/Makefile
config.status: creating sample/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[root@dev18 libevent-2.0.22-stable]#

make

执行make编译

[root@dev18 libevent-2.0.22-stable]# make

部分编译显示内容如下:

mv -f .deps/regress-regress_dns.Tpo .deps/regress-regress_dns.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_testutils.o -MD -MP -MF .deps/regress-regress_testutils.Tpo -c -o regress-regress_testutils.o `test -f 'regress_testutils.c' || echo './'`regress_testutils.c
mv -f .deps/regress-regress_testutils.Tpo .deps/regress-regress_testutils.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_rpc.o -MD -MP -MF .deps/regress-regress_rpc.Tpo -c -o regress-regress_rpc.o `test -f 'regress_rpc.c' || echo './'`regress_rpc.c
mv -f .deps/regress-regress_rpc.Tpo .deps/regress-regress_rpc.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress.gen.o -MD -MP -MF .deps/regress-regress.gen.Tpo -c -o regress-regress.gen.o `test -f 'regress.gen.c' || echo './'`regress.gen.c
mv -f .deps/regress-regress.gen.Tpo .deps/regress-regress.gen.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_et.o -MD -MP -MF .deps/regress-regress_et.Tpo -c -o regress-regress_et.o `test -f 'regress_et.c' || echo './'`regress_et.c
mv -f .deps/regress-regress_et.Tpo .deps/regress-regress_et.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_bufferevent.o -MD -MP -MF .deps/regress-regress_bufferevent.Tpo -c -o regress-regress_bufferevent.o `test -f 'regress_bufferevent.c' || echo './'`regress_bufferevent.c
mv -f .deps/regress-regress_bufferevent.Tpo .deps/regress-regress_bufferevent.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_listener.o -MD -MP -MF .deps/regress-regress_listener.Tpo -c -o regress-regress_listener.o `test -f 'regress_listener.c' || echo './'`regress_listener.c
mv -f .deps/regress-regress_listener.Tpo .deps/regress-regress_listener.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_util.o -MD -MP -MF .deps/regress-regress_util.Tpo -c -o regress-regress_util.o `test -f 'regress_util.c' || echo './'`regress_util.c
mv -f .deps/regress-regress_util.Tpo .deps/regress-regress_util.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-tinytest.o -MD -MP -MF .deps/regress-tinytest.Tpo -c -o regress-tinytest.o `test -f 'tinytest.c' || echo './'`tinytest.c
mv -f .deps/regress-tinytest.Tpo .deps/regress-tinytest.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_main.o -MD -MP -MF .deps/regress-regress_main.Tpo -c -o regress-regress_main.o `test -f 'regress_main.c' || echo './'`regress_main.c
mv -f .deps/regress-regress_main.Tpo .deps/regress-regress_main.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_minheap.o -MD -MP -MF .deps/regress-regress_minheap.Tpo -c -o regress-regress_minheap.o `test -f 'regress_minheap.c' || echo './'`regress_minheap.c
mv -f .deps/regress-regress_minheap.Tpo .deps/regress-regress_minheap.Po
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../compat -I../include -I../include -DTINYTEST_LOCAL     -g -O2 -Wall -fno-strict-aliasing  -MT regress-regress_thread.o -MD -MP -MF .deps/regress-regress_thread.Tpo -c -o regress-regress_thread.o `test -f 'regress_thread.c' || echo './'`regress_thread.c
mv -f .deps/regress-regress_thread.Tpo .deps/regress-regress_thread.Po
/bin/sh ../libtool --tag=CC   --mode=link gcc  -g -O2 -Wall -fno-strict-aliasing    -o regress regress-regress.o regress-regress_buffer.o regress-regress_http.o regress-regress_dns.o regress-regress_testutils.o regress-regress_rpc.o regress-regress.gen.o regress-regress_et.o regress-regress_bufferevent.o regress-regress_listener.o regress-regress_util.o regress-tinytest.o regress-regress_main.o regress-regress_minheap.o regress-regress_thread.o     ../libevent.la ../libevent_pthreads.la   -lrt 
libtool: link: gcc -g -O2 -Wall -fno-strict-aliasing -o .libs/regress regress-regress.o regress-regress_buffer.o regress-regress_http.o regress-regress_dns.o regress-regress_testutils.o regress-regress_rpc.o regress-regress.gen.o regress-regress_et.o regress-regress_bufferevent.o regress-regress_listener.o regress-regress_util.o regress-tinytest.o regress-regress_main.o regress-regress_minheap.o regress-regress_thread.o  ../.libs/libevent.so ../.libs/libevent_pthreads.so -lrt -Wl,-rpath -Wl,/usr/local/lib
make[3]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/test'
make[2]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/test'
make[1]: Leaving directory `/srv/libevent/libevent-2.0.22-stable'
[root@dev18 libevent-2.0.22-stable]#

make install

执行make install安装Libevent

[root@dev18 libevent-2.0.22-stable]# make install

部分安装显示内容如下:

See any operating system documentation about shared libraries for
more information,such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/include'
 /usr/bin/install -c -m 644 event.h evhttp.h evdns.h evrpc.h evutil.h '/usr/local/include'
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 libevent.pc libevent_pthreads.pc '/usr/local/lib/pkgconfig'
make[3]: Leaving directory `/srv/libevent/libevent-2.0.22-stable'
make[2]: Leaving directory `/srv/libevent/libevent-2.0.22-stable'
Making install in include
make[2]: Entering directory `/srv/libevent/libevent-2.0.22-stable/include'
make[3]: Entering directory `/srv/libevent/libevent-2.0.22-stable/include'
make[3]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/usr/local/include'
 /bin/mkdir -p '/usr/local/include/event2'
 /usr/bin/install -c -m 644  event2/buffer.h event2/buffer_compat.h event2/bufferevent.h event2/bufferevent_compat.h event2/bufferevent_ssl.h event2/bufferevent_struct.h event2/dns.h event2/dns_compat.h event2/dns_struct.h event2/event.h event2/event_compat.h event2/event_struct.h event2/http.h event2/http_compat.h event2/http_struct.h event2/keyvalq_struct.h event2/listener.h event2/rpc.h event2/rpc_compat.h event2/rpc_struct.h event2/tag.h event2/tag_compat.h event2/thread.h event2/util.h '/usr/local/include/event2'
 /bin/mkdir -p '/usr/local/include'
 /bin/mkdir -p '/usr/local/include/event2'
 /usr/bin/install -c -m 644  ./event2/event-config.h '/usr/local/include/event2'
make[3]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/include'
make[2]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/include'
Making install in sample
make[2]: Entering directory `/srv/libevent/libevent-2.0.22-stable/sample'
make[3]: Entering directory `/srv/libevent/libevent-2.0.22-stable/sample'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/sample'
make[2]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/sample'
Making install in test
make[2]: Entering directory `/srv/libevent/libevent-2.0.22-stable/test'
make  install-am
make[3]: Entering directory `/srv/libevent/libevent-2.0.22-stable/test'
make[4]: Entering directory `/srv/libevent/libevent-2.0.22-stable/test'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/test'
make[3]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/test'
make[2]: Leaving directory `/srv/libevent/libevent-2.0.22-stable/test'
make[1]: Leaving directory `/srv/libevent/libevent-2.0.22-stable'
[root@dev18 libevent-2.0.22-stable]#

经过 配置(./configure)、编译 (make) 和安装 (make install) 三个步骤就完成了Libevent的安装。

安装好Libevent之后,我们就能继续前进安装Memcache了。

Memcache安装

和安装Libevent步骤类似,我们还是先下载memcache包,然后通过解压、配置(./configure)、编译 (make) 和安装 (make install) 几个步骤来安装。

访问memcache.org下载Memcache,本文下载的版本是memcached-1.4.33.tar.gz

解压缩

[root@dev18 memcached]# tar -zxvf memcached-1.4.33.tar.gz

./configure

进入解压后的目录,执行./configure

[root@dev18 memcached]# cd memcached-1.4.33
[root@dev18 memcached-1.4.33]# ./configure

部分配置显示内容如下:

[root@dev18 memcached-1.4.33]# ./configure
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... /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... /bin/grep
checking for egrep... /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

make

执行make编译

[root@dev18 memcached-1.4.33]# make

部分编译显示内容如下:

[root@dev18 memcached-1.4.33]# make
make  all-recursive
make[1]: Entering directory `/srv/memcached/memcached-1.4.33'
Making all in doc
make[2]: Entering directory `/srv/memcached/memcached-1.4.33/doc'
make  all-am
make[3]: Entering directory `/srv/memcached/memcached-1.4.33/doc'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/srv/memcached/memcached-1.4.33/doc'
make[2]: Leaving directory `/srv/memcached/memcached-1.4.33/doc'
make[2]: Entering directory `/srv/memcached/memcached-1.4.33'
gcc -std=gnu99 -DHAVE_CONFIG_H -I.  -DNDEBUG   -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing -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
mv -f .deps/memcached_debug-bipbuffer.Tpo .deps/memcached_debug-bipbuffer.Po
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -fprofile-arcs -ftest-coverage -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing   -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-cache.o   -lgcov  -levent -lrt 
gcc -std=gnu99 -DHAVE_CONFIG_H -I.     -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -fno-strict-aliasing   -o sizes sizes.o  -levent -lrt 
gcc -std=gnu99 -DHAVE_CONFIG_H -I.     -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing -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 -fno-strict-aliasing   -o testapp testapp.o util.o cache.o  -levent -lrt 
gcc -std=gnu99 -DHAVE_CONFIG_H -I.     -g -O2 -pthread -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fno-strict-aliasing -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 -fno-strict-aliasing   -o timedrun timedrun.o  -levent -lrt 
make[2]: Leaving directory `/srv/memcached/memcached-1.4.33'
make[1]: Leaving directory `/srv/memcached/memcached-1.4.33'
[root@dev18 memcached-1.4.33]#

make install

执行make install安装Memcache

[root@dev18 memcached-1.4.33]# make install

部分安装显示内容如下:

[root@dev18 memcached-1.4.33]# make install
make  install-recursive
make[1]: Entering directory `/srv/memcached/memcached-1.4.33'
Making install in doc
make[2]: Entering directory `/srv/memcached/memcached-1.4.33/doc'
make  install-am
make[3]: Entering directory `/srv/memcached/memcached-1.4.33/doc'
make[4]: Entering directory `/srv/memcached/memcached-1.4.33/doc'
make[4]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 memcached.1 '/usr/local/share/man/man1'
make[4]: Leaving directory `/srv/memcached/memcached-1.4.33/doc'
make[3]: Leaving directory `/srv/memcached/memcached-1.4.33/doc'
make[2]: Leaving directory `/srv/memcached/memcached-1.4.33/doc'
make[2]: Entering directory `/srv/memcached/memcached-1.4.33'
make[3]: Entering directory `/srv/memcached/memcached-1.4.33'
 /bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c memcached '/usr/local/bin'
 /bin/mkdir -p '/usr/local/include/memcached'
 /usr/bin/install -c -m 644 protocol_binary.h '/usr/local/include/memcached'
make[3]: Leaving directory `/srv/memcached/memcached-1.4.33'
make[2]: Leaving directory `/srv/memcached/memcached-1.4.33'
make[1]: Leaving directory `/srv/memcached/memcached-1.4.33'
[root@dev18 memcached-1.4.33]#

同样,

经过 配置(./configure)、编译 (make) 和安装 (make install) 三个步骤就完成了Memcache的安装。

问题及解决

安装好Memcache之后,我们来启动Memcahce,

进入/usr/local/bin目录,执行

memcached -d -m 10 -u root -p 11211 -P /temp/memcached.pid尝试启动Memcache

参数说明:

-d 表示启动的是一个守护线程

-m RAM分配的数量,单位为MB,因为执行小于64MB可能还是会设置成64MB,所以本文就设置为64

摘要https://github.com/memcached/memcached/wiki/ConfiguringServer

-u 指定运行Memcache的用户

-p 执行Memcache监听的端口

-P pid文件保存的地址

出现如下问题:

memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

[root@dev18 ~]# cd /usr/local/bin/
[root@dev18 bin]# memcached -d -m 64 -u root -p 11211 -P /temp/memcached.pid
memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
[root@dev18 bin]#

首先来看一下,Memcahce是从哪里找livevent-2.0.so.5的,使用LD_DEBUG=libs ./memcached -v命令查看。

[root@dev18 bin]# LD_DEBUG=libs ./memcached -v
      3668:	find library=libevent-2.0.so.5 [0]; searching
      3668:	 search cache=/etc/ld.so.cache
      3668:	 search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64		(system search path)
      3668:	  trying file=/lib64/tls/x86_64/libevent-2.0.so.5
      3668:	  trying file=/lib64/tls/libevent-2.0.so.5
      3668:	  trying file=/lib64/x86_64/libevent-2.0.so.5
      3668:	  trying file=/lib64/libevent-2.0.so.5
      3668:	  trying file=/usr/lib64/tls/x86_64/libevent-2.0.so.5
      3668:	  trying file=/usr/lib64/tls/libevent-2.0.so.5
      3668:	  trying file=/usr/lib64/x86_64/libevent-2.0.so.5
      3668:	  trying file=/usr/lib64/libevent-2.0.so.5
      3668:	
./memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
[root@dev18 bin]#

从上面的结果可以看出,Memcache会从/usr/lib64/下查找livevent-2.0.so.5。

接下来,看一下libevent的相关路径信息,使用 whereis libevent来查找。

[root@dev18 bin]# whereis libevent
libevent: /usr/local/lib/libevent.so /usr/local/lib/libevent.la /usr/local/lib/libevent.a

从上面信息可以看出,libevent是被安装在/usr/local/lib/下了,这样问题就找到了。

正是因为路径不一致导致的问题:

libevent是被安装在/usr/local/lib/下,

Memcache会从/usr/lib64/下查找livevent-2.0.so.5

明白了问题所在,解决的办法就变得简单了,创建一个软链接即可

ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

重新尝试启动,没有再报错,

[root@dev18 bin]# ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
[root@dev18 bin]# memcached -d -m 64 -u root -p 11211 -P /temp/memcached.pid

使用ps -ef|grep memcached来查看Memcached相关进程,如下:

[root@dev18 bin]# ps -ef|grep memcached
root      3764     1  0 11:22 ?        00:00:00 memcached -d -m 10 -u root -p 11211 -P /temp/memcached.pid
root      3775  3580  0 11:23 pts/0    00:00:00 grep memcached
[root@dev18 bin]#

至此,Memcache的简单安装和启动就完成了。

原文链接:https://www.f2er.com/centos/379320.html

猜你在找的CentOS相关文章