Memcache is often used to accelerate the processing of applications. memcache is a distributed memory object caching system, so there must be a place to store it. Let's call it the server side. Then, who will store things on it will call it the client side. How can we store it, it must be the client-connect to the server-send things to the server-to store things. The same is true for retrieval. Connect first and get things back.
Install php and httpd in yum mode before installation, and pay attention to the following precautions when installing php In yum mode: yum install php httpd
I haven't used it before. Some time ago, the company needed to use memcache. I checked the information online and installed it. The problems encountered were also recorded as incorrect or not detailed. I hope you can give me some advice.
1) memcached uses the libevent library for Socket processing.
1. wget http://www.monkey.org /~ Provos/libevent-2.0.10-stable.tar.gz
2. tar xzvf libevent-2.0.10-stable.tar.gz
3. cd libevent-2.0.10-stable
4../configure -- prefix =/usr
5. make & make install
Verify that libevent is correctly installed
1. ls-al/usr/lib | grep libevent
1. [root @ test/] # ls-al/usr/lib | grep libevent
2. lrwxrwxrwx 1 root 21 Feb 28 libevent-2.0.so.5-> libevent-2.0.so.5.0.1
3.-rwxr-xr-x 1 root 943520 Feb 28 19:27 libevent-2.0.so.5.0.1
4.-rw-r -- 1 root 1532202 Feb 28 19:27 libevent.
5. lrwxrwxrwx 1 root 26 Feb 28 libevent_core-2.0.so.5-> libevent_core-2.0.so.5.0.1
6.-rwxr-xr-x 1 root 554374 Feb 28 19:27 libevent_core-2.0.so.5.0.1
7.-rw-r -- 1 root 928010 Feb 28 19:27 libevent_core.a
8.-rwxr-xr-x 1 root 971 Feb 28 19: 27 libevent_core.
9. lrwxrwxrwx 1 root 26 Feb 28 libevent_core.so-> libevent_core-2.0.so.5.0.1
10. lrwxrwxrwx 1 root 27 Feb 28 libevent_extra-2.0.so.5-> libevent_extra-2.0.so.5.0.1
11.-rwxr-xr-x 1 root 410763 Feb 28 19:27 libevent_extra-2.0.so.5.0.1
12.-rw-r -- 1 root 604266 Feb 28 19:27 libevent_extra.a
13.-rwxr-xr-x 1 root 978 Feb 28 :27 libevent_extra.la
14. lrwxrwxrwx 1 root 27 Feb 28 libevent_extra.so-> libevent_extra-2.0.so.5.0.1
15.-rwxr-xr-x 1 root 936 Feb 28 19:27 libevent. la
16. lrwxrwxrwx 1 root 29 Feb 28 libevent_openssl-2.0.so.5-> libevent_openssl-2.0.so.5.0.1
17.-rwxr-xr-x 1 root 85731 Feb 28 19:27 libevent_openssl-2.0.so.5.0.1
18.-rw-r -- 1 root 120996 Feb 28 19: 27 libevent_openssl.
19.-rwxr-xr-x 1 root 1007 Feb 28 19: 27 libevent_openssl.
20. lrwxrwxrwx 1 root 29 Feb 28 libevent_openssl.so-> libevent_openssl-2.0.so.5.0.1
21. lrwxrwxrwx 1 root 30 Feb 28 libevent_pthreads-2.0.so.5-> libevent_pthreads-2.0.so.5.0.1
22.-rwxr-xr-x 1 root 18094 Feb 28 19:27 libevent_pthreads-2.0.so.5.0.1
23.-rw-r -- 1 root 18678 Feb 28 19:27 libevent_pthreads.a
24.-rwxr-xr-x 1 root 999 Feb 28 libevent_pthreads.la
25. lrwxrwxrwx 1 root 30 Feb 28 :27 libevent_pthreads.so-> libevent_pthreads-2.0.so.5.0.1
26. lrwxrwxrwx 1 root 21 Feb 28 libevent. so-> libevent-2.0.so.5.0.1
2) install memcached
1. wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
2. tar xzvf memcached-1.4.5.tar.gz
3. cd memcached-1.4.5
4../configure -- with-libevent =/usr
5. make & make install
After the installation is complete, the program automatically places memcached to/usr/local/bin/memcached
1. [root @ test/] # which memcached
2./usr/local/bin/memcached
3) install the memcache extension of PHP.
Memcache Project
1. http://pecl.php.net/package/memcache
Installation Steps
1. wget http://pecl.php.net/get/memcache-3.0.5.tgz
2. tar xf memcache-3.0.5.tgz
3. cd memcache-3.0.5
4. usr/local/php/bin/phpize (generate the compilation environment./configure)
5. In this step, if the php path installed with yum is changed to -- with-php-config =/usr/bin/php-config
6../configure -- enable-memcache -- with-php-config =/usr/local/php/bin/php-config -- with-zlib-dir
7. make & make install
Prompt after installation is complete
1. Installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
2. The following is a prompt for installing php In Yum:
3. Installing shared extensions: "/usr/lib64/php/modules"
Configure the php. ini file
Modify extension_dir:
1. extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626 /"
2. The yum installation configuration file is as follows:
3. extension_dir = "/usr/lib64/php/modules"
Add a line to load the memcache extension: extension = memcache. so
1. extension = memcache. so
Verify if memcache extension is successfully loaded in PHP
1. [root @ test/] # php-m
2. [PHP Modules]
3. Core
4. ctype
5. curl
6. date
7. dom
8. eAccelerator
9. ereg
10. fileinfo
11. filter
12. hash
13. iconv
14. json
15. libxml
16. mcrypt
17. memcache
18. mysql
19. mysqli
20. pcre
21. PDO
22. pdo_sqlite
23. Phar
24. posix
25. Reflection
26. session
27. SimpleXML
28. SPL
29. SQLite
30. sqlite3
31. standard
32. tokenizer
33. xml
34. xmlreader
35. xmlwriter
36. zlib
37.
38. [Zend Modules]
39. eAccelerator
17 lines, with memcahe, correctly loaded
Follow-up: Basic memcached Configuration
Start the memcached server program:
1. memcached-d-m 10-u root-l localhost-p 11211-c 256-P/tmp/memcached. pid
2. If the error message "Libaraies does not exist or cannot be shared" is returned when the node is running in one step
Execute ldconfig (load Dynamic Link Library)
Before performing the preceding operations, you 'd better execute this step ldconfig-C | grep libevent to see if there is any
Meanings of parameters:
1. The-d option is to start a daemon process,
2.-m indicates the amount of memory allocated to Memcached. The unit is MB,
3.-u is the user running Memcache. Here I am root,
4.-l is the IP address of the listening server,
5.-p is the port for Memcache listening, preferably over 1024,
6. The-c option is the maximum number of concurrent connections. The default value is 1024, which is determined based on the load of your server,
7.-P is the pid file for saving Memcache.
PS: memcached common methods:
1. kill 'cat/tmp/memcached. Pi'
2.
3. Get the running status
4.
5. echo stats | nc 192.168.0.122 11200
6. watch "echo stats | nc 192.168.0.122 11200" (Real-time status)
7.
8. Fast clearing
9.
10. echo "flush_all" | nc 192.168.0.122 11200
11.
12. Other Tools