安装Memcached
安装必要memcached libmemcached libevent
yum install -y memcached libmemcached libevent
开启memcached服务
systemctl start memcached
查看Memcached运行状态
# memcached-tool 127.0.0.1:11211 stats
或者echo stats |nc 127.0.0.1 11211 需要安装nc工具 yum install -y nc
若安装libmemcached后,可以使用命令
memstat --servers=127.0.0.1:11211 查看memcached服务状态
Memcached命令行
# yum install -y telnet
# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set key2 0 30 2
ab
STORED
get key2
VALUE key2 0 2
ab
END
Memcached数据示例
# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set key3 1 100 4
abcd
STORED
get key3
VALUE key3 1 4
abcd
END
replace key3 1 200 5
abcdx
STORED
get key3
VALUE key3 1 5
abcdx
END
delete key3
DELETED
get key3
END
Memcached数据导出和导入
导出:
# memcached-tool 127.0.0.1:11211 dump > data.txt
Dumping memcache contents
Number of buckets: 0
Number of items :
导入:
nc 127.0.0.1 11211 < data.txt
注:若nc命令不存在,yum install nc
|