1. redis 4.0.9 setup & jedis example

1.Centos 安装redis

    cd 

    mkdir redis

    cd redis

    wget  --no-check-certificate  https://github.com/antirez/redis/archive/4.0.9.tar.gz    

    tar xzf 4.0.9.tar.gz    

    cd redis-4.0.9/    

    make    

    cd src && make all    

    redis-server    
1.因为无法连接http://redis.io 所以此处使用github来下载redis压缩包;
2.操作中遇到无法验证证书问题,所以采用    --no-check-certificate
3.执行redis-server启动时有一个警告

# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
意思是:
解决方法是 修改配置文件 redis.conf:
tcp-backlog 511
然后 修改 etc/sysctl.conf
添加 net.core.somaxconn= 1024 然后执行 sysctl -p 就可以永久消除这个warning
4.如果需要从别的ip进行调试,启动redis需要执行 redis-server --protected-mode no

2.使用java连接redis

    package com.jedis;

    import redis.clients.jedis.Jedis;

    public class JedisUtil {

    public static void main(String[] args) {

        Jedis jedis = new Jedis("redis://192.168.1.104:6379");

        jedis.set("foo", "bar");

        String value = jedis.get("foo");

        System.out.println(value);

    }

}
    java连接会出现 exceptions.JedisDataException 这样的异常;
    可以采用下面方法解决
                //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.

转载于:https://www.cnblogs.com/drduan/articles/9029232.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值