Centos6.5 安装 redis

此文章为原创,转载请注明出处!!!

 

redis官方下载地址:http://redis.io/download 

  官方下载地址里面有描述安装方法

  1.下载redis压缩包

      命令:wget http://download.redis.io/releases/redis-2.8.19.tar.gz

2.解压redis压缩包

命令:tar xzf redis-2.8.19.tar.gz

3.进入到解压后的redis路径下

命令:cd redis-2.8.19

4.最后一步安装

命令:make

 

我相信很多人都会安装,一共就这么4步也是非常简单的,但是make之后可能会遇到几个问题

1.没有安装gcc,错误信息如下:

 

make[2]: Entering directory `/redis/redis-2.8.19/deps/hiredis'
cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[2]: cc: Command not found

  解决办法:安装gcc  

         命令:yum install gcc-c++

2.没有安装tcl,错误信息如下:

  

couldn't execute "tclsh8.5": no such file or directory

 解决办法:安装tcl

 

     命令:yum install -y tcl

3.一些编译依赖或原来编译遗留出现的问题,错误信息如下:

zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory

 解决办法:执行命令:make MALLOC=libc

 清理 make distclean 重新执行 make,成功后执行make test 检查是否有错误,没有执行 make install

 

最后启动redis服务,命令如下:

redis-server   redis.conf

启动时可能会出现警告:

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

 解决办法:修改 redis.conf配置文件中 大约37行的位置 daemonize no 改成 daemonize yes

重新启动服务 redis-server redis.conf

 

启动成功后我们进行redis缓存的测试

命令:./bin/redis-cli  出现 127.0.0.1:6379>  表示连接成功

命令: set test 123123

命令:get test  执行结果 123123 表示获取成功。

 

如果需要外网访问,请在redis.conf配置文件中大约 63行 bind 192.168.1.100 10.0.0.1

 64行 bind 127.0.0.1 前面加上 # 号注释掉这两行代码,表示访问不限制IP地址

如果外网还是连接不上,请关闭6379端口的防火墙

 

JAVA技术交流群 532101200
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值