redis官网
https://redis.io/download
安装
$ wget http://download.redis.io/releases/redis-5.0.4.tar.gz$ tar xzf redis-5.0.4.tar.gz$ cd redis-5.0.4$ make
启动
src/redis-server
make时候可能报错
xx command not found
CentOS7默认没有安装gcc,这会导致我们无法make成功。使用yum安装:
yum -y install gcc
error: jemalloc/jemalloc.h: No such file or directory
原因是jemalloc重载了Linux下的ANSI C的malloc和free函数。解决办法:make时添加参数。
make MALLOC=libc
make之后,会出现一句Hint提示
Hint: To run 'make test' is a good idea ;)
但是不测试,通常是可以使用的。若我们运行make test ,会有如下提示
$ make testYou need tcl 8.5 or newer in order to run the Redis testmake: ***[test] Error_1
解决办法是用yum安装tcl8.5(或去tcl的官方网站http://www.tcl.tk/下载8.5版本,并参考官网介绍进行安装)
yum install tcl
安装完之后再次执行测试
$ make test.......\o/ All tests passed without errors!Cleanup: may take some time... OKmake[1]: Leaving directory `/usr/local/redis-5.0.4/src'
redis设置密码
临时生效
# ./redis-cli 127.0.0.1:6379> config set requirepass 123456OK127.0.0.1:6379>
永久生效
需更改redis.conf配置文件
requirepass passwoord
重启redis后生效