当前位置:网站首页>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
创建的服务
边栏推荐
- transformer通俗理解
- RestTemplate源码debug:可变形参引发的问题
- 7行代码让B站崩溃3小时,竟因“一个诡计多端的0”
- 虚拟偶像的歌声原来是这样生成的!
- 【QT】Qt获取前几天/后几天的时间
- [Code Hoof Set Novice Village 600 Questions] Find the square root of the given data
- Analyst: Baidu could become China's most valuable company by 2030
- 碎片化时间真的适合学习吗?
- 吴恩达撰文:公共数据的 “围墙”
- [Code Hoof Set Novice Village 600 Questions] Given an integer n, find all the values of x and y in floor(n/x)=y
猜你喜欢
随机推荐
Virtink:更轻量的 Kubernetes 原生虚拟化管理引擎
疫情驱动医疗数字化新业态,ActiveReports强力助推医院LIMS系统升级换代!
北汇信息继续扩大V2X测试服务,扎根重庆,服务全国
【QT】Qt获取前几天/后几天的时间
Security整各Gateway后配置不生效?
RestTemplate源码debug:可变形参引发的问题
字节跳动使用 Flink State 的经验分享
字节跳动基于 Iceberg 的海量特征存储实践
解决 @RefreshScope 导致定时任务注解 @Scheduled 失效
碎片化时间真的适合学习吗?
亿级用户背后的字节跳动云原生计算最佳实践
字节跳动 Flink 单点恢复功能及 Regional CheckPoint 优化实践
[Code Hoof Set Novice Village 600 Questions] Find the distance between two points in the space rectangular coordinate system
转载:同班毕业两夫妻退休待遇四比一
[Deep Learning] YOLO to VOC VOC to YOLO
三轮电摩专用之48V动力锂电池组-产品规格书
谈谈如何建立价值驱动的数据战略
7行代码让B站崩溃3小时,竟因“一个诡计多端的0”
公司无线规划设计及实施SOP
滚动条样式