memcached安装运行
生活随笔
收集整理的這篇文章主要介紹了
memcached安装运行
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1. 安裝libevent?
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure ?
make
make install --用root用戶,否則沒權(quán)限
2:安裝memcached
tar zxvf memcached-1.4.5.tar.gz
cd memcached-1.4.5.tar.gz
./configure ?--with-libevent=/usr
說明:configure 需要加 libevent的安裝路徑
make
make install --用root用戶,否則沒權(quán)限
安裝完成后會把memcached放到 /usr/local/bin/memcached
[jifeng@jifeng04 ~]$ tar zxf memcached-1.4.20.tar.gz [jifeng@jifeng04 ~]$ cd memcached-1.4.20 [jifeng@jifeng04 memcached-1.4.20]$ ./configure --with-libevent=/usr checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-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 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 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 checking for gcc option to accept ISO C99... -std=gnu99 checking whether gcc -std=gnu99 and cc understand -c and -o together... yes 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... -lrt checking for library containing socket... none required checking for library containing gethostbyname... none required checking for libevent directory... /usr 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 alignment... need checking for GCC atomics... yes checking for setppriv... no checking umem.h usability... no checking umem.h presence... no checking for umem.h... no checking for xml2rfc... no checking for xsltproc... no configure: creating ./config.status config.status: creating Makefile config.status: creating doc/Makefile config.status: creating config.h config.status: executing depfiles commands [jifeng@jifeng04 memcached-1.4.20]$make [root@jifeng04 memcached-1.4.20]$make install
libevent 的位置所以,請先使用whereis libevent 得到位置,然后連接到memcached 所尋找的路徑
# whereis libevent libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.so /usr/local/lib/libevent.a
然后,再看memcached 從哪里找它
# LD_DEBUG=libs memcached -v 2>&1 > /dev/null | less
可以看到:是/usr/lib/libevent-2.0.so.5,所以,創(chuàng)建軟鏈
?ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
[jifeng@jifeng04 memcached-1.4.20]$ ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5 ln: 創(chuàng)建符號鏈接 "/usr/lib/libevent-2.0.so.5": 權(quán)限不夠 [jifeng@jifeng04 memcached-1.4.20]$ su - 密碼: [root@jifeng04 ~]# ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5 [root@jifeng04 ~]# exit logout
memcached基本選項(xiàng) memcached -d -m 1024 -u root -l 10.3.7.215 -p 11211 -c 256 -P /tmp/memcached.pid
-d 選項(xiàng)是啟動一個守護(hù)進(jìn)程,?
-m 是分配給Memcache使用的內(nèi)存數(shù)量,單位是MB,這里是1024MB
-u 是運(yùn)行Memcache的用戶,這里是root
-l 是監(jiān)聽的服務(wù)器IP地址,如果有多個地址的話,這里指定了服務(wù)器的IP地址10.3.7.215?
-p 是設(shè)置Memcache監(jiān)聽的端口,這里設(shè)置了11211,最好是1024以上的端口
-c 選項(xiàng)是最大運(yùn)行的并發(fā)連接數(shù),默認(rèn)是1024,這里設(shè)置了256,按照你服務(wù)器的負(fù)載量來設(shè)定
-P 是設(shè)置保存Memcache的pid文件
kill `cat /tmp/memcached.pid` 檢查memcached是否正常運(yùn)行 #ps aux | grep memcached #telnet localhost 11211 .... echo stats | nc 10.3.7.215 11211
會顯示memcached的基本信息 [jifeng@jifeng03 ~]$ echo stats | nc 10.3.7.215 11211 STAT pid 14279 STAT uptime 79957 STAT time 1407767792 STAT version 1.4.20 STAT libevent 2.0.21-stable STAT pointer_size 64 STAT rusage_user 1.392788 STAT rusage_system 0.910861 STAT curr_connections 5 STAT total_connections 7 STAT connection_structures 6 STAT reserved_fds 20 STAT cmd_get 2 STAT cmd_set 0 STAT cmd_flush 0 STAT cmd_touch 0 STAT get_hits 0 STAT get_misses 2 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 22 STAT bytes_written 10 STAT limit_maxbytes 1073741824 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT hash_power_level 16 STAT hash_bytes 524288 STAT hash_is_expanding 0 STAT malloc_fails 0 STAT bytes 0 STAT curr_items 0 STAT total_items 0 STAT expired_unfetched 0 STAT evicted_unfetched 0 STAT evictions 0 STAT reclaimed 0 STAT crawler_reclaimed 0 END
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure ?
make
make install --用root用戶,否則沒權(quán)限
2:安裝memcached
tar zxvf memcached-1.4.5.tar.gz
cd memcached-1.4.5.tar.gz
./configure ?--with-libevent=/usr
說明:configure 需要加 libevent的安裝路徑
make
make install --用root用戶,否則沒權(quán)限
安裝完成后會把memcached放到 /usr/local/bin/memcached
[jifeng@jifeng04 ~]$ tar zxf memcached-1.4.20.tar.gz [jifeng@jifeng04 ~]$ cd memcached-1.4.20 [jifeng@jifeng04 memcached-1.4.20]$ ./configure --with-libevent=/usr checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-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 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 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 checking for gcc option to accept ISO C99... -std=gnu99 checking whether gcc -std=gnu99 and cc understand -c and -o together... yes 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... -lrt checking for library containing socket... none required checking for library containing gethostbyname... none required checking for libevent directory... /usr 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 alignment... need checking for GCC atomics... yes checking for setppriv... no checking umem.h usability... no checking umem.h presence... no checking for umem.h... no checking for xml2rfc... no checking for xsltproc... no configure: creating ./config.status config.status: creating Makefile config.status: creating doc/Makefile config.status: creating config.h config.status: executing depfiles commands [jifeng@jifeng04 memcached-1.4.20]$make [root@jifeng04 memcached-1.4.20]$make install
啟動時出現(xiàn)“memcached: error while loading shared libraries:libevent-2.0.so.5: cannot
open shared object file: No such file or directory”之類的信息,表示memcached 找不到libevent 的位置所以,請先使用whereis libevent 得到位置,然后連接到memcached 所尋找的路徑
# whereis libevent libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.so /usr/local/lib/libevent.a
然后,再看memcached 從哪里找它
# LD_DEBUG=libs memcached -v 2>&1 > /dev/null | less
可以看到:是/usr/lib/libevent-2.0.so.5,所以,創(chuàng)建軟鏈
?ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
[jifeng@jifeng04 memcached-1.4.20]$ ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5 ln: 創(chuàng)建符號鏈接 "/usr/lib/libevent-2.0.so.5": 權(quán)限不夠 [jifeng@jifeng04 memcached-1.4.20]$ su - 密碼: [root@jifeng04 ~]# ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5 [root@jifeng04 ~]# exit logout
3:啟動memcached
[jifeng@jifeng04 memcached-1.4.20]$ /usr/local/bin/memcached -d -m 1024 -l 10.3.7.215 -p 11211 [jifeng@jifeng04 memcached-1.4.20]$memcached基本選項(xiàng) memcached -d -m 1024 -u root -l 10.3.7.215 -p 11211 -c 256 -P /tmp/memcached.pid
-d 選項(xiàng)是啟動一個守護(hù)進(jìn)程,?
-m 是分配給Memcache使用的內(nèi)存數(shù)量,單位是MB,這里是1024MB
-u 是運(yùn)行Memcache的用戶,這里是root
-l 是監(jiān)聽的服務(wù)器IP地址,如果有多個地址的話,這里指定了服務(wù)器的IP地址10.3.7.215?
-p 是設(shè)置Memcache監(jiān)聽的端口,這里設(shè)置了11211,最好是1024以上的端口
-c 選項(xiàng)是最大運(yùn)行的并發(fā)連接數(shù),默認(rèn)是1024,這里設(shè)置了256,按照你服務(wù)器的負(fù)載量來設(shè)定
-P 是設(shè)置保存Memcache的pid文件
kill `cat /tmp/memcached.pid` 檢查memcached是否正常運(yùn)行 #ps aux | grep memcached #telnet localhost 11211 .... echo stats | nc 10.3.7.215 11211
會顯示memcached的基本信息 [jifeng@jifeng03 ~]$ echo stats | nc 10.3.7.215 11211 STAT pid 14279 STAT uptime 79957 STAT time 1407767792 STAT version 1.4.20 STAT libevent 2.0.21-stable STAT pointer_size 64 STAT rusage_user 1.392788 STAT rusage_system 0.910861 STAT curr_connections 5 STAT total_connections 7 STAT connection_structures 6 STAT reserved_fds 20 STAT cmd_get 2 STAT cmd_set 0 STAT cmd_flush 0 STAT cmd_touch 0 STAT get_hits 0 STAT get_misses 2 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 22 STAT bytes_written 10 STAT limit_maxbytes 1073741824 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT hash_power_level 16 STAT hash_bytes 524288 STAT hash_is_expanding 0 STAT malloc_fails 0 STAT bytes 0 STAT curr_items 0 STAT total_items 0 STAT expired_unfetched 0 STAT evicted_unfetched 0 STAT evictions 0 STAT reclaimed 0 STAT crawler_reclaimed 0 END
總結(jié)
以上是生活随笔為你收集整理的memcached安装运行的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ActiveMQ的集群与高可用
- 下一篇: redis作为hibernate的二级缓