zoukankan      html  css  js  c++  java
  • redis 入门

    (一)安装

    redis官方下载安装链接:https://redis.io/download

    按照官网的来总流程上是没问题的。不过我本地还是有点小问题。

    1、到你想安装的目录

    $ wget http://download.redis.io/releases/redis-3.2.8.tar.gz
    $ tar xzf redis-3.2.8.tar.gz
    $ cd redis-3.2.8
    $ make

    我的本地到make这就不行了,开始报错:提示缺少cc

    $ yum -y install gcc

    继续make,此时还是报错

    $ make CFLAGS="-march=x86-64"

    再make,就ok了。

    下面按官网的启动服务

    $ src/redis-server

    (二)java通过Jedis来操作

    这里说下我的环境:测试java连接是在我windows本地,redis装在我的虚拟机上

    package test.com.redis;
    
    import redis.clients.jedis.Jedis;
    
    public class RedisDemo {
    
        public static void main(String[] args) {
            Jedis jedis = new Jedis("10.99.8.166",6379);
    //        Jedis jedis = new Jedis("10.99.8.166");
    //        jedis.auth("admin");
            jedis.set("name", "vincent");
            System.out.println(jedis.get("name"));
        }
    }

    此处运行将会报错,错误是这样的:

    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.

    我采用的是第二种解决方式。

    1)setting the protected mode option to 'no' 和注掉本地绑定

     重新启动
    ./redis-server ../redis.conf

    此时再运行main方法就会输出了。

    (三)图形化界面

    下载地址:http://pan.baidu.com/s/1b7ewk2 密码:jk5a

    以上是我今天的学习总结。

  • 相关阅读:
    移动端的文本框获取焦点时导致fixed或absolute定位的按钮被手机键盘顶上去的问题
    移动端css适配
    【两种方式】vuex 如何监听页面状态的变化
    VUE中使用lib-flexible和 px2rem-loader
    在vue移动端使用lib-flexible和px2remLoader适配屏幕
    两步创建vue全局组件
    《心淡》钢伴
    原生JS代码封装(显示、隐藏)
    原生JS代码封装(添加cookie,获取cookie)
    原生JS代码封装(输入id名、class名、标签名 返回 "object HTMLDivElement")
  • 原文地址:https://www.cnblogs.com/vincentren/p/6628190.html
Copyright © 2011-2022 走看看