Linux 安装Redis

时间:2019-10-24
本文章向大家介绍Linux 安装Redis,主要包括Linux 安装Redis使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

环境:

CentOS 6.5

Redis 官网下载   https://redis.io/download

1. 下载文件

    1.CD 到存放下载文件夹的路径

创建下载文件夹 mkdir  /usr/local/softdownload
创建安装文件夹 mkdir /usr/local/programs 转到下载文件夹下 cd
/usr/local/softdownload

   2.下载并解压

下载 wget http://download.redis.io/releases/redis-4.0.1.tar.gz           
解压 tar xzf redis-4.0.1.tar.gz
移动 mv redis-4.0.1 /usr/local/programs
转到 cd /usr/local/programs/redis-4.0.1

 3. 安装

make PREFIX=/usr/local/programs/redis-4.0.1 install 

提示:Hint: It's a good idea to run 'make test' ;)
可以运行 make test 检查一下

若无问题会提示: All tests passed without errors!

安装成功后,ls ,可以看到有个bin文件夹

  [root@dmtest11-fastdfs redis-4.0.1]# ls
   00-RELEASENOTES COPYING Makefile deps runtest-cluster src
   BUGS INSTALL README.md redis.conf runtest-sentinel tests
   CONTRIBUTING MANIFESTO bin runtest sentinel.conf utils
  [root@dmtest11-fastdfs redis-4.0.1]#

 4.执行Redis-server 命令,启动Redis 服务 

转到bin目录 cd bin
执行启动操作 ./redis-server

 如上图所示,标识成功

 注:通过这种方式启动服务后,若会话关闭,服务也会停止,因此需要设置Redis从后台启动

5. 后台启动Redis 服务

  1. 修改redis.conf 

转到Redis安装目录   cd /usr/local/programs/redis-4.0.1
编辑redis.conf文件  vi redis.conf

定位到 /daemonize 
 
daemonize no

按 'i' ,进入 编辑模式 ,改成  daemonize yes

保存退出  ":wq!"

   2. 再次启用Redis服务,指定启动配置文件

bin/redis-server redis.conf

6.启动客户端

无密码 src/redis-cli
有密码 src/redis-cli -a 123456 (-a后为密码)

  如上成功

注:密码配置在 redis.conf ,requirepass  修改后,重启生效

bin/redis-server redis.conf 

原文地址:https://www.cnblogs.com/ericyi/p/11732787.html