官方教程:https://redis.io/download

  1. cd /usr/src                                                (我要存放的路径)
  2. wget http://download.redis.io/releases/redis-5.0.7.tar.gz (下载)
  3. tar xzf redis-5.0.7.tar.gz (解压)
  4. cd redis-5.0.7 (进入redis路径)
  5. make       (编译)
  6. cd /usr/src/redis-5.0.7      
  7. src/redis-server     /usr/src/redis-5.0.7/redis.conf                       ( 启动redis,指定加载redis配置启动)

 

测试

  1. cd /usr/src/redis-5.0.7          (进入redis 路径)
  2. src/redis-cli                         (启动客户端)
  3. 如下命令 设定值,获取值, 这样说明redis 成功

Linux 搭建 Redis

默认是本地访问的,如果要使用外网访问,以下配置

  1. cd  /usr/src/redis-5.0.7        (进入redis路径)
  2. vim   redis.conf
  3. 注释掉 bind 127.0.0.1               
  4. 修改protected-mode   no     
  5. 6379 端口记得开放起来 (记得测试端口是否有通 )
  6. src/redis-server     /usr/src/redis-5.0.7/redis.conf      (重新启动redis)      

 

注意事项:

为什么明明安装了redis,修改了配置,启动的时候,配置还是不生效。

  1. 不要用 src/redis-server 启动redis   这个 默认会去加载 /path/to/redis.conf   ,  由于你改又不是这个文件,当然没有效果。
  2. 用指定加载reids配置文件启动 : src/redis-server     /usr/src/redis-5.0.7/redis.conf       

 

配置文件说明:

daemonize no  相同于前端运行了,输入其它命令 redis停止服务了

Linux 搭建 Redis

daemonize yes    相同后台运行了 ,输入其它命令 redis 还是在运行的。

Linux 搭建 Redis

 

使用Windows 测试 阿里云服务器 中的redis 端口 是否有通

telnet   ip   端口                         举例:   telnet    192.168.43.110     6379

Linux 搭建 Redis

如果出现如下提示,说明访问不到端口(当然前提是要能ping通你的ip,要是连ip都ping不通的话这步是过不去的)

Linux 搭建 Redis

如果有报此错,请查看 上面的外网配置

-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.
遗失对主机的连接。

 

有反应,直接进入一个什么都没有的界面说明通了

Linux 搭建 Redis

使用 Redis Desktop Manager 进行连接

Linux 搭建 Redis

相关文章:

  • 2021-12-12
  • 2022-02-05
  • 2022-01-08
  • 2021-07-23
  • 2021-10-08
  • 2021-09-09
  • 2022-01-09
猜你喜欢
  • 2021-09-04
  • 2021-08-08
  • 2021-04-26
  • 2021-09-27
  • 2022-01-08
  • 2022-12-23
  • 2022-01-08
相关资源
相似解决方案