利用shell命令操作Memcached

2021-09-01 08:14:09 字數 1523 閱讀 8036

首先,需要了解memcached協議,如果不清楚可參考《memcached 協議中英文對照 》。

1、資料儲存(假設key為zhangyan,value為12345)

printf "set zhangyan 0 0 5\r\n12345\r\n" | nc 127.0.0.1 11211

stored

2、資料取回(假設key為zhangyan)

printf "get zhangyan\r\n" | nc 127.0.0.1 11211

value zhangyan 0 5

12345

end3、數值增加1(假設key為zhangyan,並且value為正整數)

printf "incr zhangyan 1\r\n" | nc 127.0.0.1 11211

12346

4、數值減少3(假設key為zhangyan,並且value為正整數)

printf "decr zhangyan 3\r\n" | nc 127.0.0.1 11211

12343

5、資料刪除(假設key為zhangyan)

printf "delete zhangyan\r\n" | nc 127.0.0.1 11211

deleted

6、檢視memcached狀態

printf "stats\r\n" | nc 127.0.0.1 11211

stat pid 3025

stat uptime 4120500

stat time 1228021767

stat version 1.2.6

stat pointer_size 32

stat rusage_user 433.463103

stat rusage_system 1224.515845

stat curr_items 1132460

stat total_items 8980260

stat bytes 1895325386

stat curr_connections 252

stat total_connections 547850

stat connection_structures 1189

stat cmd_get 13619685

stat cmd_set 8980260

stat get_hits 6851607

stat get_misses 6768078

stat evictions 0

stat bytes_read 160396238246

stat bytes_written 260080686529

stat limit_maxbytes 2147483648

stat threads 1

end7、模擬top命令,檢視memcached狀態:

watch "printf 'stats\r\n' | nc 127.0.0.1 11211"

或者watch "echo stats | nc 127.0.0.1 11211"

常用shell命令操作

1.判斷2個目錄同時存在再執行shell命令 bin bash testpath volume01 edit high testpath1 volume01 bak edit high if d testpath d testpath1 then echo ok rsync a delete vol...

利用Shell命令獲取IP位址

一 獲取單個網絡卡的ipv4位址,方法如下 方法一 sbin ifconfig ethx awk inet addr cut f2 d 方法二 sbin ifconfig ethx awk inet addr awk f 方法三 sbin ifconfig ethx sed ne s addr di...

shell常用操作命令系列 軟體操作命令

rpm常用操作 rpm ivh lynx rpm安裝 rpm e lynx 解除安裝包 rpm e lynx nodeps 強制解除安裝 rpm qa 檢視所有安裝的rpm包 rpm qa grep lynx 查詢包是否安裝 rpm ql 軟體包路徑 rpm uvh 公升級包 rpm test ly...