zoukankan      html  css  js  c++  java
  • Redis设置远程连接

    转载:https://www.cnblogs.com/liuxiutianxia/p/11057120.html

    1、修改redis服务器的配置文件

      本机安装的redis-4.0.14默认的配置文件 redis.conf 设置

      绑定本机地址:bind 127.0.0.1

      开启保护模式:protected-mode yes

      此时连接,服务器是拒绝的

         

    1
    2
    3
    4
    [root@fjgh redis]# ./redis-cli -h 192.168.100.109  -p  6379
    Could not connect to Redis at 192.168.100.109:6379: Connection refused
    Could not connect to Redis at 192.168.100.109:6379: Connection refused
    not connected> eixt

      

            配置文件比较大,我们通过ctrl + F  查找关键字修改为:

      bind 0.0.0.0 

      protected-mode no

    2、重启redis服务:先通过kill -9 杀死现有redis进程在启动redis服务

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [root@fjgh redis]# ps -ef|grep redis
    root     10768     1  0 Jun19 ?        00:01:37 ./redis-server 127.0.0.1:6379
    root     11339 11251  0 10:05 pts/1    00:00:00 grep --color=auto redis
    [root@fjgh redis]# kill -9 10768
    [root@fjgh redis]# ps -ef|grep redis
    root     11343 11251  0 10:05 pts/1    00:00:00 grep --color=auto redis
    [root@fjgh redis]# ./redis-server redis.conf
    11344:C 20 Jun 10:05:46.798 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    11344:C 20 Jun 10:05:46.798 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11344, just started
    11344:C 20 Jun 10:05:46.798 # Configuration loaded

      

    3、通过IP地址连接

    1
    2
    3
    4
    [root@fjgh redis]# ./redis-cli -h 192.168.100.109  -p  6379
    192.168.100.109:6379> get setUpTime
    "201906191227"
    192.168.100.109:6379>
  • 相关阅读:
    Discrete Logging
    P1378 油滴扩展
    P3390 【模板】矩阵快速幂
    RMQ算法
    P1372 又是毕业季I
    P1440 求m区间内的最小值
    高效判断素数方法
    阿尔贝喝我
    浙江大学PAT上机题解析之2-11. 两个有序链表序列的合并
    顺序队列之C++实现
  • 原文地址:https://www.cnblogs.com/ershoushouji/p/15210405.html
Copyright © 2011-2022 走看看