|NO.Z.00005|——————————|^^ 部署 ^^|——|Hadoop&Redis.V05|——|Redis.v05|Redis5.05单机部署|
一、Redis单机版安装和使用
### --- Redis下载
~~~ 官网地址:http://redis.io/
~~~ 中文官网地址:http://www.redis.cn/
~~~ 下载地址:http://download.redis.io/releases/

### --- Redis安装环境
~~~ Redis 没有官方的Windows 版本,所以建议在Linux 系统上安装运行。
~~~ 我们使用CentOS 7 作为安装环境。
二、Redis安装
### --- 第一步:安装C 语言需要的GCC 环境
[root@hadoop ~]# yum install -y gcc-c++
[root@hadoop ~]# yum install -y wget
### --- 第二步:下载并解压缩Redis 源码压缩包
[root@hadoop software]# wget http://download.redis.io/releases/redis-5.0.5.tar.gz
[root@hadoop software]# tar -zxvf redis-5.0.5.tar.gz
### --- 第三步:编译Redis 源码,进入redis-5.0.5 目录,执行编译命令
[root@hadoop software]# cd redis-5.0.5/src/
[root@hadoop src]# make
### --- 第四步:安装Redis ,需要通过PREFIX 指定安装路径
[root@hadoop src]# mkdir /opt/yanqi/servers/redis -p
[root@hadoop src]# make install PREFIX=/opt/yanqi/servers/redis
[root@hadoop src]# ls ../../../servers/redis/bin/
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
三、Redis启动
### --- 前端启动
~~~ 启动命令: redis-server ,直接运行bin/redis-server 将以前端模式启动
~~~ 关闭命令: ctrl+c
~~~ 启动缺点:客户端窗口关闭则redis-server 程序结束,不推荐使用此方法
[root@hadoop bin]# ./redis-server
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 12001
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
### --- 后端启动(守护进程启动)
~~~ 第一步:拷贝redis-5.0.5/redis.conf 配置文件到Redis 安装目录的bin 目录
[root@hadoop ~]# cp /opt/yanqi/software/redis-5.0.5/redis.conf /opt/yanqi/servers/redis/bin/
### --- 第二步:修改redis.conf
[root@hadoop ~]# vim /opt/yanqi/servers/redis/bin/redis.conf
# 将`daemonize`由`no`改为`yes`
daemonize yes
# 默认绑定的是回环地址,默认不能被其他机器访问
# bind 127.0.0.1
# 是否开启保护模式,由yes该为no
protected-mode no
# 第507行:设置redis密码
requirepass 123456
### --- 第三步:启动服务
[root@hadoop bin]# ./redis-server redis.conf
~~~ # OR
[root@hadoop ~]# /opt/yanqi/servers/redis/bin/redis-server /opt/yanqi/servers/redis/bin/redis.conf
[root@hadoop bin]# ps -ef |grep 6379
root 12008 1 0 16:43 ? 00:00:00 ./redis-server 127.0.0.1:6379
### --- 第四步:后端启动的关闭方式
[root@hadoop bin]# ./redis-cli shutdown
### --- 命令说明
redis-server : // 启动redis 服务
redis-cli : // 进入redis 命令客户端
redis-benchmark : // 性能测试的工具
redis-check-aof : // aof 文件进行检查的工具
redis-check-dump : // rdb 文件进行检查的工具
redis-sentinel : // 启动哨兵监控服务
四、Redis命令行客户端
### --- 命令格式
[root@hadoop bin]# ./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379>
### --- 密码形式登录redis服务端
[root@hadoop ~]# /opt/yanqi/servers/redis/bin/redis-cli -h hadoop03 -p 6379 -a 123456
### --- 参数说明
~~~ -h:redis服务器的ip地址
~~~ -p:redis实例的端口号
### --- 默认方式
~~~ 如果不指定主机和端口也可以
~~~ 默认主机地址是127.0.0.1
~~~ 默认端口是6379
./redis0-cli
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
分类:
bdv012-redis
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通