Redis-7.2 安装指南

1.Redis安装指南

1.1 官网地址

下载地址:Downloads - Redis

中文文档:redis中文文档

Redis在线练习:https://try.redis.io/

参考手册:http://doc.redisfans.com/

1.2 Linux版安装 (redis-7.2)

1.2.1 配置gcc环境

检查有没有gcc:gcc -v

若没有,安装gcc:yum -y install gcc-c++

1.2.2 安装redis

解压压缩包至 /opt 目录下

安装:make && make install

(默认安装目录:usr/local/bin

(出现Hint: It's a good idea to run 'make test' ;),则安装成功)

redis-benchmark:性能测试工具,服务启动后运行该命令
redis-check-aof:修复有问题的AOF文件
redis-check-rdb:修复有问题的rdb文件
redis-cli:客户端,操作入口
redis-sentinel:redis集群使用
redis-server:redis服务器启动命令

1.2.3 配置文件

配置文件在 /opt/redis-7.2/redis.conf

是先拷贝一份默认的conf文件保存着

[root@localhost redis-7.2]# mkdir /myredis
[root@localhost redis-7.2]# cp redis.conf /myredis/redis7.conf

修改 /opt/redis-7.2/redis.conf 配置文件

修改前修改后
daemonize nodaemonize yes
protected-mode yesprotected-mode no
bind 127.0.0.1# bind 127.0.0.1
# requirepass foobaredrequirepass 自定义密码

根据配置文件启动redis服务

redis-server /myredis/redis7.conf

若报错:

WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect.

执行:

echo 1 > /proc/sys/vm/overcommit_memory

然后重新启动redis

1.2.4 连接redis客户端
redis-cli -a 密码 [-p 端口号]

redis-cli
auth 密码

端口号默认为6379

1.2.5 查看Redis版本
redis-server -v
1.2.6 检查
127.0.0.1:6379> ping
PONG

安装配置成功

1.2.7 关闭Redis客户端
quit
1.2.8 关闭Redis服务器

(1)客户端内部退出

SHUTDOWN

(2)客户端外部退出

​ 单实例关闭:

redis-cli -a 密码 shutdown

​ 多实例关闭(指定端口关闭):

redis-cli -p 端口号 shutdown
1.2.9 卸载

停止Redis服务

rm -rfv /usr/local/bin/redis-*

删除 /usr/local/lib 目录下与redis相关的文件

  • 29
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值