下载
从官方网站下载稳定版本 redis-6.0.8.tar.gz,网址为:http://download.redis.io/releases/
用ftp或sftp工具拷贝redis-6.0.8.tar.gz到linux系统
解压
# 将上述包解压后
tar -xvf redis-6.0.8.tar.gz
安装
cd redis-6.0.8
# 编译安装到指定目录下
make
cd src && make PREFIX=/data/redis install
# 如果有执行出错,先安装gcc
# 若出现【zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录】,
# 则运行命令 make MALLOC=libc
# 以下命令视情况使用
# 编译出错时,清出编译生成的文件
make distclean
# 卸载
make uninstall
修改配置文件
# 配置redis为后台启动
# 拷贝配置文件到安装目录下
cd ../
mkdir /data/redis/conf
cp redis.conf /data/redis/conf
# 配置redis为后台启动
vim /data/redis/conf/redis.conf
# 将daemonize no改为daemonize yes
daemonize no -> daemonize yes
# 如有需要添加reids密码,添加
requirepass cloudmas
# 如需开启多线程模式,请配置以下配置
io-threads-do-reads yes
io-threads 4
开机启动
# 将redis加入到开机启动
vi /etc/rc.local
# 添加内容:
/data/redis/bin/redis-server /data/redis/conf/redis.conf
# 手动启动
# 开启redis:
/data/redis/bin/redis-server /data/redis/conf/redis.conf
远程连接
# 远程连接
使用工具远程连接redis时,可能会出现连接问题,可使用下方命令查看当前绑定的IP:HOST
ps -ef|grep redis
如需其他机器连接请修改以下配置:
bind 127.0.0.1
修改为
bind 当前ip
或直接注释 bind ,注释后代表绑定本机所有ip