本文記錄一次在CentOS上安裝Memcache的過程,其中也包含了安裝過程當中遇到的錯誤以及相應的解決方法。linux
能夠訪問libevent.org網站下載最新的libevent,本文使用的是libevent-2.0.22-stablegit
,將下載的tar.gz包放到本身想安裝的目錄下。github
[root@dev18 libevent]# tar -zvxf libevent-2.0.22-stable.tar.gz
進入解壓後的目錄,執行./configurebash
[root@dev18 libevent]# cd libevent-2.0.22-stable [root@dev18 libevent]# ./configure
執行後,部分配置顯示的內容以下:app
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編譯memcached
[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安裝Libeventui
[root@dev18 libevent-2.0.22-stable]# make install
部分安裝顯示的內容以下:spa
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的安裝。prototype
安裝好Libevent以後,咱們就能繼續前進安裝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
[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編譯
[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安裝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的簡單安裝和啓動就完成了。