Note, after the actual production of the BO main environment test, found that stand-alone memcached is not easy to use.
Memcached is a high-performance distributed memory object caching system. It reduces the number of read databases by caching data and objects in memory, thereby increasing the speed of dynamic, database-driven Web sites.
Recently advocated Meng also to their own Aliyun server installed Memcached, the effect seems to be good oh.
Test environment: Aliyun CentOS 6.5 64-bit, military elder brother's Lnmp one-click installation package configuration Environment 1.2. Install Memcached
lnmp1.2: Into the LNMP after the unpacked directory, the implementation:./addons.sh Install memcached (This is the military brother Lnmp built-in installation script, other configuration of their own environment, Google installation method it)
You can choose Php-memcache or php-memcached expansion according to your own needs, Discuz X is the former, the function is more powerful php-memcached. If you want to use the WordPress plugin below, please select Php-memcache (i.e. 1), otherwise there will be a problem
Enter the corresponding ordinal number, return, confirm the carriage return to start the installation.
After installation, you can enable it normally. WordPress Open Memcached Cache
WordPress Memcached plugin Download, after decompression, will object-cache.php upload to the wp-content directory (not wp-content/plugins/), so WordPress will automatically check in the Wp-content Whether there are object-cache.php files in the directory, if any, call it directly as a WordPress object caching mechanism.
Note: If you have more than one WordPress server installed, please ensure that each WordPress site uses a different database prefix, if the prefix, such as all wp_, it is likely to cause conflicts, because each site's data are cached through memory, the prefix will be the same fight.
For your WordPress site to open the memcached cache, there is no need to install DB cache Reloaded Fix This kind of database caching plug-ins. View Memcached Cache conditions
We need to use the Telnet command to see if the Telnet package is installed first
If it is installed, it will return the relevant version
Telnet-0.17-41.el5
Telnet-server-0.17-41.el5
If it is not installed, run the following command and note that it is installed under root
1
2
3
|
Yum install xinetd
yum install telnet
yum install Telnet-server |
Special Note: Telnet service relies on the XINETD service to start, so install xinetd service first. So we have to install XINETD first, then install Telnet-server.
Then link to telnet service
If the link succeeds, it returns:
Trying 127.0.0.1 ...
Connected to 127.0.0.1.
Escape character is ' ^] '.
And then enter
Enter, you can see the cache condition of the Memcached
ID of the STAT PID 20439--memcached process
STAT uptime 179982--Process run time
STAT Time 1382361665--Current
STAT version 1.4.15--memcached
STAT libevent 1.4.13-stable
STAT Pointer_size 32
STAT Rusage_user 21.916668
STAT Rusage_system 40.576831
STAT curr_connections 11
STAT total_connections 329
STAT Connection_structures 23
STAT Reserved_fds 20
STAT Cmd_get 2363348--The total number of times the data was fetched (equal to Get_hits + get_misses)
STAT cmd_set 279971--Number of data sets in total
STAT Cmd_flush 0
STAT Cmd_touch 0
How many times STAT get_hits 2286284--hit, that is, the number of successful data fetches from the Memcached cache
STAT get_misses 77064--number of missed hits
STAT delete_misses 30803
STAT delete_hits 48876
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 574591015
STAT Bytes_written 4353057466
STAT limit_maxbytes 67108864--Total storage size, default 64M
STAT Accepting_conns 1
STAT Listen_disabled_num 0
STAT Threads 4
STAT Conn_yields 0
STAT Hash_power_level 16
STAT hash_bytes 262144
STAT hash_is_expanding 0
STAT bytes 4717345--currently used storage size
STAT Curr_items 5654
STAT Total_items 58461
STAT expired_unfetched 17
STAT evicted_unfetched 0
STAT Evictions 0
STAT reclaimed 49
End
The above data hit ratio: 2286284/2363348 = 96.7% indicates that the current hit rate is relatively high.
If you want to empty the existing data, you can use the following command:
To exit Telnet, enter the key combination CTRL +] appears
Telnet>
Enter quit to exit.
1. Close memcached
You can use the Kill process ID directly, for example, the above information shows the process ID of 20439, then use kill 20439
2. Reboot the memcached and modify the parameters such as memory, as follows (modify the maximum memory is 1024M, the maximum number of connections is 4000):
1
|
Memcached-d-M 1024-u root-l 127.0.0.1-p 11211-c 4000-p/tmp/memcached.pid 11211 |
Some of the more detailed parameters are described below:
-P Listening Port
The IP address of the-l connection, the default is native
-D Start memcached service
-D Restart Restart memcached service
-D Stop|shutdown shut down the running memcached service
-D Install installation memcached service
-d Uninstall Uninstall memcached service
-U Run as (only valid when run as root)
-m maximum memory usage, in MB. Default 64MB
-Returns an error when M memory is exhausted instead of deleting the item
-C Maximum Simultaneous connection number, default is 1024
-F Block size growth factor, default is 1.25
-N Minimum allocation space, key+value+flags default is 48
-H Display Help