在centos下安装redis

参考文章:http://www.cnblogs.com/silent2012/p/3499654.html

1、下载源码(可以直接上网下载),解压缩后,先安装gcc,再编译源码

$ 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

2、安装gcc,前提是配置好了yum仓库,我配置的是163仓库

$ yum -y install gcc

3、编译源码

$ make

4、编译完成后,在redis-2.8.3/src目录下,有三个可执行文件redis-server、redis-benchmark、redis-cli,在redis-2.8.3目录下有redis.conf文件。然后拷贝到一个目录下,如/usr/redis

mkdir /usr/redis
cd src
cp redis-server /usr/redis cp redis-benchmark /usr/redis cp redis-cli /usr/redis cp ../redis.conf /usr/redis cd /usr/redis

 5、启动Redis服务,./redis-server,如下图所示

[root@localhost redis]# ./redis-server 
[1688] 25 Apr 12:23:30.495 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
[1688] 25 Apr 12:23:30.498 * Max number of open files set to 10032
[1688] 25 Apr 12:23:30.540 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.3 (00000000/0) 32 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1688
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

[1688] 25 Apr 12:23:30.540 # Server started, Redis version 2.8.3
[1688] 25 Apr 12:23:30.543 # 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.
[1688] 25 Apr 12:23:30.549 * DB loaded from disk: 0.006 seconds
[1688] 25 Apr 12:23:30.549 * The server is now ready to accept connections on port 6379

6、打开另外一个客户端,测试一下是否启动成功。

[root@localhost ~]# cd /usr/redis/
[root@localhost redis]# ./redis-cli 
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> 

 

posted @ 2015-04-25 12:40  crazyMyWay  阅读(107)  评论(0)    收藏  举报