memcached server installation, configuration, use of detailed

Source: Internet
Author: User
Tags cas memcached touch command

Manage memcached Services

    • Start memcached

In general, you can start the memcached service simply by using a form similar to the following:

/usr/local/bin/memcached-d-192.168.  1024-p/usr/local/memcached/memcached.pid    

The above command line, based on the above options, as well as the meanings of some other options, is illustrated in the following table:

Options Meaning description
-D Specifies that the memcached process is started as a daemon process
M <num> Specify the amount of memory allocated to memcached, in megabytes
-U <username> Users running the memcached
-L <ip_addr> The server IP address of the listener, if there are multiple addresses, separated by commas, the format can be "IP address: Port number", for example:-L to specify 192.168.0.184:19830,192.168.0.195:13542; Port number can also be specified by the-p option
-P <num> Memcached Listen on the port, to ensure that the port number is not occupied
-C <num> Set the maximum number of concurrent connections to run, default is 1024
-R <num> To avoid client starvation (starvation), set a limit on the number of consecutive client requests to be reached, and if this setting is exceeded, another connection is selected to process the request, which defaults to 20
-K Set the memory to lock all paging, and use this option sparingly for large cache scenarios
-P Save the PID file for the memcached process
-S <file> Specify the UNIX socket file that memcached uses for listening
-A <perms> Set the-S option to specify the permissions of the UNIX socket file
-U <num> Specifies the port on which UDP is listening, by default 11211,0 means shutdown
-M Disables automatic purging of data items in the cache when memory usage exceeds the configured value, at which point memcached is not allowed until memory is freed
-R Set the resulting core file size
-F <factor> Multiplier factor for calculating the memory block size of cached data items, default is 1.25
-N Sets the minimum number of bytes allocated for the key, value, flag of the cached data item, which is 48 by default
-C Disable CAs
-H Display memcached version and summary information
-V Output warnings and error messages
-vv Print information more detailed than-V: not only output warnings and error messages, but also output client request and response information
-I. Print licenses information for libevent and memcached
-T <threads> Specifies the number of threads used to process the request, which defaults to 4
-D <char> The delimiter between the key prefix and the ID in the statistics report, which is the colon ":" By default.
-L Try using large memory paging (pages)
b <proto> Specifies the protocol used, the default behavior is auto-negotiation (autonegotiate), and the options that may be used are auto, ASCII, binary.
-I <size> Overrides the default Stab page size, which is 1M by default
-F Disable the Flush_all command
-O <options> Specify comma-delimited options, typically used for extended or experimental properties
    • Stop memcached

You can query the process number of the memcached by using the following command from Linux:

grep memcached

Then kill the memcached service process:

<pid>

-9 means to force the kill process.

After the memcached is started, the data in the cache can be manipulated by the client, and we describe some common clients and how to use them.

Telnet Client

The Telnet client can use the command line to monitor how the memcached server stores data. For example, Memcached has a service address of 192.168.4.86:11211 and can telnet to the service port:

Telnet 192.168.4.86 11211

If the connection succeeds, you can use some of the following commands:

    • Stats command

This command is used to display server information, statistics, and the resulting sample data (from the Www.2cto.com Web site), for example:

STAT PID22362Process ID of the memcache server www.2cto.com STAT uptime1469315Number of seconds the server has been running stat time1339671194Server current UNIX Timestamp stat version1.4.9Memcache version Stat libevent1.4.9-stableLibevent version Stat Pointer_size64The current operating system pointer size (32-bit system is generally 32bit,64 is a 64-bit operating system) STAT Rusage_user3695.485200Cumulative user time for processes stat Rusage_system14751.273465Cumulative system time for processes stat curr_connections69The number of items currently stored by the server stat total_connections855430The total number of items stored after starting the server stat Connection_structures74Number of connection constructs that are allocated by the server stat Reserved_fds20STAT Cmd_get328806688Get command (GET) total number of requests stat Cmd_set75441133Set command (Save) total number of requests www.2cto.com STAT Cmd_flush34Flush Command Request Count Stat Cmd_touch0Touch Command Request Count Stat get_hits253547177Total Hit count stat get_misses75259511Total number of misses stat delete_misses4Delete command Miss Count stat delete_hits565730Delete command hit count stat incr_misses0incr Command misses stat incr_hits0INCR command hit Count stat decr_misses0DECR Command misses stat decr_hits0DECR command hit Count stat cas_misses0CAS command Miss Count stat cas_hits0CAS command hit count stat cas_badval0Use wipe count stat touch_hits0Touch Command Miss Count Stat touch_misses0Touch command hit Count stat Auth_cmds0Number of authentication command processing stat auth_errors0Number of authentication failures stat Bytes_read545701515844Total bytes read (number of requests bytes) STAT Bytes_written1649639749866Total Bytes sent (bytes of result) STAT Limit_maxbytes2147483648Memory size (bytes) assigned to Memcache STAT Accepting_conns1Whether the server has reached the maximum connectivity (0/1) STAT Listen_disabled_num0Number of failed listeners stat threads4 //current threads stat conn_yields 14 //connection operation active Abort number STAT hash_power_level 16 //stat hash_ Bytes 524288stat hash_is_expanding 0stat expired_unfetched 30705763stat evicted_unfetched 0stat bytes 61380700 //current storage consumption of bytes stat Curr_items 28786 //the total number of data currently stored stat Total_items Span class= "number" >75441133 //total data stored since startup stat evictions 0 //the number of items deleted for free memory (the space allocated to memcache needs to be deleted after the old items are allocated to the new items) STAT reclaimed //expired data entry to store the number of new data end         

The above gives a description of the meaning of each statistic item, no longer to be described. The stats command has several level two subkeys, as illustrated in the following table:

Command Meaning description
Stats Slabs Displays information about each slab, including the size, number, usage, etc. of the chunk
Stats items Displays the number of item in each slab and the age of the oldest item (the number of seconds the last access distance is now)
Stats detail [On|off|dump] Set or display detailed operation record;
The parameter is on to open the detailed operation record;
The parameter is off, close the detailed operation record;
The parameter is dump, showing the detailed operation record (number of times each key value get, set, hit, Del)
Stats malloc Print memory allocation information
Stats sizes Print Cache usage Information
Stats Reset Resetting statistics
    • Get command

Used to get the cached data, key. Usage format:

<key>*\r\n

Examples are shown below:

Get Basis_behavior_user

The result example is as follows:

VALUE Basis_behavior_user0451{"Aadata": [["D1a2233dc382432b8e19e40254fdb98a","100000002223484","1402563046319","C4f82195815300bcf39a5232707ad9c1","1","0","Ebest_w70","4.0.4","2.2.2.","WiFi","","Ebest","19", "854*480", " 863531010517866 ", " c4f82195815300bcf39a5232707ad9c11402562805664 ", " 460010255508963 ", " 1901589461 ", " 1402563045960 ", " 338 ",  "2014-06-12_16:50:46",  "0",  "3"]], "Secho": 1, " Itotalrecords ": 0,0}end  

You can also get the values corresponding to multiple keys, as shown below:

725tenis basketball footballend
    • Set command

Usage format:

<<<<bytes> [noreply]\r\n<value>\r\n   

Example:

7shirdrnSTOREDGet name7shirdrnEND  
    • Delete command

Given key, delete the data from the key in the cache.

    • Add command

Usage format:

<<<<bytes> [noreply]\r\n<value>\r\n   

Example:

10basketballSTORED10basketballEND
    • Replace command

Overwrite an already existing key and its corresponding value, replace must ensure that the replacement value of the length of the original length of the same, or replace fails. Usage format:

<<<<bytes> [noreply]\r\n<value>\r\n   

Example:

Get namevalue name 0 7shirdrnEND7youak47storedget name7youak47END   
    • Append command

Appended to an already existing data value (value), appended after the data value. Usage format:

<<<<bytes> [noreply]\r\n<value>\r\n   

Example:

9footballSTORED19basketball footballend
    • prepend command

Appended to an already existing data value (value), appended before the data value. Usage format:

<<<<bytes> [noreply]\r\n<value>\r\n   

Example:

6tenisSTORED25tenis basketball footballend
    • INCR command

The Count command, which sums up the existing numbers, calculates and stores the new values. Usage format:

<<value> [noreply]\r\n 

Example:

71000000STOREDget active_users710000001000099     
    • DECR command

The Count command, which calculates and stores a new value, is subtracted from the previously existing number. Usage format:

<<value> [noreply]\r\n 

Example:

73456996643 
    • Flush_all command

Invalidates the data items in the cache, and the optional parameters expire after a few seconds. Usage format:

Flush_all [<time>] [noreply]\r\n 
    • Version command

Returns the version information for the memcached server.

    • Quit command

Exit the Telnet terminal.

memcached server installation, configuration, use of detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.