Telnet connection Operation Memcache Server detailed _ database other

Source: Internet
Author: User
Tags cas memcached port number

As an excellent out-of-process cache, Memcache is often used in high concurrency system architectures. Here to talk about how to use the Telnet tool to view the Memcache health and its key management maintenance. Suppose memcache installation directory:/usr/local/memcached

1, start memcache

Copy Code code as follows:

[Root@localhost ~]#/usr/local/memcached/bin/memcached-d-M 512-u root-l 192.168.119.70-p 12000-c 512-p/usr/local/ Memcached/memcached.pid

Start parameter detailed
-D: Start as daemon. If this parameter is not specified, the memcache automatically closes when the CTRL + C command ends
-M: The maximum amount of memory allocated to Memcache is M., the default is 64m
-U: Specifies the user who is running Memcache
-L: Specifies the IP address of the listener
-P: Specifies the TCP port number on which to listen, and you can specify the UDP port by-U. Default is 11211
-C: Maximum number of concurrent connections
-P: File with error process ID
Once the memcache is started, we can use Telnet to connect memcache and manage it simply.

2, Telnet connection memcache

Copy Code code as follows:

[root@localhost ~]# telnet 192.168.119.70 12000
Trying 192.168.119.70 ...
Connected to 192.168.119.70 (192.168.119.70).
Escape character is ' ^] '.

After the connection is successful, the memcache can be managed and the commonly used commands are:

Ⅰ, adding modifications

Command format:<command> <key> <flags> <exptime> <bytes>\r\n<data block>\r\n

<command>:add, set or replace

<key>: Cached Name

A <flag>:16-bit unsigned integer that is stored with the data that the key stores and returns when the program get cache.

<exptime>: Past time, 0 means never expire, if Non-zero, indicates Unix time or the number of seconds from

<bytes>: Number of bytes storing data

\ r \ n: Indicates a newline carriage return

Command result:

STORED: it means success.

Not_stored: Indicates failure

a), adding caching

Copy Code code as follows:

Add ID 1 0 4
1234
STORED

If the key already exists, the failure is added.

b), modify the cache

Copy Code code as follows:

Replace ID 1 0 4
3456
STORED

When key exists, it succeeds or fails when it does not exist.

c), setting the cache

Copy Code code as follows:

Set ID 1 0 4
2345
STORED

Adds "Add" when key does not exist, replaces "replace" when it already exists.

Ⅱ, Reading

Command format: Get <key>+\r\n

<key>+: denotes one or more key, multiple keys, separated by a space

A), reading the cache of a single key

Copy Code code as follows:

Get ID
VALUE ID 1 4
1234
End

b), reading the cache of multiple key

Copy Code code as follows:

Get ID Name
VALUE ID 1 4
3456
VALUE Name 1 3
Jim
End

Ⅲ, deleting

Command format: delete <key> \ r \ n

<key>: Key to delete

Delete ID

Copy Code code as follows:

Delete ID
DELETED

Ⅳ, empty all caches

Command format: Flush_all

Copy Code code as follows:

Flush_all
Ok

Ⅴ, viewing cache server Status

Command: Stats

Copy Code code as follows:

Stats
STAT PID 2711//Process ID
STAT uptime 2453//Total run time, Unit description
STAT time 1344856333//current times
STAT version 1.4.0//Edition
STAT pointer_size 32//server pointer number, general 32-bit operating system is 32
STAT Rusage_user 0.002999//cumulative user time for the process
STAT Rusage_system 1.277805//Cumulative system events for processes
STAT curr_connections 1//Current number of connections
STAT total_connections 11//The total number of connections after server startup
STAT connection_structures 11//Number of connection structures
STAT cmd_get 17//Total acquisition times
STAT Cmd_set 1//Total write times
STAT Cmd_flush 1//Total purge times
STAT get_hits 1//Total hit count
STAT get_misses 7//Get No hit count
STAT delete_misses//Delete no hit count
STAT delete_hits 4//delete hit count
STAT incr_misses//increment operation has no hit count
STAT incr_hits//increment operation hit count
Number of STAT decr_misses//decrement operations not hit
Number of STAT decr_hits//decrement operations hit
STAT cas_misses//cas Set no hit count
STAT cas_hits//cas Hit count
STAT cas_badval//cas operation found key, but version expired, no success was set
STAT Bytes_read 455//Total amount of data obtained
STAT Bytes_written 1175///Total amount of data written
STAT limit_maxbytes 1048576//maximum allowable use of memory, unit byte
STAT Accepting_conns 1
STAT Listen_disabled_num 0
STAT Threads 5//When the number of frontline
STAT Conn_yields 0
STAT bytes 56//Used cache space
STAT Curr_items 1//Current cached KeyValue number
STAT Total_items 7//Total number of cached keyvalue, including expired deleted
STAT Evictions//Free memory number by removing keyvalue
End

Ⅵ, print version

Command: Version

Copy Code code as follows:

Version
VERSION 1.4.0

Ⅶ, print memory information

Command: Stats Slabs

Copy Code code as follows:

Stats Slabs
STAT 1:chunk_size 80
STAT 1:chunks_per_page 13107
STAT 1:total_pages 1
STAT 1:total_chunks 13107
STAT 1:used_chunks 1
STAT 1:free_chunks 1
STAT 1:free_chunks_end 13105
STAT 1:get_hits 10
STAT 1:cmd_set 10
STAT 1:delete_hits 4
STAT 1:incr_hits 0
STAT 1:decr_hits 0
STAT 1:cas_hits 0
STAT 1:cas_badval 0
STAT Active_slabs 1
STAT total_malloced 1048560
End

3. Exit Telnet

Copy Code code as follows:

Quit

Finish!

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.