下载

从官方网站下载稳定版本 redis-6.0.8.tar.gz,网址为:http://download.redis.io/releases/
用ftp或sftp工具拷贝redis-6.0.8.tar.gz到linux系统

解压

  1. # 将上述包解压后
  2. tar -xvf redis-6.0.8.tar.gz

安装

  1. cd redis-6.0.8
  2. # 编译安装到指定目录下
  3. make
  4. cd src && make PREFIX=/data/redis install
  5. # 如果有执行出错,先安装gcc
  6. # 若出现【zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录】,
  7. # 则运行命令 make MALLOC=libc
  8. # 以下命令视情况使用
  9. # 编译出错时,清出编译生成的文件
  10. make distclean
  11. # 卸载
  12. make uninstall

修改配置文件

  1. # 配置redis为后台启动
  2. # 拷贝配置文件到安装目录下
  3. cd ../
  4. mkdir /data/redis/conf
  5. cp redis.conf /data/redis/conf
  6. # 配置redis为后台启动
  7. vim /data/redis/conf/redis.conf
  8. # 将daemonize no改为daemonize yes
  9. daemonize no -> daemonize yes
  10. # 如有需要添加reids密码,添加
  11. requirepass cloudmas
  12. # 如需开启多线程模式,请配置以下配置
  13. io-threads-do-reads yes
  14. io-threads 4

开机启动

  1. # 将redis加入到开机启动
  2. vi /etc/rc.local
  3. # 添加内容:
  4. /data/redis/bin/redis-server /data/redis/conf/redis.conf
  5. # 手动启动
  6. # 开启redis:
  7. /data/redis/bin/redis-server /data/redis/conf/redis.conf

远程连接

  1. # 远程连接
  2. 使用工具远程连接redis时,可能会出现连接问题,可使用下方命令查看当前绑定的IP:HOST
  3. ps -ef|grep redis
  4. 如需其他机器连接请修改以下配置:
  5. bind 127.0.0.1
  6. 修改为
  7. bind 当前ip
  8. 或直接注释 bind ,注释后代表绑定本机所有ip