Redis安装+密码认证

redis:

安装:
$ wget http://download.redis.io/releases/redis-3.2.7.tar.gz
$ tar xzf redis-3.2.7.tar.gz
$ cd redis-3.2.7
$ make

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

README.md中:

Allocator

Selecting a non-default memory allocator when building Redis is done by setting
the MALLOC environment variable. Redis is compiled and linked against libc
malloc by default, with the exception of jemalloc being the default on Linux
systems. This default was picked because jemalloc has proven to have fewer
fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

分配器allocator,如果有MALLOC这个环境变量,会用这个环境变量去建立redis,
而且libc并不是默认的分配器,默认的是jemalloc,但是如果没有jemalloc,而只有libc,就会make出错,所以需要添加参数.

解决:$ make MALLOC=libc

启动redis失败:
vim /usr/local/redis/etc/redis.conf
daemonize yes ---将daemonize的值修改为yes.

redis密码设置:
方法1:
vim /usr/local/redis/etc/redis.conf
requirepass kasumi 去掉本行的注释 ----重启服务
$redis-cli -h 127.0.0.1 -p 6379 -a kasumi ---使用密码登录执行成功.

方法2:

config set requirepass kasumi
修改后不需要重启服务,但是服务重启后,会使用配置文件中的密码.

原文地址:https://www.cnblogs.com/kasumi/p/6386269.html