服务器连接redis的一些配置

  1. redis使用后端模式启动
    修改redis.conf配置文件, daemonize yes
  2. 服务器A无法连接服务器B中的redis
    修改两处:
    修改redis.conf配置文件, 只留一个bind 0.0.0.0 ,其他bind全部注释。意思是运行其他ip访问
    protected-mode yes 修改为no ps:该配置表示是否开启保护模式,如果为yes,则该redis只允许本地发起连接
  3. redis后端启动后如何关闭:redis-cli shutdown
  4. 开机启动配置(有待验证)
    echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local
  5. 设置密码
    修改redis.conf文件配置,快速查找到 # requirepass foobared 然后去掉注释,这个foobared改为自己的密码。然后wq保存。
  6. 执行以下命令查看redis是否启动成功

参考:https://www.cnblogs.com/bestmystery/p/6371229.html
https://blog.csdn.net/qq_37117582/article/details/111067019

你可能感兴趣的:(服务器连接redis的一些配置)