官方教程:https://redis.io/download
- cd /usr/src (我要存放的路径)
- wget http://download.redis.io/releases/redis-5.0.7.tar.gz (下载)
- tar xzf redis-5.0.7.tar.gz (解压)
- cd redis-5.0.7 (进入redis路径)
- make (编译)
- cd /usr/src/redis-5.0.7
- src/redis-server /usr/src/redis-5.0.7/redis.conf ( 启动redis,指定加载redis配置启动)
测试
- cd /usr/src/redis-5.0.7 (进入redis 路径)
- src/redis-cli (启动客户端)
- 如下命令 设定值,获取值, 这样说明redis 成功
默认是本地访问的,如果要使用外网访问,以下配置
- cd /usr/src/redis-5.0.7 (进入redis路径)
- vim redis.conf
- 注释掉 bind 127.0.0.1
- 修改protected-mode no
- 6379 端口记得开放起来 (记得测试端口是否有通 )
- src/redis-server /usr/src/redis-5.0.7/redis.conf (重新启动redis)
注意事项:
为什么明明安装了redis,修改了配置,启动的时候,配置还是不生效。
- 不要用 src/redis-server 启动redis 这个 默认会去加载 /path/to/redis.conf , 由于你改又不是这个文件,当然没有效果。
- 用指定加载reids配置文件启动 : src/redis-server /usr/src/redis-5.0.7/redis.conf
配置文件说明:
daemonize no 相同于前端运行了,输入其它命令 redis停止服务了
daemonize yes 相同后台运行了 ,输入其它命令 redis 还是在运行的。
使用Windows 测试 阿里云服务器 中的redis 端口 是否有通
telnet ip 端口 举例: telnet 192.168.43.110 6379
如果出现如下提示,说明访问不到端口(当然前提是要能ping通你的ip,要是连ip都ping不通的话这步是过不去的)
如果有报此错,请查看 上面的外网配置
-DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
遗失对主机的连接。
有反应,直接进入一个什么都没有的界面说明通了
使用 Redis Desktop Manager 进行连接