zoukankan      html  css  js  c++  java
  • Redis(一)—— Redis安装

    mysql与redis的区别

    mysql将数据储存在磁盘中,而redis运行时数据存在内存中,redis也支持数据持久化。

    1、下载安装包、解压、安装

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

    2、异常问题解决

    (1)cc未找到

    /bin/sh: cc: command not found
    make[1]: *** [adlist.o] Error 127
    make[1]: Leaving directory `/root/linux/redis-2.8.3/src'
    make: *** [all] Error 2
    [root@VM_0_5_centos redis-2.8.3]# ls
    00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README  redis.conf  runtest  sentinel.conf  src  tests  utils
    [root@VM_0_5_centos redis-2.8.3]# make install
    cd src && make install
    make[1]: Entering directory `/root/linux/redis-2.8.3/src'
        CC adlist.o
    /bin/sh: cc: command not found
    make[1]: *** [adlist.o] Error 127
    make[1]: Leaving directory `/root/linux/redis-2.8.3/src'
    make: *** [install] Error 2
    
    

    解决方法,安装gcc

    yum install gcc
    

    (2)adlist.o 错误

    cd src && make all
    make[1]: Entering directory `/root/linux/redis-3.0.1/src'
        CC adlist.o
    In file included from adlist.c:34:0:
    zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
     #include <jemalloc/jemalloc.h>
                                   ^
    compilation terminated.
    make[1]: *** [adlist.o] Error 1
    make[1]: Leaving directory `/root/linux/redis-3.0.1/src'
    make: *** [all] Error 2
    
    

    解决方法,修改配置

    编辑src/.make-settings里的OPT,将OPT改为OPT=-O2 -march=x86-64
    (3)编译 redis 报错 error: jemalloc/jemalloc.h: No such file or directory

    zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
    zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
    
    

    原因是jemalloc重载了Linux下的ANSI C的malloc和free函数。解决办法:make时添加参数。

    make MALLOC=libc
    

    (4) You need tcl 8.5 or newer in order to run the Redis test

    
    yum install tcl
    
    

    3、启动服务

    
    ./redis-server ../redis.conf &
    
    

    检查端口是否在监听,在监听说明启动成功

    netstat -lntp | grep 6379
    
    

    4、设置密码

    将redis.conf中的#requirepass foobared去掉注释,foobared改为自己的密码

    5、客户端连接

    如果设置了密码,直接连接会报无权限的错误,需要在连接时输入密码

    $ ./redis-cli -h 127.0.0.1 -p 6379 -a foobared
    
    

    6、出现权限拒绝时

    验证密码即可 :输入命令auth "密码"

    127.0.0.1:6379> auth "xiaoxigua"
    OK
    
  • 相关阅读:
    JAVA调用WCF
    写代码之前要做什么?
    漫谈界面和数据
    UIButton 简易的UI
    数据结构利器之私房STL(中)
    有趣的位运算
    基于TCP的C/S初级网络编程1
    数据结构利器之私房STL(上)
    Unix/Linux 那些系统启动后的进程
    【字符串匹配】KMP算法之道
  • 原文地址:https://www.cnblogs.com/gloria-liu/p/8613119.html
Copyright © 2011-2022 走看看