|NO.R.00009|——————————|Navigation|————|服务启动导航.v04|————|Redis.v01|环境部署|
一、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 -p /opt/yanqi/servers/redis
[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 ~]# cd /opt/yanqi/servers/redis/bin/
[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启动:后端启动(守护进程启动)
### --- 拷贝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
### --- 启动服务
[root@hadoop bin]# ./redis-server 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>
### --- 参数说明
~~~ -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
分类:
dov003-spark
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」