redis 在Linux下的安装与配置

redisLinux下的安装与配置

by:授客  QQ1033553122

测试环境

redis-3.0.7.tar.gz

下载地址:

http://redis.io/download

http://pan.baidu.com/s/1slh5YbV

CentOS 6.5-x86_64

安装配置redis

[root@localhost mnt]# tar xzf redis-3.0.7.tar.gz

[root@localhost local]# cd redis-3.0.7/

[root@localhost redis-3.0.7]# ls

00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests

BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils

CONTRIBUTING     INSTALL  README     runtest-cluster  src

[root@localhost redis-3.0.7]# make MALLOC=libc

cd src && make all

make[1]: Entering directory `/usr/local/redis-3.0.7/src'

LINK redis-check-dump

CC redis-check-aof.o

LINK redis-check-aof

Hint: It's a good idea to run 'make test' ;)

注意:

1、Linux平台下执行make命令时,必须加MALLOC=libc,否则会报错

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

zmalloc.h:55:2: error: #error "Newer version of jemalloc required"

2、需要安装gcc,否则会报类似如下的错误

/bin/sh: cc: command not found

……

make[1]: *** [adlist.o] Error 127

make[1]: Leaving directory `/usr/local/redis-3.0.7/src'

make: *** [all] Error 2

运行测试

[root@localhost ~]# yum install tcl.x86_64

注意:如果未安装tcl可能报错,如下

[root@localhost redis-3.0.7]# make test

cd src && make test

make[1]: Entering directory `/usr/local/redis-3.0.7/src'

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

make[1]: *** [test] Error 1

make[1]: Leaving directory `/usr/local/redis-3.0.7/src'

make: *** [test] Error 2

[root@localhost redis-3.0.7]# make test

56 seconds - unit/memefficiency

70 seconds - unit/hyperloglog

130 seconds - integration/replication-4

137 seconds - integration/replication-3

130 seconds - integration/replication-psync

98 seconds - unit/obuf-limits

\o/ All tests passed without errors!

Cleanup: may take some time... OK

make[1]: Leaving directory `/usr/local/redis-3.0.7/src'

启动redis服务

[root@localhost redis-3.0.7]# cd src/

redis 在Linux下的安装与配置

测试下

[root@localhost src]#
./redis-cli

127.0.0.1:6379> set foo
bar

OK

127.0.0.1:6379> get foo

"bar"

127.0.0.1:6379> exit

成功了

如上,启动时出来了一堆警告,咋办?进行如下配置

[root@localhost ~]# echo 511 >
/proc/sys/net/core/somaxconn

[root@localhost ~]# echo
vm.overcommit_memory=1 > /etc/sysctl.conf

[root@localhost ~]# sysctl
vm.overcommit_memory=1

vm.overcommit_memory = 1

[root@localhost ~]#

[root@localhost ~]# echo never >
/sys/kernel/mm/transparent_hugepage/enabled

[root@localhost ~]# echo never >
/etc/rc.local

重试,如下

redis 在Linux下的安装与配置

上一篇:RabbitMQ 设置队列的过期时间


下一篇:webpack入坑之旅(四)扬帆起航