当前位置:网站首页>centos8安装redis
centos8安装redis
2022-07-29 18:15:00 【OMUQUK】
简介: Redis 是一个开源的在内存存储键值对数据的存储程序。它可以被用作数据库,缓存,信息暂存,并且支持各种数据结构。本文将为大家讲解如何在 CentOS 8 上安装和配置 Redis。
一,安装gcc依赖
由于 redis 是用 C 语言开发,安装之前必先确认是否安装 gcc 环境(gcc -v),如果没有安装,执行以下命令进行安装
[[email protected] local] yum install -y gcc
二,下载并解压安装包
1.下载redis
wget http://download.redis.io/releases/redis-6.0.8.tar.gz

2.解压源码包
tar xzf redis-6.0.8.tar.gz

三、cd切换到redis解压目录下,再执行编译
[[email protected] redis]# cd redis-6.0.8
[[email protected] redis-6.0.8]# make
执行完make命令后,在redis-4.0.2 的 src目录下会出现编译后的 redis 服务程序 redis-server,还有用于测试的客户端程序 redis-cli

三,安装并指定安装目录
直接
make install(默认安装到/usr/local/bin目录下),这里我们可以使用以下指令安装到指定目录下
make install PREFIX=/opt/redis

1.查看安装目录
[[email protected] src]# cd /opt/redis/bin
[[email protected] bin]# ll

redis-benchmark 性能测试工具,可以在自己本子运行,看看自己本子性能如何
redis-check-aof 修复有问题的AOF文件,rdb和aof后面讲
redis-check-dump 修复有问题的dump.rdb文件
redis-sentinel Redis集群使用
redis-server Redis服务器启动命令
redis-cli 客户端,操作入口
四,后台启动
将redis解压目录下的
redis.conf配置文件复制到/etc/redis目录下,并修改复制后的redis.conf中的后台启动设置,让服务再后台启动daemonize no 改成 yes
Redis启动
进入到/opt/redis/bin
redis-server /etc/redis/redis.conf
用户端访问:redis-cli
多端口访问:redis-cli -p port
[[email protected] bin] redis-cli
127.0.0.1:6379> ping
PONG
五,配置环境变量
[[email protected] src]# vim /etc/profile
export REDIS_HOME=/opt/redis
export PATH=$PATH:$REDIS_HOME/bin
保存退出

source /etc/profile --刷新环境变量
source /etc/profile
六,redis-utlis的使用
[email protected] redis-6.0.8]# cd utils
[[email protected] utils]# ll

执行utils文件夹下面的install_server.sh脚本,可以为我们自动开启一个redis服务
注意: 首次启动install_server.sh提示我们This systems seems to use systemd. Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
解决方案:
vi ./install_server.sh
注释以下代码片段即可:
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi

然后重新启动:
./install_server.sh
具体操作如下:一直回车,不需要修改任何东西;(如果需要配置多个redis服务,则指定新的端口即可)
[[email protected] utils]# ./install_server.sh
----------------------------------------------------------------------------------------------------
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379] ---端口号
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] ----配置文件
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] ----日志文件
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] -----数据文件
Selected default - /var/lib/redis/6379
Please select the redis executable path [/opt/redis/bin/redis-server] -----服务安装路径(根据配置好得path得来的)
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /opt/redis/bin/redis-server
Cli Executable : /opt/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort. ----提示回车表示同意执行 Ctrl-C取消
Copied /tmp/6379.conf => /etc/init.d/redis_6379 ----可执行文件得位置
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
/var/run/redis_6379.pid exists, process is already running or crashed
Installation successful!
进入
/etc/init.d/文件夹下可以看到我们通过install_server.sh创建的服务
边栏推荐
- 11.99万起,东风风行游艇上市,产品力越级诚意满满
- 疫情驱动医疗数字化新业态,ActiveReports强力助推医院LIMS系统升级换代!
- KubeMeet 报名 | 「边缘原生」线上技术沙龙完整议程公布!
- 实时数仓:知乎实时数仓的架构演进
- R语言ggplot2可视化绘制条形图(bar plot)、使用gghighlight包突出高亮条形图中的特定条形(highlight specific bar plot)
- KubeMeet 报名 | 「边缘原生」线上技术沙龙完整议程公布!
- 请问跑sql任务调度必须得设置依赖的上游节点嘛?比如说我sql里面a b两张表join出来的结果写入
- 公司无线规划设计及实施SOP
- 深投控收购意大利半导体设备商被叫停
- 数字化来势汹汹,低代码起势,JNPF助力企业定制专属BIM
猜你喜欢
随机推荐
碎片化时间真的适合学习吗?
StarRocks 2.3 新版本特性介绍
今年一季度全球PC出货量同比增长32%,创21年来最快增速
A redis tool class to solve cache breakdown, cache penetration
西人马重磅发布自研电荷信号调理芯片CU0102B
EasyNVR更新版本至(V5.3.0)后页面不显示通道配置该如何解决?
虚拟偶像的歌声原来是这样生成的!
疫情驱动医疗数字化新业态,ActiveReports强力助推医院LIMS系统升级换代!
国产钡铼分布式IO模块如何与西门子PLC Profinet通讯
【学习笔记】NOIP模拟赛
The problem that crontab executes scheduled tasks and reports errors
字节跳动基于 Iceberg 的海量特征存储实践
tar命令详解---归档及压缩
R语言时间序列数据提取:使用xts包的last函数提取时间序列中最后面两周的数据(last 2 week)
多线程并发Callable
Security整各Gateway后配置不生效?
[Code Hoof Set Novice Village 600 Questions] Given an integer n, find all the values of x and y in floor(n/x)=y
恐造成下一个“千年虫”的闰秒,遭科技巨头们联合抵制
HCIP笔记第十四天
Frame双向通信插件FrameDataTrans









