Linux 搭建 Redis

 

官方教程: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 成功

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

  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停止服务了

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 进行连接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值