下载 官网 下载
下载地址:redis-5.0.8.tar.gz
安装 安装gcc依赖
解压安装 1 2 3 4 5 tar -zxvf redis-5.0.8.tar.gz cd redis-5.0.8 cd src make distclean # make distclean清除之前生成的文件(可选) make && make install
修改配置文件 编辑 redis.conf
:
1 vim /ldjc/rj/redis-5.0.8/redis.conf
进入vim 输入 /
再按 回车用来搜索关键字
比如如下命令会定位到文件中出现 bind 的位置并会将关键词用颜色区分。
/bind
搜索 daemonize no
改为 daemonize yes
搜索 requirepass password
添加 requirepass 设置的密码
requirepass password
搜索 bind 127.0.0.1
然后使用 #
注释掉
启动 命令:
1 2 3 4 5 6 7 cd /ldjc/rj/redis-5.0.8/usr/local/bin/redis-server /ldjc/rj/redis-5.0.8/redis.conf /usr/local/bin/redis-cli
示例:
1 2 3 4 5 6 7 8 9 10 11 12 [root@host-192-125-30-11 redis-5.0.8 ]# /usr/local/bin/redis-server /ldjc/rj/redis-5.0.8/redis.conf 15531 :C 12 May 2020 16 :07 :35.523 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 15531 :C 12 May 2020 16 :07 :35.523 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=15531, just started 15531 :C 12 May 2020 16 :07 :35.523 # Configuration loaded [root@host-192-125-30-11 redis-5.0.8 ]# /usr/local/bin/redis-cli 127.0 .0 .1 :6379 > keys *(error) NOAUTH Authentication required. 127.0 .0 .1 :6379 > auth rootOK 127.0 .0 .1 :6379 > keys *(empty list or set ) 127.0 .0 .1 :6379 >
开放端口 注意:针对各种云,因为有专门策略,所以不需要操作防火墙;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 firewall-cmd --zone=public --add-port=6379/tcp --permanent firewall-cmd --reload firewall-cmd --query-port=6379/tcp netstat -lnpt firewall-cmd --zone=public --remove-port=6379/tcp --permanent firewall-cmd --zone=public --list-ports
查找redis ps aux | grep redis
关闭Redis服务 1 2 3 4 5 6 7 [root@localhost bin]# pkill redis-server [root@localhost bin]# netstat -tunpl | grep 6379 [root@localhost bin]# pstree -p | grep redis [root@localhost bin]# /usr/local/bin/redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused Could not connect to Redis at 127.0.0.1:6379: Connection refused not connected>