Redis安装部署

一、Redis简介

​ Redis(Remote Dictionary Server ),即远程字典服务,是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。从2013年5月开始,Redis的开发由Pivotal赞助。

二、Redis安装

1、下载Redis安装包
[root@ chenc01 ~]# wget http://download.redis.io/releases/redis-4.0.6.tar.gz
--2020-03-19 17:34:31--  http://download.redis.io/releases/redis-4.0.6.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1723533 (1.6M) [application/x-gzip]
Saving to: ‘redis-4.0.6.tar.gz’

100%[==========================================================================================================>] 1,723,533    608KB/s   in 2.8s   

2020-03-19 17:35:31 (608 KB/s) - ‘redis-4.0.6.tar.gz’ saved [1723533/1723533]
[root@ chenc01 ~]# ls
anaconda-ks.cfg  redis-4.0.6.tar.gz
2、解压压缩包
[root@ chenc01 ~]# tar -zxvf redis-4.0.6.tar.gz 
redis-4.0.6/
redis-4.0.6/.gitignore
redis-4.0.6/00-RELEASENOTES
redis-4.0.6/BUGS
redis-4.0.6/CONTRIBUTING
redis-4.0.6/COPYING
redis-4.0.6/INSTALL
redis-4.0.6/MANIFESTO
.................................
[root@ chenc01 ~]# ls
anaconda-ks.cfg  redis-4.0.6  redis-4.0.6.tar.gz
3、yum安装gcc依赖
[root@ chenc01 ~]# yum -y install gcc
4、跳转到redis解压目录下
[root@ chenc01 ~]# cd redis-4.0.6/
[root@ chenc01 redis-4.0.6]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
5、编译安装
[root@ chenc01 ~]# make MALLOC=libc
[root@ chenc01 redis-4.0.6]# cd src && make install
    CC Makefile.dep

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
6、启动redis

make完后 redis-2.8.17目录下会出现编译后的redis服务程序redis-server,还有用于测试的客户端程序redis-cli,两个程序位于安装目录 src 目录下:

下面启动redis服务

[root@ chenc01 src]# ./redis-server
2851:C 19 Mar 18:41:33.087 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2851:C 19 Mar 18:41:33.087 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=2851, just started
2851:C 19 Mar 18:41:33.087 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 2851
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

2851:M 19 Mar 18:41:33.088 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
2851:M 19 Mar 18:41:33.088 # Server initialized
2851:M 19 Mar 18:41:33.088 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2851:M 19 Mar 18:41:33.088 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
2851:M 19 Mar 18:41:33.088 * Ready to accept connections

redis启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。

按 ctrl + c可以关闭窗口。

7、修改配置文件

第一步:修改redis.conf文件

daemonize no

修改为

daemonize yes

第二步:指定redis.conf文件启动

[root@ chenc01 src]# ./redis-server /usr/local/redis-4.0.6/redis.conf
17465:C 19 Mar 18:51:48.896 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
17465:C 19 Mar 18:51:48.897 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=17465, just started
17465:C 19 Mar 18:51:48.897 # Configuration loaded

启动redis服务进程后,就可以使用测试客户端程序redis-cli和redis服务交互了。 比如:

[root@ chenc01 src]# ./redis-cli 
127.0.0.1:6379> set one time
OK
127.0.0.1:6379> get one
"time"

三、参考资料

1、Redis官方文档资料

2、CentOS安装Redis+三种启动方式

3、service redis does not support chkconfig错误的解决办法

<think>好的,用户需要查找关于Redis安装部署的教程。首先,我得回想一下之前提供的引用内容,特别是引用[1]、[2]、[3]中的信息。用户可能是在Windows系统下安装,或者是Linux,需要分情况说明。引用[1]提到了Windows下通过MSI文件安装,配置密码和重启服务的步骤,这部分应该详细说明。而引用[3]则是关于Linux下的安装,包括复制配置文件、修改daemonize为yes、启动服务等步骤。用户的问题没有明确系统环境,所以应该涵盖两种主要系统的安装方法。 另外,用户可能对可视化客户端有需求,引用[2]提到了RedisClient等工具,可以补充在部署后的管理部分,提升用户体验。需要确保步骤清晰,避免遗漏关键点,比如配置文件修改、密码设置和服务启动命令。 还要检查是否有权限问题,比如Linux下是否需要root权限执行命令,以及如何验证安装是否成功,比如使用redis-cliping命令。同时,注意安全性,比如修改默认密码的重要性,避免直接使用foobared。 可能用户是开发人员或运维新手,步骤需要详细,代码块要准确,比如Shell命令和配置文件修改示例。此外,生成的相关问题要围绕安装后的配置、常见错误解决、性能优化等,帮助用户进一步学习。</think>### Redis 安装部署指南 #### **Windows 系统部署** 1. **下载安装包** 访问官方地址下载 Windows 版 Redis: [Redis-x64-5.0.14.1.msi](https://github.com/tporadowski/redis/releases) [^1] 2. **安装步骤** - 双击 `.msi` 文件,按提示完成安装 - 默认安装路径为 `C:\Program Files\Redis` 3. **配置密码** - 进入安装目录,打开 `redis.windows-service.conf` - 找到 `requirepass foobared`,在其下方添加: ```conf requirepass 123456 # 替换为自定义密码 ``` - 保存文件后,重启 Redis 服务(通过任务管理器)[^1] 4. **验证服务状态** ```bash redis-cli ping # 返回 PONG 表示成功 ``` --- #### **Linux 系统部署** 1. **编译安装** ```bash wget https://download.redis.io/releases/redis-6.2.6.tar.gz tar -xzf redis-6.2.6.tar.gz cd redis-6.2.6 make && make install ``` 2. **配置后台运行** - 复制配置文件: ```bash cp redis.conf /usr/local/redis/bin/ ``` - 修改 `redis.conf`: ```conf daemonize yes # 允许后台运行 requirepass 123456 # 设置密码 ``` [^3] 3. **启动服务** ```bash ./redis-server redis.conf ps -ef | grep redis # 查看进程确认状态 ``` --- #### **可视化客户端推荐** 1. **RedisInsight**(官方工具,支持监控与管理) 2. **RedisClient**(轻量级,适合基础操作)[^2] ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值