----------------------------------------安装----------------------------------------
wget http://download.redis.io/releases/redis-5.0.4.tar.gz tar zxvf redis-5.0.4.tar.gz -C /usr/local/ mv /usr/local/redis-5.0.4 /usr/local/redis cd /usr/local/redis make
修改配置文件
bind 0.0.0.0 #配置监听地址 protected-mode no #关闭保护模式,允许外网连接数据库 daemonize yes #开启以后台方式运行 logfile "/usr/local/redis/log/redis.log" #日志文件路径 dir /usr/local/redis/ #dump快照存放路径
mkdir /usr/local/redis/log;touch /usr/local/redis/log/redis.log #创建日志文件
创建命令链接
ln -s /usr/local/redis/src/redis-cli /usr/local/bin/redis ln -s /usr/local/redis/src/redis-cli /usr/local/bin/redis-cli ln -s /usr/local/redis/src/redis-server /usr/local/bin/redis-server
设置redis开机自启动
echo "redis-server /usr/local/redis/redis.conf" >> /etc/rc.local chmod +x /etc/rc.local
启动redis服务
redis-server /usr/local/redis/redis.conf
测试连接
redis-cli
----------------------------------------安装过程可能出现的问题----------------------------------------
1.CentOS默认没有安装gcc,这会导致我们无法make成功
yum install gcc-c++ -y #解决办法:yum安装开发环境
2.make时报如下错误:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
#include <jemalloc/jemalloc.h>
^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/redis-5.0.4/src‘
make: *** [all] Error 2
原因是jemalloc重载了Linux下的ANSI C的malloc和free函数
make MALLOC=libc #解决办法:make时添加参数
3.make之后,会出现一句提示
Hint: To run ‘make test‘ is a good idea ;)
但是不测试,通常是可以使用的;若我们运行make test ,会有如下提示
[devnote@devnote src]$ make test
You need tcl 8.5 or newer in order to run the Redis test
make: ***[test] Error_1
yum install tcl -y #解决办法:yum安装tcl8.5
原文:https://www.cnblogs.com/omgasw/p/10755405.html