• CentOS 安装Redis


    Redis简介:

    Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。

    redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都 支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排 序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文 件,并且在此基础上实现了master-slave(主从)同步。

    安装环境:

    CentOS 6.5

    Redis 2.8.13

    下载安装:

    下载文件到 /opt/ 目录下

    wget http://download.redis.io/releases/redis-2.8.13.tar.gz

    解压文件

    tar zxvf redis-2.8.13.tar.gz

    切换目录到 redis-2.8.13 目录下

    cd redis-2.8.13

    执行make命令,最后几行的输出结果

    Hint: To run 'make test' is a good idea ;)
    make[1]: Leaving directory `/opt/redis-2.8.13/src'

    执行安装命令

    make install

    提示:

    1. cd src && make install  
    2. make[1]: Entering directory `/opt/redis-2.8.13/src'  
    3.   
    4. Hint: To run 'make test' is a good idea ;)  
    5.   
    6.     INSTALL install  
    7.     INSTALL install  
    8.     INSTALL install  
    9.     INSTALL install  
    10.     INSTALL install  
    11. make[1]: Leaving directory `/opt/redis-2.8.13/src'  

     根据提示,执行:cd src && make install
    提示:

    1. Hint: To run 'make test' is a good idea ;)  
    2.   
    3.     INSTALL install  
    4.     INSTALL install  
    5.     INSTALL install  
    6.     INSTALL install  
    7.     INSTALL instal  

    按照提示执行:make test

    提示:

    1. You need tcl 8.5 or newer in order to run the Redis test  
    2. make: *** [test] Error 1  

    解决方法参考:http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html

    也可以使用:yum install tcl 命令安装

    后来经搜索发现不需要安装,直接到src目录下执行 ./redis-server 就可以


    可以使用类似 ./redis-server /path/to/redis.conf 命令指定配置文件;

    Server started, Redis version 2.8.13
    The server is now ready to accept connections on port 6379

    服务启动成功,服务已经在6379端口上监听连接请求。

    你可以使用内置的客户端连接Redis:http://www.redis.cn/download.html

    1. $ src/redis-cli  
    2. redis> set foo bar  
    3. OK  
    4. redis> get foo  
    5. "bar"  

    注意事项:

    要远程访问它,还需要开启防火墙端口,
    要保持服务的运行可以直接关闭终端窗口,但不要使用Ctrl+C,这样会使程序退出。
    转自:http://blog.csdn.net/testcs_dn/article/details/39756477
    ==================================================================
    在学习RHP SessionRedis时,发现根本没有装Redis。

    立马搜索安装教程,转snowolf 的http://snowolf.iteye.com/blog/1630697

    1、下载和解压

    wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
    tar zxvf redis-2.6.14.tar.gz

    2、在/opt/redis-2.6.14/目录下,执行make时报错:/bin/sh: cc: command not found

    好吧,都没有装相关的编译工具。

    搜,sudo apt-get install build-essential

    error 1):bash: apt-get: command not found

    再搜,CentOS的软件安装工具不是apt-get  是yum,

    正确的应该是sudo yum -y install gcc gcc-c++ libstdc++-devel

    安装成功。

    error 2)在/opt/redis-2.6.14/目录下,执行make时报错

    make[1]: Entering directory `/opt/redis-2.6.14/src'
    CC adlist.o
    In file included from adlist.c:34:
    zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
    zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
    make[1]: *** [adlist.o] Error 1
    make[1]: Leaving directory `/opt/redis-2.6.14/src'
    make: *** [all] Error 2

    好吧,继续~,发现:http://xueliang1yi.blog.163.com/blog/static/1145570162012102114635764/

    好像遇到了类似的情况,文中提到了安装gcc,把他的命令也敲了一边,系统提示最新版本的已经装好了,不需要再装了。

    之后执行 make MALLOC=libc 就行

    error 3)执行完上面的命令后,系统提示 'Hint: To run 'make test' is a good idea'

    make test 报错: You need tcl 8.5 or newer in order to run the Redis test

    3.1)在上面的也是有提到的,不过还是找了一个更详细的安装tcl的方法;

    下载地址:http://downloads.sourceforge.net/tcl/tcl8.5.10-src.tar.gz

    安装命令:http://blog.csdn.net/makebuaa/article/details/6709140

    tcl 安装
    [user@localhost 桌面]$ ls tcl8.5.9-src.tar.gz
    tcl8.5.9-src.tar.gz
    [user@localhost 桌面]$ su
    密码:
    [root@localhost 桌面]# cp tcl8.5.9-src.tar.gz /usr/local/src/
    [root@localhost 桌面]# cd /usr/local/src/
    [root@localhost src]# tar -zxvf tcl8.5.9-src.tar.gz
    [root@localhost src]# cd tcl8.5.9/
    [root@localhost tcl8.5.9]# cd unix/
    [root@localhost unix]# ./configure --prefix=/usr/local/tcl/ --enable-shared
    [root@localhost unix]# make
    [root@localhost unix]# make install
    [root@localhost unix]# /usr/local/tcl/bin/tclsh8.5
    % exit
    [root@localhost unix]#

    3.2)还是提示错误需要tcl8.5或更新的版本

      发现 sudo yum install tcl 就可以搞定,只是版本是8.5.7的。

          终于提示'o/ All tests passed without errors!'

    在/opt/redis-2.6.14/目录下,执行make,OK;

    4、修改配置文件目录

    mkdir /etc/redis
    cp redis.conf /etc/redis

    5、运行

    redis-server /etc/redis/redis.conf

    摘自http://www.cnblogs.com/chy710/archive/2012/05/28/redis.html

    redis-server.exe是Redis服务程序,命令行运行后启动服务端
    [2624] 28 May 17:19:30 * Server started, Redis version 2.4.2
    [2624] 28 May 17:19:30 # Open data file dump.rdb: No such file or directory
    [2624] 28 May 17:19:30 * The server is now ready to accept connections on port 6379

    redis-cli.exe是一个客户端程序,命令行下运行,简单的一个Set/Get

    redis 127.0.0.1:6379> set mykey "this is a value"
    OK
    redis 127.0.0.1:6379> get mykey
    "this is a value"
    redis 127.0.0.1:6379>

    6、写入开机自启动 echo "redis-server /etc/redis/redis.conf" >>/etc/rc.local

    7、测试,参考 http://blog.csdn.net/21aspnet/article/details/6960757 

    启动进程

    #redis-server /etc/redis/redis.conf

    查看进程有没有成功启动

    #ps -ef | grep redis 
    测试输入一个键值
    #redis-cli set test "123456"
    获取键值
    #redis-cli get test

    Note:

    以下两文中都有链接一些另外的Redis的信息,有时间去看看...

    http://blog.csdn.net/chenggong2dm/article/details/6100001

    http://www.cnblogs.com/chy710/archive/2012/05/28/redis.html

    转自:http://www.cnblogs.com/la-isla-bonita/p/3582751.html

  • 相关阅读:
    Linux/shell: remove adjacent similar patterns
    Calculate difference between consecutive data points in a column from a file
    awk
    自定义Cordova插件(基础篇)
    npm init 命令生成package.json文件
    自定义Cordova插件详解
    Android 回退键监听
    Cordova结合Vue学习Camera
    解决悬浮的<header>、<footer>遮挡内容的处理技巧
    npm 是干什么的
  • 原文地址:https://www.cnblogs.com/chasewade/p/4563679.html
Copyright © 2020-2023  润新知