Centos版本:7.8
Redis版本:5.0
官网下载地址:http://download.redis.io/releases/redis-5.0.0.tar.gz
yum install gcc-c++ cd /opt tar -zxvf redis-5.0.0.tar.gz cd redis-5.0.0/ make make install PREFIX=/opt/redis
mkdir -p /opt/redis/conf cp /opt/redis-5.0.0/redis.conf /opt/redis/conf vi /opt/redis/conf/redis.conf ------------------------------------------------------------ bind 192.168.100.11 port 8080 daemonize yes protected-mode no requirepass 123456 # 设置密码 --------------------------------------------------------------
bin/redis-server conf/redis.conf # 启动redis bin/redis-cli shutdown # 关闭redis ps -ef|grep redis # 查看进程
# 链接redis bin/redis-cli -h 192.168.100.11 -p 8080 -a 123456 192.168.100.11:8080> info
192.168.1.11:8080> set 1001 abc # 设置单个key-value值 192.168.1.11:8080> mset 1002 abc 1003 def # 设置多个key-value值 192.168.1.11:8080> get 1001 # 根据单个key获取value值 192.168.1.11:8080> mget 1001 1002 1003 # 根据多个key获取value值 192.168.1.11:8080> exists 1001 # 检测key是否存在 192.168.1.11:8080> type 1001 # 根据key查看value类型 192.168.1.11:8080> ttl 1001 # 查看key生命周期,-1为永久保存 192.168.1.11:8080> dbsize # 查询key数量 192.168.1.11:8080> set abcd 99 192.168.1.11:8080> keys ab* # 模糊匹配查询key 192.168.1.11:8080> del 1001 # 删除key-value值
原文:https://www.cnblogs.com/linwenhai/p/14619007.html