NoSQL——Redis初相见

初见Redis

无意中看到一篇博文讲Spark+Redis结合后,查询效率比spark缓存的速度快了45倍【不是45%】,再加上之前跟对面组做运维的交流的时候,知道他们也在使用Redis,好奇心之下,看完blog后,去官网下载了最新版的redis-3.0.7。没想到的是,这神奇的小编原来只有1.5M,更加对其有好奇心了。


安装手顺

很简单,用过linux系统的,应该觉得这是最简单的安装。

事前准备

  1. 确认你的虚拟机是否已安装了gcc。笔者第一次安装的时候,就出问题了,查看了控制台上的message信息后,发信该虚拟机没有安装gcc,瞬间石化了。
  2. 下载物件。直接去官网,很方便。github上托管的源码:https://github.com/antirez/redis-doc

安装

  1. 解压物件。
    tar -zxf redis-3.0.7.tar.gz
  2. 编译redis源码
    cd redis-3.0.7
    make
  3. 以demon形式启动服务端
    src/redis-server
  4. 当你看到如下所示的东西时,证明启动成功
    [root@sv004 redis-3.0.7]# src/redis-server    
    5478:C 31 Mar 23:21:27.448 # Warning: no config file specified,using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
                    _._                                                  
               _.-``__ ''-._                                             
          _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
      .-`` .-```.  ```\/    _.,_ ''-._                                   
     (    ',.-`  | `,)     Running in standalone mode
     |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
     |    `-._   `._    /     _.-'    |     PID: 5478
      `-._    `-._  `-./  _.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |           http://redis.io        
      `-._    `-._`-.__.-'_.-'    _.-'                                   
     |`-._`-._    `-.__.-'    _.-'_.-'|                                  
     |    `-._`-._        _.-'_.-'    |                                  
      `-._    `-._`-.__.-'_.-'    _.-'                                   
          `-._    `-.__.-'    _.-'                                       
              `-._        _.-'                                           
                  `-.__.-'                                               
    
    5478:M 31 Mar 23:21:27.450 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    5478:M 31 Mar 23:21:27.450 # Server started,Redis version 3.0.7
    5478:M 31 Mar 23:21:27.450 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
    5478:M 31 Mar 23:21:27.450 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
    5478:M 31 Mar 23:21:27.450 * The server is now ready to accept connections on port 6379
     
                                                                  5478:M 31 Mar 23:36:03.254 * DB saved on disk
    5478:M 01 Apr 00:36:04.033 * 1 changes in 3600 seconds. Saving...
    5478:M 01 Apr 00:36:04.034 * Background saving started by pid 5750
    5750:C 01 Apr 00:36:04.043 * DB saved on disk
    5750:C 01 Apr 00:36:04.044 * RDB: 6 MB of memory used by copy-on-write
    5478:M 01 Apr 00:36:04.134 * Background saving terminated with success
    
  5. 启动cli
    src/redis-cli

    这会,你就可以命令行的形式,使用redis了。

PS:为了更易区分,可以优化一下文件分布。创建bin目录来存储执行文件

mkdir bin
cp -p redis-server bin/
cp -p redis-cli bin/

相关文章

文章浏览阅读752次。关系型数据库关系型数据库是一个结构化的...
文章浏览阅读687次,点赞2次,收藏5次。商城系统中,抢购和秒...
文章浏览阅读1.4k次。MongoTemplate开发spring-data-mongodb...
文章浏览阅读887次,点赞10次,收藏19次。1.背景介绍1. 背景...
文章浏览阅读819次。MongoDB连接失败记录_edentialmechanisn...
文章浏览阅读470次。mongodb抽取数据到ES,使用ELK内部插件无...