Redis学习(一)Redis安装配置(单机)

安装redis(单机)
  1. linux系统 wget命令 下载资源,可以参考官网https://redis.io/download#installation
  2. 窗口命令
    Installation
    Download, extract and compile Redis with:
    --安装
    $ wget https://download.redis.io/releases/redis-6.0.8.tar.gz
    $ tar xzf redis-6.0.8.tar.gz
    $ cd redis-6.0.8
    $ make
    The binaries that are now compiled are available in the src directory. Run Redis with:
    --启动服务端(非diamond,可以新开窗口)
    $ src/redis-server
    You can interact with Redis using the built-in client:
    --启动客户端
    $ src/redis-cli
    redis> set foo bar
    OK
    redis> get foo
    "bar"
    
  3. 上述操作make时出现【server.c:5251:168: error: ‘struct redisServer’ has no member named ‘sentinel_mode’】,gcc版本不一致。执行下面代码后,重新安装 参考相关博客
    yum -y install gcc gcc-c++ make tcl
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    scl enable devtoolset-9 bash
    
  4. 上述src/redis-server中,如果操作习惯,你已经cd到src里了,可以使用./redis-server开启。ctrl+c立即关闭
  5. 后台启动:
    修改redis.config中,把daemonize设置为yes。
    如果要加载配置文件启动 ./redis-server …/redis.config
  6. 如果无法连接到redis服务器:
    ps -ef|grep redis
    root      270377       1  0 11:21 ?        00:00:00 ./src/redis-server 127.0.0.1:6379
    
    这里显示的是127.0.0.1:6379
    bind 127.0.0.1
    这里的意思就是说这台机器上的redis只能通过本机访问,要想在其他电脑通过./redis-cli来访问或者通过java程序来访问,是不允许的
    为了安全考虑,可以在127.0.0.1后加空格再添加指定的服务器地址
    bind 127.0.0.1 139.196.194.xxx
    不考虑安全问题也可以注释掉此行,或者改为bind 0.0.0.0
    windows可以通过telnet 139.196.194.xxx 6379
  7. redis增加密码(redis.conf中)
    requirepass 123456
    登录时比原来多一步:先输入./redis-cli ,再 输入 auth  密码
    
  8. 如果是自己调试可以简单改为以下配置,可以避免很多问题
# 将`daemonize`由`no`改为`yes`
daemonize yes
# 默认绑定的是回环地址,默认不能被其他机器访问
# bind 127.0.0.1
# 是否开启保护模式,由yes该为no
protected-mode no
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值