CentOS 上面安装redis3.0.5

第一步:解压redis-3.0.5.tar

shell>tar -zxvf redis-3.0.5.tar

shell>cd redis-3.0.5


第二步:make 

shell>make

可能会出现异常

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


shell>yum install jemalloc

然后再次

shell>make

Make成功后

shell>cd src

shell>make test

这时如果出现 

\o/ All tests passed without errors!

Cleanup: may take some time... OK

则说明是成功的

第三步:安装

shell>cd ..

shell>make install 

这种方式安装后redis-server ,redis-cli 等程序会安装到默认目录/usr/local/bin

shell>make PREFIX=/usr/local/redis install

上面的命令是安装到指定目录


安装之后,在我们刚才解压的redis3.0.5 目录中有redis.conf

将这个文件拷到/usr/local/redis3.0.5目录下一份

shell>cp redis.conf /usr/local/redis3.0.5/bin


第四步:启动 redis

shell>cd /usr/local/redis3.0.5/bin

shell>./redis-server

出现下面的字样则说明启动redis 成功

24599:C 21 Dec 14:01:48.697 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 24599
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               


24599:M 21 Dec 14:01:48.736 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
24599:M 21 Dec 14:01:48.736 # Server started, Redis version 3.0.5
24599:M 21 Dec 14:01:48.736 # 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.
24599:M 21 Dec 14:01:48.736 # 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.
24599:M 21 Dec 14:01:48.736 * The server is now ready to accept connections on port 6379


第五步:验证

启动一个新的shell

shell>cd /usr/local/redis3.0.5/bin

shell>./redis-cli

会连接到本机的redis 服务器


出现这样的界面则说明OK


通过set 命令存入一个key value

通过一个get命令获得一个key 的value


第六步:

Redis 命令大全可以看这个网址

http://redis.io/commands


第七步:Redis 官方推荐Java 客户端jedis

网址:https://github.com/xetorthio/jedis

例子:

1
import  redis.clients.jedis.*
?
1
2
3
Jedis jedis =  new  Jedis( "localhost" );
jedis.set( "foo" "bar" );
String value = jedis.get( "foo" );




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值